fox
fox

Reputation: 16546

Adding metadata to markdown text

I'm working on software creating annotations and would like my main data structure to be based around markdown.

I was thinking of working with an existing markdown editor, but hacking it so that certain tags, i.e. [annotation-id-001]Sample text.[/annotation-id-001] did not show up as rendered HTML; the above would output Sample text. in an HTML preview and link to a separate annotation with the ID 001.

My question is, is this the most efficient way to represent this kind of metadata inside of a markdown document? Also, if a user wants to legitimately use something like "[annotation-id-001]" as text inside of their document, I assume that I would have to make that string syntax illegal, correct?

Upvotes: 1

Views: 1666

Answers (1)

picas
picas

Reputation: 358

I don't know what Markdown parser you use but you can abord your problem with different points of view:

  • first you can "hack" an existing parser to exclude your annotation tags from "classic" parsing and include them only in a certain mode
  • you can also use the internal "meta-data" information proposed by certain parsers (like MultiMarkdown or MarkdownExtended) and only write your annotations like meta-data with a reference to their final place in content
  • or, as mentionned by mb21, you can use simple links notation like [Sample text.](#annotation-id-001) or use footnotes like [Sample text.](^annotation-id-001) and put your annotations as footnotes.

Upvotes: 2

Related Questions