@Emile Thank you for offer to support other syntax, here is my use case, feel free to improve the syntax if needed. I tried to come up with natural, flexible enough to describe any bill of material which will for example allow to transitively/recursively sum up quantities of materials needed for given catering plan.
Markdown nested list, similar to Yaml but using structured text in place of leaf string as a way to add properties in “natural language way” and include wiki or markdown links.
# food 1
some
- irrelevant text
- contains:
- 1 kg of [[food 2]]
- [[food 3]]
- approximately 3 pieces of [[food 4]]
- 1 piece of [[food 5]] # optionally 2 pieces
- previously also:
- 1 piece of [[food 6]]
- another irrelevant
- text
In a graph, I would like to get relations where
({ID: 'food 1'})-[:contains {quantity: 1, unit: kg}]->({ID: 'food 2'})
({ID: 'food 1'})-[:contains {quantity: "", unit: ""}]->({ID: 'food 3'})
({ID: 'food 1'})-[:contains {quantity: 3, unit: piece}]->({ID: 'food 4'})
({ID: 'food 1'})-[:contains {quantity: 1, unit: piece}]->({ID: 'food 5'})
Sorry if my formulation in Cypher is incorrect.
Processing:
- list of relations starts by non-indented line in form
- <linktype>:
- indented list item expected to be in form
- text <amount> <unit> <preposition> <[[linktosubject|text]]> # another text which might contain links
- treat filename of the file as a “subject” of relations
- ignore list items that do not contain link. (maybe treat dead links with missing target file as valid.)
- ignore comment after "# " till end of line (requiring comment separator means that this can be extension of your original proposed syntax with more links (objects) on one line separated by comma, when colon after link type is optional or signifies initiation of hyphenated multi-line list. )
- ignore optional prepositions before link, e.g. " of "
- ignore link text after pipe
- for start, ignore text before the decimal number or link
- store decimal number in property “quantity” of the edge/link/relation
- store string in property “unit” of the edge/link/relation
- allow specification of equivalent units like
piece, pieces, ks (although this could be treated by user later in graph database, but for real time interaction between markdown and graph, treating this automatically like aliases would be nice.)
- similarly aliases for link-types.
contains, obsahuje Could be specified as equivalent.
aliases would allow to adjust to any language.
Czech version:
# potravina 1
some
irrelevant text
- obsahuje:
- 1 kg [[potravina 2|potraviny 2]]
- [[potravina 3]]
- asi 2 ks [[potravina 4]]
- 1 ks [[potravina 5]] # mohou být i 2 kusy.
- dříve také:
- 1 ks [[potravina 6]]