Markdown 中的语义标记
我想使用简单的文本编辑器和 Markdown 做课堂笔记。有没有办法标记文本元素以使它们机器可读?
例如,我想将某些单词和短语标记为“定义”。然后,我可以运行某种脚本来显示单词及其相应的定义。
I'd like to take class notes using a simple text editor and Markdown. Is there a way to tag elements of the text to make them machine readable?
For example, I'd like to tag certain words and phrases as "definitions". Then later, I could run some sort of script to display words and their corresponding definitions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我知道这已经过时了,但我刚刚开始接受 Markdown,发现自己在问同样的问题。我有一个 Markdown 文档,我在其中写开发笔记,主要是 C# 内容,还有 JavaScript 和其他主题。我想我想出了一个非常好的解决方案;只需将前缀为
#
的空链接添加到帖子的标题中,如下所示:这使我可以添加任意数量的标签,这在一篇帖子包含多个主题时非常有用。不用说,您可以在帖子本身中添加标签。也许对我们中的一些人来说最重要的是,它渲染得很好!。理想情况下,它们是不可见的,但显示它们也有一个优点。
希望这对某人有帮助。
I know this is old but I just started to embrace Markdown and found myself asking this same question. I have a markdown document where I write notes on development, mainly C# stuff but also JavaScript and other topics. I think I came up with a pretty good solution; Simply add empty links prefixed with
#
to the post's title like so:This allows me to add as many tags as I want, which is useful when a post contains more than one topic. Needless to say, you could add tags within the post itself. Perhaps most importantly to some of us, it renders nicely!. Ideally they would be invisible but there is also an advantage to displaying them.
Hope this helps someone.
定义没有特定的 Markdown 语法(更不用说标签了)。您可能可以使用块引用语法:
...或者您可以简单地强调您要定义的术语:
但是,markdown 中的 html 代码在语法上是正确的,因此您可以使用具有类属性的标签,如下所示:
在这种特殊情况下,有HTML5 标签涵盖定义:
There is no specific markdown syntax for definitions (let alone tag). You could probably use the blockquote syntax :
...or you could simply emphasize the term you are about to define :
However, html code inside markdown is syntactically correct so you could use tags with class attributes like this :
In that particular case, there are HTML5 tags covering definitions :
为什么不简单地用您选择的特定图案包围标签呢?如
:mytag:
或&mytag&
。Why not simply surround the tag with a specific pattern of your choosing? Like
:mytag:
or&mytag&
.如果您使用 Kramdwon 或 Maruku 要解析您的 Markdown 文件,您可以将类和 id 添加到内联元素,如下所示:
您可以尝试使用 Markdownr。
但我想更简单、更实用的方法是添加
并稍后使用脚本进行所需的更改。正如 Antoine Gersant 所提议的那样。
If you use Kramdwon or Maruku to parse your Markdown files you can add classes and ids to inline elements like this:
You can try it with Markdownr.
But I guess the simpler and more practical way is to just add
<em>
s and do the desired changes later on with a script. Just as proposed by Antoine Gersant.Quarto (Posit) markdown 与 pandoc 和 PHP markdown extra 相同,接受:
它分别转换为 dt 和 dd html 标签。
四开是一个非常酷的工具。看看:Quarto
Quarto (Posit) markdown, which is the same markdown as pandoc and PHP markdown extra, accepts:
It converts to dt and dd html tags respectively.
Quarto is a very cool tool. Take a look: Quarto
Markdown 支持转义特殊字符。
#foo
呈现为一级标题,而\#foo
则呈现为“#foo”。Markdown supports escaping special characters. While
#foo
is rendered as a first-level heading,\#foo
is rendered as "#foo".