user94154
user94154

Reputation: 16574

Semantic tagging in 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.

Upvotes: 18

Views: 18311

Answers (6)

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

Upvotes: 1

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

Upvotes: 1

Yosef Bernal
Yosef Bernal

Reputation: 1064

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.

Upvotes: 10

Michael Wilding
Michael Wilding

Reputation: 31

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

Upvotes: 3

Jonas
Jonas

Reputation: 956

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.

Upvotes: 2

Antoine Gersant
Antoine Gersant

Reputation: 536

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> 

Upvotes: 4

Related Questions