github - Github Markdown 代码块中的上标

标签 github markdown

<sup></sup>标签用于上标。创建代码块是使用反引号完成的。我遇到的问题是,当我尝试在代码块中创建上标时,它会打印出 <sup></sup>标签而不是格式化标签之间的文本。

当它在反引号之间时,如何正确格式化上标文本?

发布解决方案编辑

期望的输出:A2而不是 A<sup>2</sup>

最佳答案

除非您使用原始 HTML,否则这是不可能的。

rules具体说明:

With a code span, ampersands and angle brackets are encoded as HTML entities automatically, which makes it easy to include example HTML tags.



换句话说,不可能使用 HTML 来格式化代码跨度中的文本。事实上,代码跨度是纯文本、无格式文本。将任何文本显示为上标意味着它不是纯文本、未格式化的文本。因此,这在设计上是不可能的。

但是,规则也state :

Markdown is not a replacement for HTML, or even close to it. Its syntax is very small, corresponding only to a very small subset of HTML tags. The idea is not to create a syntax that makes it easier to insert HTML tags. In my opinion, HTML tags are already easy to insert. The idea for Markdown is to make it easy to read, write, and edit prose. HTML is a publishing format; Markdown is a writing format. Thus, Markdown's formatting syntax only addresses issues that can be conveyed in plain text.

For any markup that is not covered by Markdown's syntax, you simply use HTML itself. ...



因此,如果您确实需要代码跨度中的某些文本为上标,则对整个跨度使用原始 HTML(确保根据需要手动转义):
<code>A code span with <sup>superscript</sup> text and escaped characters: "&lt;&amp;&gt;".</code>

呈现为:

A code span with superscript text and escaped characters: "<&>".

关于github - Github Markdown 代码块中的上标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38427565/

相关文章:

git - github 上的多个存储库

swift - 使用Github时如何隐藏APPKey

markdown - 如何在 Markdown 方程式中编写案例

markdown - 如何使用 Markdown 在表格单元格中嵌套代码块?

markdown - Reveal 中的多个 Markdown 文件选择

css - 在 Atom 中更改 Markdown 预览主题

github - Jekyll-bootstrap 如何为外部链接 Markdown ?

git - CircleCI过滤器 pull 请求

git - 在推送后恢复空的 merge 提交

syntax-highlighting - 预格式化 HTML 并将其显示在模板中