Turtle Markdown Extensions
A bit of forward-planning for blog engine stuff. This went on my todo list the other day, since then I've had a think, thought I'd better get it down before I forget.
The implementation for makesite.py
should be straightforward, but I've other things to do. But I can start using these extensions in posts today, no matter that they won't do anything yet. When I've got a demo implementation and tried it out a bit I'll give it a repo on GitHub.
How to express RDF statements in Markdown?
Uses Cases
- make statements about the md doc
- extract a block of arbitrary Turtle from md doc
General Requirements
- simple to use, simple to implement
- independent of, but compatible with existing markdown tools
- extensible, reasonably modular
- block identifier & delimiters
- useful defaults, easily overriden
Note re. (2) : the markup syntax used will be interpreted as a processing instruction, so while Turtle creation/extraction is the immediate goal, it makes sense for extensibility to consider other possible uses.
0. General Syntax
` :term fur`
``` :term fur```
TODO express in BNF TODO provide regexes
1. Statements about Current Markdown Document
` :tag fur`
- the URL of the current document (or a derived version in a format like HTML) will be the subject of the triple
- the string
:tag
will be interpreted as the termtag
from the namespacehttp://purl.org/stuff/mx/
and used as the property of the triple - the string
fur
will be used as the literal object of the triple
TODO result
In this example fur
is one word, a simple string delimited by spaces. Alternatives will include quoting of literals "as in Turtle"
for the object as well as the use of URIs using standard Turtle syntax.
TODO longer example
Useful Terms
- mx:x - extract, as above
- mx:a - rdf:type
- mx:cat - category
- mx:tag
- mx:tags
TODO fill out as needed, find standard vocab equivalents
2. Arbitrary Turtle in Markdown Document
Where a block of Turtle should be extracted, the term mx:x
should be used, e.g.
```:x @base http://example.org/ . @prefix foaf: http://xmlns.com/foaf/0.1/ . @prefix rel: http://www.perceive.net/schemas/relationship/ .
<#green-goblin> rel:enemyOf <#spiderman> ; a foaf:Person ; # in the context of the Marvel universe foaf:name "Green Goblin" . ```
3. Interpretation Rules
TODO
for eg. mx:tags - provide a simple list syntax
Terms MAY be interpreted as those in the mx namespace and/or well-known equivalents
How to say what should be passed to standard markdown processor, what should be cut?
Implementation Notes
- Processing should occur before standard markdown processing.
- Processing will return a dictionary (or equiv).
eg. :
contents = mx(markdown_with_extensions)
markdown = contents['markdown']
turtle = contents['turtle']
html = to_html(markdown)
store.add(turtle)