Here's a draft syntax for the datawiki I'm working on, with a data model where each page is a multimap, that maps keys to lists of values.
The goal is to stay close to how one usually takes notes, while allowing the expression of arbitrary metadata associated with each page.
Basics
Pages come in three forms:
1) Only body block
Remember to call Bob!
If a page has only one block, it is automatically the body of the page. So this equals:
body: Remember to call Bob!
2) One title and N body blocks (no key-value pairs)
TODO
Get EC2 working.
Try Hunchentoot SSL support.
If a page has more than one block, but no key-value pairs, the first block is the title, the others are the body of the page. So this equals:
title: TODO
body: Get EC2 working.
Try Hunchentoot SSL support.
3) Page with key-value pairs
Time Out of Mind
by: Bob Dylan
rating: *****
Must be one of his best records of late.
If a page has key-value pairs, everything before them is the title, everything after them is the body of the page. So this equals:
title: Time Out of Mind
by: Bob Dylan
rating: *****
body: Must be one of his best records of late.
Key-value pairs
Rules for parsing them:
A) Values may span multiple lines, except for the last value
We want to allow values that span multiple lines, including empty ones, like so:
value: bla bla bla
bla bla bla
value 2: even more bla
...
This conflicts a bit with the rule that everything after the key-value pairs is the body, so the last value of the page can have no empty lines:
...
last value: bla bla bla
even more bla
equals:
...
last value: bla bla bla
body: even more bla
B) Keys can contain any character except the ':'
The following are valid keys:
author of
message-id
C) Spaces at the start of the line disable key-value parsing
In order to be able to write a value that contains a ':', key-value parsing is disabled if the line starts with one or more spaces.
For example, this defines a single key-value pair, and not two key-value pairs:
story: bla bla
He said: bla bla
D) Commas split a value into a list (sometimes)
If a value contains commas, and the comma-separated parts are rather short, and the value does not end with sentence-end punctuation, it is parsed as a list.
tags: lisp, semweb, semistructured
equals:
tags: lisp
tags: semweb
tags: semistructured
But this does not parse as a list:
description: A nice house, even if somewhat old.
Recent Comments