0.2.10 • Published 2 years ago

@yxonic/vmark v0.2.10

Weekly downloads
-
License
-
Repository
github
Last release
2 years ago

VMark

Markdown rendering as Vue 3 component tree, with carefully selected Markdown features, human-friendly rendering options, and custom vue component support. It also provides a Vite plugin for this to happen at server-side.

Usage

npm i @yxonic/vmark

Then in your .vue file:

<template>
  <v-mark src="# heading">
</template>
<script setup>
import VMark from '@yxonic/vmark'
</script>

Vite plugin

You can also use VMark to import .md files as Vue components. In your vite.config.js:

import vue from '@vitejs/plugin-vue'
import vmark from '@yxonic/vmark/vite'

export default {
  plugins: [vue(), vmark()]
}

Configuration

VMark:

export interface MarkdownVueRendererOptions {
  html?: boolean
  containers?: Record<string, ComponentOptions | null>
  customRules?: RenderRules
  nodeRenderer?: NodeRenderer
}

export interface Node {
  tag: string | ComponentOptions | null
  attrs: Record<string, string>
  children: VNodeArrayChildren
}
export type TokenRenderRule = (
  token: Token,
  ctx: { nodeRenderer: NodeRenderer },
) => Node | string | null
export type RenderRules = Record<string, TokenRenderRule>
export type NodeRenderer = (node: Node | string) => VNodeChild

Vite plugin:

type ComponentResolver = (
  name: string,
  id: string,
) => string | { name: string; path: string } | null | undefined

interface VMarkVitePluginOption {
  rewriteBaseUrl?: boolean
  containers?: string[]
  defaultComponentDir?: string
  componentDirResolver?: (id: string) => string | null | undefined
  componentResolver?: ComponentResolver | ComponentResolver[]
}

TODO

  • Support token renderer customization for each type.
  • A handy collection of markdown-it plugins (anchor, attrs, KaTeX, etc.).
  • Feature-oriented options for <v-mark>.
  • Custom components.
  • Dynamic options.
  • Vite plugin.
  • Export frontmatter and document structure.
  • Error display.
  • Documentation.

markdown-it Plugins

Community packages

* needs special care when rendering

Manual

  • Link rewrite
  • KaTeX
0.2.10

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.4

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.28

2 years ago

0.1.27

2 years ago

0.1.26

2 years ago

0.1.25

2 years ago

0.1.24

2 years ago

0.1.23

2 years ago

0.1.22

2 years ago

0.1.21

2 years ago

0.1.20

2 years ago

0.1.19

2 years ago

0.1.18

2 years ago

0.1.17

2 years ago

0.1.16

2 years ago

0.1.15

2 years ago

0.1.14

2 years ago

0.1.13

2 years ago

0.1.12

2 years ago

0.1.11

2 years ago

0.1.10

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago