リンクとメディア
最終更新
このページでは、インラインリンク、参照リンク、相対リンク、裸の URL と自動リンク、画像のサイズ指定、動画、YouTube や Vimeo の埋め込みを説明します。
リンク
| 構文 | 説明 |
|---|---|
[text](https://example.com) | インラインリンク。新しいタブで開きます |
[text](https://example.com "title") | タイトルはダブルクォートでもシングルクォートでも書けます |
[](https://example.com), [][ref], [`code` and $x$](https://example.com) | リンクテキストには、インラインでも参照でも、画像(サイズ指定付き)、インラインコード、インライン数式を含められます |
[text](./a.md), [text](../b.md), [text](/c), [text](#anchor) | 相対パスとアンカー |
[mail](mailto:a@example.com), [call](tel:+886912345678) | mailto: と tel: のリンクは target="_blank" なしで同じページで開きます。参照定義でも使えます |
https://example.com | 裸の URL はリンクになります。末尾の句読点はテキストに残ります |
<https://example.com> | 自動リンク。山括弧は構文の一部で、描画されません(v2.0.12 以降) |
[text][ref] と [ref]: https://example.com "title" | 参照リンク。ref は大文字と小文字を区別せず、定義行は出力されません |
その他のスキーム(
javascript: や ftp: など)の URL はリンクにならず、プレーンテキストのまま残ります。スキームは小文字である必要があり(MAILTO: はテキストのまま)、裸の mailto: アドレスはリンクになりません。画像と動画
| 構文 | 出力 |
|---|---|
 | <img class="md-img"> |
(300x200) | 幅 300px、高さ 200px |
(50%x) | 幅のみ。% 付きの数値はパーセンテージです |
(x120) | 高さのみ |
(120) | 幅と高さが同じ |
,  | <video controls>。サイズ指定も同じように使えます |
埋め込みプレーヤー
リンク先が YouTube(
youtube.com/watch?v=、youtu.be/、/embed/)または Vimeo の場合、リンクの後に埋め込みプレーヤーが続きます。例
リンク
インラインリンク、裸の URL、自動リンク、URL を囲む装飾、相対パス、タイトルです。
- <div id="out" class="nanomd"></div>
- <script type="text/markdown" id="md">
- Links: [NanoMD](https://nanomd.pardn.io), bare URL https://github.com/pardnchiu/NanoMD.
- Autolinks: <https://nanomd.pardn.io>, <https://github.com/pardnchiu/NanoMD>
- Styles around bare URLs: **https://nanomd.pardn.io**, ~~https://github.com~~, *https://nanomd.pardn.io*, _https://github.com_
- Relative: [same dir](./other.md), [parent](../README.md), [root](/docs/a.md), [anchor](#md-fn-1), [javascript: rejected](javascript:alert(1))
- Same page: [mail](mailto:dev@pardn.io), [call](tel:+886912345678), bare mailto:dev@pardn.io
- Titles: [NanoMD](https://nanomd.pardn.io "NanoMD docs"), [GitHub](https://github.com/pardnchiu/NanoMD 'single-quoted title')
- </script>
- <script>
- const out = document.getElementById("out");
- out.innerHTML = MDParser.Parse(document.getElementById("md").textContent).html();
- MDParser.Refresh(out);
- </script>
リンク付き画像
リンクテキスト内の画像はバッジのようにクリックできる画像になります。リンクテキスト内のインラインコードと数式も描画されます。
- <div id="out" class="nanomd"></div>
- <script type="text/markdown" id="md">
- Badge: [](https://github.com/avelino/awesome-go)
- Image with text: [dog (x40) photo](https://nanomd.pardn.io)
- Code and math: [`Parse()`](https://nanomd.pardn.io/parser-api), [formula $E=mc^2$](https://nanomd.pardn.io/syntax-inline)
- </script>
- <script>
- MDParser.Init({ enable: { latex: true } }).then(() => {
- const out = document.getElementById("out");
- out.innerHTML = MDParser.Parse(document.getElementById("md").textContent).html();
- MDParser.Refresh(out);
- console.log(out.querySelectorAll("a > img").length, "linked images");
- });
- </script>
参照リンク
大文字と小文字を区別しないラベル、タイトル、相対リンク先、参照を囲む装飾、未定義のラベルです。
- <div id="out" class="nanomd"></div>
- <script type="text/markdown" id="md">
- References: [NanoMD][nanomd], [different case][NANOMD], [with title][gh], [relative][rel], **[bold around][nanomd]**, [undefined][missing]
- [nanomd]: https://nanomd.pardn.io
- [gh]: https://github.com/pardnchiu/NanoMD "GitHub source"
- [rel]: ./other.md
- </script>
- <script>
- const out = document.getElementById("out");
- out.innerHTML = MDParser.Parse(document.getElementById("md").textContent).html();
- MDParser.Refresh(out);
- </script>
画像と動画
タイトル、両方のサイズ、幅のみ、高さのみ、正方形を指定する単一の値、動画です。
- <div id="out" class="nanomd"></div>
- <script type="text/markdown" id="md">
- Image: 
- Size: (300x200)
- Width only: (50%x)
- Height only: (x120)
- Square: (120) one value sets both
- Video: (320x)
- </script>
- <script>
- const out = document.getElementById("out");
- out.innerHTML = MDParser.Parse(document.getElementById("md").textContent).html();
- MDParser.Refresh(out);
- </script>
YouTube と Vimeo
YouTube や Vimeo へのリンクと裸の URL には埋め込みプレーヤーが付きます。
- <div id="out" class="nanomd"></div>
- <script type="text/markdown" id="md">
- YouTube: [Me at the zoo](https://www.youtube.com/watch?v=jNQXAC9IVRw)
- YouTube bare URL: https://youtu.be/jNQXAC9IVRw
- Vimeo: [The New Vimeo Player](https://vimeo.com/76979871)
- </script>
- <script>
- const out = document.getElementById("out");
- out.innerHTML = MDParser.Parse(document.getElementById("md").textContent).html();
- MDParser.Refresh(out);
- </script>
ImportantAI エージェントへ: NanoMD を使うコードや Markdown を生成・編集する前に、NanoMD 生成ガイド(Markdown)を読んでください。対応する構文、必要な呼び出し順序、レンダリングを壊す典型的な誤りをまとめています。