乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      推薦一個markdown格式轉(zhuǎn)html格式的開源JavaScript庫

       汪子熙 2019-03-27

      這個markdown格式轉(zhuǎn)html格式的開源JavaScript庫在github上的地址:

      https://github.com/millerblack/markdown-js

      從markdown 格式轉(zhuǎn)成html源代碼格式

      新建一個以js結(jié)尾的文件,將下列內(nèi)容粘貼進去:

      var markdown = require( "markdown" ).markdown;console.log( markdown.toHTML( "Hello *World*!" ) );

      用nodejs執(zhí)行,可以看到markdown格式的字符串:

      Hello World!

      被自動轉(zhuǎn)換成了html格式的字符串:

      <p>Hello <em>World</em>!</p>

      除了nodejs以外,我們還可以在瀏覽器里使用這個開源庫。

      新建一個html,將下列源碼粘貼進去:

      <!DOCTYPE html><html><body><textarea id="text-input" oninput="this.editor.update()"rows="6" cols="60">Type **Markdown** here.</textarea><div id="preview"> </div><script src="../node_modules/markdown/lib/markdown.js"></script><script>function Editor(input, preview) {this.update = function () {
      
      preview.innerHTML = markdown.toHTML(input.value);
      
      };
      
      input.editor = this;this.update();
      
      }var $ = function (id) { return document.getElementById(id); };new Editor($("text-input"), $("preview"));</script></body></html>

      用瀏覽器打開這個html,在頂部輸入框里輸入markdown代碼后,能自動調(diào)用這個開源庫,轉(zhuǎn)換成html源代碼,然后賦給innerHTML, 這樣我們在UI上能看到實時的markdown代碼轉(zhuǎn)html代碼的結(jié)果。

      要獲取更多Jerry的原創(chuàng)文章,請關(guān)注公眾號"汪子熙

        轉(zhuǎn)藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多