v2.0.11

Links and Media

Last updated


This page covers inline, reference and relative links, bare URLs, image sizing, videos, and YouTube or Vimeo embeds.

SyntaxNotes
[text](https://example.com)Inline link, opens in a new tab
[text](https://example.com "title")The title takes double or single quotes
[![alt](badge.svg)](https://example.com), [![alt](badge.svg)][ref], [`code` and $x$](https://example.com)Link text, inline or reference, can hold images (with sizes), inline code and inline math
[text](./a.md), [text](../b.md), [text](/c), [text](#anchor)Relative paths and anchors
[mail](mailto:a@example.com), [call](tel:+886912345678)mailto: and tel: links open in the same page, without target="_blank"; also works in reference definitions
https://example.comBare URLs become links; trailing punctuation stays in the text
[text][ref] with [ref]: https://example.com "title"Reference link; ref is case-insensitive and the definition line is not output

URLs with other schemes (such as javascript: or ftp:) are not linked and stay as plain text. The scheme must be lowercase (MAILTO: stays text), and a bare mailto: address is not linked.

Images and Videos


SyntaxOutput
![alt](a.png "title")<img class="md-img">
![a](a.png)(300x200)300px wide, 200px high
![a](a.png)(50%x)Width only; a number with % is a percentage
![a](a.png)(x120)Height only
![a](a.png)(120)Same width and height
![a](a.mp4), ![a](a.mov)<video controls>, sizes work the same way

Embedded Players


When a link points to YouTube (youtube.com/watch?v=, youtu.be/, /embed/) or Vimeo, an embedded player follows the link.

Examples



Inline links, bare URLs, styles wrapping URLs, relative paths and titles.
  1. <div id="out" class="nanomd"></div>
  2. <script type="text/markdown" id="md">
  3. Links: [NanoMD](https://nanomd.pardn.io), bare URL https://github.com/pardnchiu/NanoMD.
  4. Styles around bare URLs: **https://nanomd.pardn.io**, ~~https://github.com~~, *https://nanomd.pardn.io*, _https://github.com_
  5. Relative: [same dir](./other.md), [parent](../README.md), [root](/docs/a.md), [anchor](#md-fn-1), [javascript: rejected](javascript:alert(1))
  6. Same page: [mail](mailto:dev@pardn.io), [call](tel:+886912345678), bare mailto:dev@pardn.io
  7. Titles: [NanoMD](https://nanomd.pardn.io "NanoMD docs"), [GitHub](https://github.com/pardnchiu/NanoMD 'single-quoted title')
  8. </script>
  9. <script>
  10. const out = document.getElementById("out");
  11. out.innerHTML = MDParser.Parse(document.getElementById("md").textContent).html();
  12. MDParser.Refresh(out);
  13. </script>
Live preview · @pardnchiu/nanomd@2.0.11

Linked Images


An image inside the link text becomes a clickable image, such as a badge; inline code and math in link text render as well.
  1. <div id="out" class="nanomd"></div>
  2. <script type="text/markdown" id="md">
  3. Badge: [![Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)
  4. Image with text: [dog ![dog](/static/image/dog-7128749_640.jpg)(x40) photo](https://nanomd.pardn.io)
  5. Code and math: [`Parse()`](https://nanomd.pardn.io/parser-api), [formula $E=mc^2$](https://nanomd.pardn.io/syntax-inline)
  6. </script>
  7. <script>
  8. MDParser.Init({ enable: { latex: true } }).then(() => {
  9. const out = document.getElementById("out");
  10. out.innerHTML = MDParser.Parse(document.getElementById("md").textContent).html();
  11. MDParser.Refresh(out);
  12. console.log(out.querySelectorAll("a > img").length, "linked images");
  13. });
  14. </script>
Live preview · @pardnchiu/nanomd@2.0.11


Case-insensitive labels, titles, relative targets, styles around references and undefined labels.
  1. <div id="out" class="nanomd"></div>
  2. <script type="text/markdown" id="md">
  3. References: [NanoMD][nanomd], [different case][NANOMD], [with title][gh], [relative][rel], **[bold around][nanomd]**, [undefined][missing]
  4. [nanomd]: https://nanomd.pardn.io
  5. [gh]: https://github.com/pardnchiu/NanoMD "GitHub source"
  6. [rel]: ./other.md
  7. </script>
  8. <script>
  9. const out = document.getElementById("out");
  10. out.innerHTML = MDParser.Parse(document.getElementById("md").textContent).html();
  11. MDParser.Refresh(out);
  12. </script>
Live preview · @pardnchiu/nanomd@2.0.11

Images and Video


Titles, both sizes, width only, height only, a single square value and a video.
  1. <div id="out" class="nanomd"></div>
  2. <script type="text/markdown" id="md">
  3. Image: ![dog](/static/image/dog-7128749_640.jpg "dog")
  4. Size: ![flamingo](/static/image/flamingo-9190160_640.jpg)(300x200)
  5. Width only: ![hippopotamus](/static/image/hippopotamus-9147023_640.jpg)(50%x)
  6. Height only: ![stilt](/static/image/stilt-8593487_640.jpg)(x120)
  7. Square: ![corn](/static/image/corn-9135131_640.jpg)(120) one value sets both
  8. Video: ![video](/static/image/233867_tiny.mp4 "video title")(320x)
  9. </script>
  10. <script>
  11. const out = document.getElementById("out");
  12. out.innerHTML = MDParser.Parse(document.getElementById("md").textContent).html();
  13. MDParser.Refresh(out);
  14. </script>
Live preview · @pardnchiu/nanomd@2.0.11

YouTube and Vimeo


Links and bare URLs to YouTube or Vimeo get an embedded player.
  1. <div id="out" class="nanomd"></div>
  2. <script type="text/markdown" id="md">
  3. YouTube: [Me at the zoo](https://www.youtube.com/watch?v=jNQXAC9IVRw)
  4. YouTube bare URL: https://youtu.be/jNQXAC9IVRw
  5. Vimeo: [The New Vimeo Player](https://vimeo.com/76979871)
  6. </script>
  7. <script>
  8. const out = document.getElementById("out");
  9. out.innerHTML = MDParser.Parse(document.getElementById("md").textContent).html();
  10. MDParser.Refresh(out);
  11. </script>
Live preview · @pardnchiu/nanomd@2.0.11
中文