I want to type the following sentence in a markdown file: she says <h1>
is large. I can do it in StackOverflow with three backticks around h1, but this doesn't work for a .md file. I've also tried a single backtick, single quote, double quote, hashtags, spacing, <code>h1</code>
and everything else I could think of. Is there a way to do this?
问题:
回答1:
You can escape the <
characters by replacing them with <
, which is the HTML escape sequence for <
. You're sentence would then be:
she says <h1> is large
As a side note, the original Markdown "spec" has the following to say:
However, inside Markdown code spans and blocks, angle brackets and ampersands are always encoded automatically. This makes it easy to use Markdown to write about HTML code. (As opposed to raw HTML, which is a terrible format for writing about HTML syntax, because every single < and & in your example code needs to be escaped.)
...which means that, if you're still getting tags when putting them in backticks, whatever renderer you're using isn't "compliant" (to the extent that one can be compliant with that document), and you might want to file a bug.
回答2:
Generally, you can surround the code in single backticks to automatically escape the characters. Otherwise just use the HTML escapes for < <
and > >
.
i.e.
she says <h1> is large or she says `<h1>` is large