v2.0.1

註腳

最後更新


本頁涵蓋註腳引用與定義、編號規則、多行定義與未定義引用的處理。

寫法


寫法說明
文字[^1]、文字[^note]引用;id 可用數字或文字,不分大小寫
[^1]: 內容定義,只在最外層判斷;內容可使用行內格式,也可再引用其他註腳
定義下一行縮排屬於同一個註腳,可接續多段
定義下一行未縮排的文字併入同一段,遇到其他區塊開頭時結束

輸出


情況結果
有定義的引用<sup class="md-footnote-ref"> 連到 #md-fn-{index}
編號依首次引用的順序 1、2、3...;同一個註腳再次引用沿用同一編號
註腳區文末附上 <section class="md-footnotes">,每項 id="md-fn-{index}"
沒有定義的引用原樣輸出為 [^id] 文字
沒被引用的定義不輸出
程式碼內或跳脫的 [^1]不視為引用

範例


註腳


數字與具名註腳、重複與不分大小寫的引用、未定義的引用、註腳內引用註腳,以及沒被引用的定義。
  1. <div id="out" class="nanomd"></div>
  2. <script type="text/markdown" id="md">
  3. Footnotes: first[^1], named[^note], again[^1], different case[^NOTE], undefined[^missing], not in code `[^1]`, escaped \[^1]
  4. [^note]: Named footnote content with **bold**, referencing another footnote[^nested]
  5. Indented second paragraph
  6. [^1]: First footnote content
  7. continuing the same paragraph
  8. [^nested]: A footnote referenced from a footnote
  9. [^unused]: Unreferenced footnotes are not output
  10. </script>
  11. <script>
  12. const out = document.getElementById("out");
  13. out.innerHTML = MDParser.Parse(document.getElementById("md").textContent).html();
  14. MDParser.Refresh(out);
  15. </script>
即時預覽 · @pardnchiu/nanomd@2.0.1
EN