Markdown 中的语义标记

发布于 2024-12-25 18:20:59 字数 111 浏览 2 评论 0原文

我想使用简单的文本编辑器和 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

夏有森光若流苏 2025-01-01 18:20:59

我知道这已经过时了,但我刚刚开始接受 Markdown,发现自己在问同样的问题。我有一个 Markdown 文档,我在其中写开发笔记,主要是 C# 内容,还有 JavaScript 和其他主题。我想我想出了一个非常好的解决方案;只需将前缀为 # 的空链接添加到帖子的标题中,如下所示:

### My post title [#mytag]()

这使我可以添加任意数量的标签,这在一篇帖子包含多个主题时非常有用。不用说,您可以在帖子本身中添加标签。也许对我们中的一些人来说最重要的是,它渲染得很好!。理想情况下,它们是不可见的,但显示它们也有一个优点。

希望这对某人有帮助。

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:

### My post title [#mytag]()

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.

爱格式化 2025-01-01 18:20:59

定义没有特定的 Markdown 语法(更不用说标签了)。您可能可以使用块引用语法:

> blablabla

...或者您可以简单地强调您要定义的术语:

**word** : a word is a blablabla

但是,markdown 中的 html 代码在语法上是正确的,因此您可以使用具有类属性的标签,如下所示:

<div class="definition important">blablabla</div>

在这种特殊情况下,有HTML5 标签涵盖定义:

<dl>
  <dt>Coffee</dt>
    <dd>Black hot drink</dd>
  <dt>Milk</dt>
    <dd>White cold drink</dd>
</dl> 

There is no specific markdown syntax for definitions (let alone tag). You could probably use the blockquote syntax :

> blablabla

...or you could simply emphasize the term you are about to define :

**word** : a word is a blablabla

However, html code inside markdown is syntactically correct so you could use tags with class attributes like this :

<div class="definition important">blablabla</div>

In that particular case, there are HTML5 tags covering definitions :

<dl>
  <dt>Coffee</dt>
    <dd>Black hot drink</dd>
  <dt>Milk</dt>
    <dd>White cold drink</dd>
</dl> 
只怪假的太真实 2025-01-01 18:20:59

为什么不简单地用您选择的特定图案包围标签呢?如 :mytag:&mytag&

Why not simply surround the tag with a specific pattern of your choosing? Like :mytag: or &mytag&.

回忆追雨的时光 2025-01-01 18:20:59

如果您使用 KramdwonMaruku 要解析您的 Markdown 文件,您可以将类和 id 添加到内联元素,如下所示:

This *word*{:.def} has to be defined. 
→ This <em class="def">word</em> has to be defined.

您可以尝试使用 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:

This *word*{:.def} has to be defined. 
→ This <em class="def">word</em> has to be defined.

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.

携君以终年 2025-01-01 18:20:59

Quarto (Posit) markdown 与 pandoc 和 PHP markdown extra 相同,接受:

term
: definition

它分别转换为 dt 和 dd html 标签。

四开是一个非常酷的工具。看看:Quarto

Quarto (Posit) markdown, which is the same markdown as pandoc and PHP markdown extra, accepts:

term
: definition

It converts to dt and dd html tags respectively.

Quarto is a very cool tool. Take a look: Quarto

北风几吹夏 2025-01-01 18:20:59

Markdown 支持转义特殊字符。 #foo 呈现为一级标题,而 \#foo 则呈现为“#foo”。

Markdown supports escaping special characters. While #foo is rendered as a first-level heading, \#foo is rendered as "#foo".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文