Rebol [ Title: "Make-Doc Text Dialect Parser" Author: ["Carl Sassenrath" "Christopher Ross-Gill"] Type: 'document ] some [ ;here: (print here) newline ;-- Headers / End of file | ["===" | "-1-"] line (emit sect1 text) | ["---" | "-2-"] line (emit sect2 text) | ["+++" | "-3-"] line (emit sect3 text) | ["..." | "-4-"] line (emit sect4 text) | "###" to end (emit end none) ;-- Special common notations: | "*" [ [">>" | "**"] line (emit bullet3 text) | [">" | "*"] line (emit bullet2 text) | line (either #"*" = last text [emit sect2 head remove back tail text][emit bullet text]) ] | "#" [ ">>" line (emit enum3 text) | ">" line (emit enum2 text) | line (emit enum text) ] | #":" define ( emit define-term text emit define-desc para ) | #"|" [ #"|" term (emit table-row none) | term (emit column none) ] ;-- Special sections: | #"\" [ "in" term (emit indent-in text) | "note" [line (emit note-in text) | term (emit note-in none)] | "define" line (emit define-in text) | "quote" block (emit quote-in values) | ["box" | "section" | "column"] block (emit box-in values) | "aside" term (emit boxout-in none) | "table" [line (emit table-in text) | term (emit table-in none)] | "group" term (emit group-in none) | "pullquote" term (emit pullquote-in none) | "list" block (emit list-in values) | "figure" term (emit figure-in none) | "sidebar" term (emit sidebar-in none) | "column" term (emit column-in none) | "center" term (emit center-in none) ] | #"/" [ "in" term (emit indent-out none) | "note" term (emit note-out none) | "define" term (emit define-out none) | "quote" [line (emit quote-out text) | term (emit quote-out none)] | ["box" | "section" | "column"] term (emit box-out none) | "aside" term (emit boxout-out none) | "table" term (emit table-out none) | "group" term (emit group-out none) | "pullquote" term (emit pullquote-out none) | "list" term (emit list-out none) | "figure" term (emit figure-out none) | "sidebar" term (emit sidebar-out none) | "center" term (emit center-out none) | "column" term (emit column-out none) ] ;-- Commands: | #"=" [ #"=" line (emit output ) | "caption" lines (emit caption para) | "row" term (emit table-row none) | "column" term (emit column none) | "image" block (emit image values) | "youtube" block (emit youtube values) | "vimeo" block (emit vimeo values) | "icon" block (emit icon values) | "url" block (emit url values) | "options" block (append options values) | ">" line (emit brief text) | ["item" | "next"] term (emit list-item none) | ["break" | "hr"] term (emit break none) | "template" block (emit template values) | "toc" term (append options 'toc) ] ;--Defaults: | ";" lines ; comment | some space term () | example (emit/verbatim code para) | line ( case [ parse/all text [copy para to " ||" 3 skip][emit para para emit table-row none] parse/all text [copy para to " |" 2 skip][emit para para emit column none] true [emit para text] ] ) | skip ]