file = section? (heading section?)* section = seclines heading = stars keyword? priority? title? hltags? NL secline = !&stars text NL seclines = secline seclines* stars = ~'\*+' keyword = ' '? ('TODO' / 'Done') priority = ' '? '[' ('#' letter) ']' title = (notagtext &hltags) / text hltag = ~"[\w@#%]*" hltags = ':' (hltag ':')* text = ~"[^\n\r]*" notagtext = ~"[^\n\r:]*" letter = ~"[a-zA-Z]" NL = '\n\r' / '\n' empty_line = NL NL affl_keywd = (affl_keywd1 / affl_keywd2) NL affl_keywd1 = '#+' key ':' value affl_keywd2 = '#+' optkey '[' option ']' ':' value affl_bkend = '#+' 'ATTR_' backend ':' value key = 'CAPTION' / 'HEADER' / 'NAME' / 'PLOT' / 'RESULTS' / 'AUTHOR' / 'DATE' / 'TITLE' optkey = 'CAPTION' / 'HEADER' option = ~"[^\[\]\n\r]+" value = text backend = name gblock = bheader bbody bend NL bheader = bstart (' ' bparams)? NL bbody = blines bstart = '#+BEGIN_' name bend = '#+END_' name bparams = text bline = !&'#+END_' text NL blines = bline blines* drawer = dheader dbody dend NL dheader = ':' name ':' NL dend = ':END:' dbody = dlines dline = !&':END:' text NL dlines = dline dlines* dblock = dbheader dbbody dbend NL dbheader = '#+BEGIN:' ' ' name (' ' dbparams)? NL dbbody = dblines dbend = '#+END' dbparams = text dbline = !&'#+END' text NL dblines = dbline dblines* footnote = '[fn:' fnlabel ']' fncontents fncontents = (!&(stars / '[fn:') text !&empty_line NL )* NL? fnlabel = name name = ~"[\w-]+" li = indent bullet counterset? checkbox? litag? NL indent = ~"[ ]*" bullet = '*' / '-' / '+' / counter counterset = '[@' counter ']' checkbox = '[' ~"[ -X]" ']' litag = text counter = (letter / ~"[1-9][0-9]*") ('.' / ')') pdrawer = ':PROPERTIES:' pdbody dend NL pdbody = nodeprops? nodeprop = ':' nodepname '+'? ':' value NL nodeprops = nodeprop nodeprops* nodepname = ~"[^\n\r\t :]+[^\n\r\t :+]$"