@@ 1,29 @@
+(def default-separator "%%%")
+
+(defn peg
+ [separator]
+ (peg/compile ~(* (<- (to ,separator))
+ ,separator
+ (<- (any 1)))))
+
+(def default-peg (peg default-separator))
+
+(def- boot-parse parse)
+
+(defn parse
+ ```
+ Parse a Mago document into Janet frontmatter and arbitrary body text.
+
+ The text before the separator is treated as a single Janet term and
+ parsed. The text after the separator is left untouched.
+
+ Accepts an optional second argument to specify the separator string
+ to use. The default is `%%%`.
+ ```
+ [src &opt separator]
+ (default separator default-separator)
+ (let [peg (case separator
+ default-separator default-peg
+ (peg separator))
+ [front body] (peg/match peg src)]
+ {:front (boot-parse front) :body body}))