diff --git a/lib/vast2.hoon b/lib/vast2.hoon index 7a646bc08..7dfdae245 100644 --- a/lib/vast2.hoon +++ b/lib/vast2.hoon @@ -170,6 +170,7 @@ $head :: # heading $bloc :: > block-quote $expr :: ;sail expression + $stet :: == to end markdown $text :: anything else == :: ++ graf :: paragraph element @@ -212,6 +213,7 @@ =| hac/(list item) =/ cur/item [%down ~] =| lub/(unit (pair hair wall)) + =| last-column/@ud :: for backtracking |_ {top/@ud naz/hair los/tape} :: ++ $ :: resolve @@ -299,7 +301,7 @@ $(los t.los, q.naz +(q.naz), nap [i.los nap]) :: :: consume newline - :_ +>(los t.los, naz [+(p.naz) 1]) + :_ +>(los t.los, naz [+(p.naz) 1], last-column q.naz) :: :: trim trailing spaces |- ^- tape @@ -307,21 +309,6 @@ $(nap t.nap) (flop nap) :: - ++ skip :: discard line - |- ^+ ..^$ - :: - :: no unterminated lines - ?~ los - ::~& %unterminated-line - ..^$(err `naz) - ?. =(`@`10 i.los) - :: - :: eat byte and repeat - $(los t.los) - :: - :: consume newline - ..^$(los t.los, naz [+(p.naz) 1]) - :: ++ look :: inspect line ^- (unit trig) (wonk (look:parse naz los)) @@ -385,15 +372,23 @@ ?~ pic :: :: break section - =~(skip close-item line) + =~(+:snap close-item line) :: :: line is not blank => .(pic u.pic) :: :: if end of input, complete - ?: |(?=($done sty.pic) (lth col.pic top)) + ?: ?=($done sty.pic) ..$(q.naz col.pic) :: + :: if == or dedent, complete and backtrack + ?: |(?=($stet sty.pic) (lth col.pic top)) + %_ ..$ + p.naz (dec p.naz) + q.naz last-column + los ['\0a' los] :: put newline back + == + :: :: bal: inspection copy of lub, current section =/ bal lub :: @@ -493,7 +488,7 @@ $8 (push %poem) :: verse literal $0 :: unindented forms ?- sty.pic - $done !! :: blank + ?($done $stet) !! :: end of markdown $rule (push %rule) :: horizontal ruler $head (push %head) :: heading $bloc (entr %bloc) :: blockquote line @@ -550,6 +545,7 @@ ;~ pose (full (easy %done)) :: end of input (cold ~ (just `@`10)) :: blank line + (cold %stet duz) :: == (ends markdown) (cold %rule ;~(plug hep hep hep)) :: --- horizontal ruler (cold %fens ;~(plug tec tec tec)) :: ``` code fence (cold %head ;~(plug (star hax) ace)) :: # heading