v2.0.11

Inline Formatting

Last updated


This page covers bold, italic, strikethrough, highlight, subscript, superscript, escapes, code spans and inline math.

Styles


SyntaxOutputNotes
**bold**, __bold__<span class="md-bold">__ next to letters or digits is not converted (such as __init__x)
*em*, _em_<em>_ between letters or digits is not converted (such as snake_case)
***both***, ___both___Bold wrapping italic
~~del~~<del>
==mark==<mark>
H~2~O<sub>No spaces inside
x^2^<sup>No spaces inside

Styles can wrap links, such as **[link](https://nanomd.pardn.io)**.

Escapes


A backslash followed by any ASCII punctuation outputs that character, such as \*, \_, \`, \[, \$ and \\.

Code Spans


SyntaxNotes
`code`The content is not parsed further
**bold `code`**Code spans can sit inside bold, italic, strikethrough and other styles; a ** inside the code does not close the style
`` a`b ``Matching open and close backtick counts wrap shorter backtick runs
One space on both sides of the contentOne space is removed from each side, so content can start with a backtick
The content is a file pathBecomes a file link when fileEndpoint is set; see File Links

Inline Math


$...$ outputs md-math-inline, which Refresh() renders once KaTeX is enabled; see Dependencies and Refresh. These are not converted:
SyntaxReason
$5 and $10The closing $ is followed by a digit
$ a $Whitespace inside the $
$$a$$Two $ in a row
\$Escaped

Examples


Styles


Every inline style in one paragraph.
  1. <div id="out" class="nanomd"></div>
  2. <script type="text/markdown" id="md">
  3. Inline: **bold**, __bold__, *italic*, _italic_, ***bold italic***, ___bold italic___, ~~deleted~~, ==marked==, H~2~O, x^2^, `code`
  4. </script>
  5. <script>
  6. const out = document.getElementById("out");
  7. out.innerHTML = MDParser.Parse(document.getElementById("md").textContent).html();
  8. MDParser.Refresh(out);
  9. </script>
Live preview · @pardnchiu/nanomd@2.0.11

Escapes and Non-Conversion


Escaped markers and patterns that intentionally stay plain text.
  1. <div id="out" class="nanomd"></div>
  2. <script type="text/markdown" id="md">
  3. Escapes: \*not italic\*, \_\_not bold\_\_, \`not code\`, \[not a link\](https://a.com), \\ a backslash itself
  4. Not converted: snake_case_name, __init__x, 2^10 and 3^ x, `a*b*c`
  5. </script>
  6. <script>
  7. const out = document.getElementById("out");
  8. out.innerHTML = MDParser.Parse(document.getElementById("md").textContent).html();
  9. MDParser.Refresh(out);
  10. </script>
Live preview · @pardnchiu/nanomd@2.0.11

Code Spans


Multi-backtick code spans, unmatched backtick runs and code inside styles.
  1. <div id="out" class="nanomd"></div>
  2. <script type="text/markdown" id="md">
  3. Multi-backtick code: ```abc```, `` a`b ``, `` ``` ``, ``mismatched`, ```` a lone backtick run
  4. Inside styles: **bold `code` here**, *`italic code`*, ~~`struck code`~~, **a `**` b**
  5. </script>
  6. <script>
  7. const out = document.getElementById("out");
  8. out.innerHTML = MDParser.Parse(document.getElementById("md").textContent).html();
  9. MDParser.Refresh(out);
  10. </script>
Live preview · @pardnchiu/nanomd@2.0.11

Inline Math


Inline math renders with KaTeX; invalid math falls back to $...$, and money amounts stay text.
  1. <div id="out" class="nanomd"></div>
  2. <script type="text/markdown" id="md">
  3. Inline math: $E=mc^2$, $\frac{a}{b}$, $x_1 + x_2^{*}$, $\{a, b\}$, $\frac{1}{$ shows the source when invalid
  4. Not math: prices $5 and $10, \$escaped\$, `$inside code$`, $ spaced $, $$a$$
  5. </script>
  6. <script>
  7. const out = document.getElementById("out");
  8. out.innerHTML = MDParser.Parse(document.getElementById("md").textContent).html();
  9. MDParser.Init({ enable: { latex: true } })
  10. .then(() => MDParser.Refresh(out))
  11. .catch((err) => console.error(err.message));
  12. </script>
Live preview · @pardnchiu/nanomd@2.0.11
中文