Semantic tagging in Markdown

后端 未结 4 530
栀梦
栀梦 2021-02-04 13:27

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

相关标签:
4条回答
  • 2021-02-04 13:33

    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.

    0 讨论(0)
  • 2021-02-04 13:35

    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> 
    
    0 讨论(0)
  • 2021-02-04 13:35

    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.

    0 讨论(0)
  • 2021-02-04 13:54

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

    0 讨论(0)
提交回复
热议问题