爱意满满的作品展示区。
lookas2001

写了一个 markdown-it 拓展,让你的 Markdown 变的更加强大!(markdown-it-directive)

  •  
  •   lookas2001 · May 6, 2020 · 2202 views
    This topic created in 2229 days ago, the information mentioned may be changed or developed.

    其实,标题这么讲有些夸张(捂脸)。这个插件的主要作用是实现了 Generic directives/plugins syntax spec 标准,配合另外一个插件 markdown-it-directive-webcomponents 可以将 WebComponents 嵌入到 Markdown 文档中。这样可以很大程度上减轻为 Markdown 拓展功能所需要的写代码负担。

    具体来讲,可以将:

    text before :directive-name[content](/link "destination" /another "one"){.class #id name=value name="string!"} text after
    
    :: directive-name [inline content] (/link "destination" /another "one") {.class #id name=value name="string!"} content title ::
    
    ::: directive-name [inline content] (/link "destination" /another "one") {.class #id name=value name="string!"} content title ::
    content
    :::
    

    配合 markdown-it 解析成:

    <p>text before <tag-name class="class" id="id" name="value" src="/link" title="destination">content</tag-name> text after</p>
    
    <tag-name class="class" id="id" name="value" src="/link" title="destination">inline content</tag-name>
    
    <tag-name class="class" id="id" name="value" src="/link" title="destination">
    <p>content</p>
    </tag-name>
    

    接下来就可以用 Vue 这种框架来渲染结果啦~~~

    希望能为需要的人带来帮助!

    项目地址:

    markdown-it-directive: https://github.com/hilookas/markdown-it-directive
    markdown-it-directive-webcomponents: https://github.com/hilookas/markdown-it-directive-webcomponents

    1 replies    2020-05-06 20:03:31 +08:00
    lookas2001
        1
    lookas2001  
    OP
       May 6, 2020
    如果对你有帮助的话,欢迎给个 star~~~
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2875 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 08:40 · PVG 16:40 · LAX 01:40 · JFK 04:40
    ♥ Do have faith in what you're doing.