mirror of
https://github.com/urbit/shrub.git
synced 2025-01-06 04:07:23 +03:00
Fenced code blocks
This commit is contained in:
parent
31aba9606c
commit
1de4408df3
@ -165,6 +165,7 @@
|
|||||||
++ trig-style :: type of parsed line
|
++ trig-style :: type of parsed line
|
||||||
$? $done :: end of input
|
$? $done :: end of input
|
||||||
$rule :: --- horizontal ruler
|
$rule :: --- horizontal ruler
|
||||||
|
$fens :: ``` code fence
|
||||||
$lint :: + line item
|
$lint :: + line item
|
||||||
$lite :: - line item
|
$lite :: - line item
|
||||||
$head :: # heading
|
$head :: # heading
|
||||||
@ -227,7 +228,7 @@
|
|||||||
::
|
::
|
||||||
:: all data was consumed
|
:: all data was consumed
|
||||||
=- [naz `[- [naz los]]]
|
=- [naz `[- [naz los]]]
|
||||||
=> made
|
=> close-item
|
||||||
|- ^- flow
|
|- ^- flow
|
||||||
::
|
::
|
||||||
:: fold all the way to top
|
:: fold all the way to top
|
||||||
@ -245,7 +246,7 @@
|
|||||||
$lime 2
|
$lime 2
|
||||||
$lord 0
|
$lord 0
|
||||||
$poem 8
|
$poem 8
|
||||||
$code 4
|
$code 0
|
||||||
$bloc 2
|
$bloc 2
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
@ -324,25 +325,25 @@
|
|||||||
(flop nap)
|
(flop nap)
|
||||||
::
|
::
|
||||||
++ skip :: discard line
|
++ skip :: discard line
|
||||||
|- ^+ +
|
|- ^+ ..^$
|
||||||
::
|
::
|
||||||
:: no unterminated lines
|
:: no unterminated lines
|
||||||
?~ los
|
?~ los
|
||||||
::~& %unterminated-line
|
::~& %unterminated-line
|
||||||
+(err `naz)
|
..^$(err `naz)
|
||||||
?. =(`@`10 i.los)
|
?. =(`@`10 i.los)
|
||||||
::
|
::
|
||||||
:: eat byte and repeat
|
:: eat byte and repeat
|
||||||
$(los t.los)
|
$(los t.los)
|
||||||
::
|
::
|
||||||
:: consume newline
|
:: consume newline
|
||||||
+(los t.los, naz [+(p.naz) 1])
|
..^$(los t.los, naz [+(p.naz) 1])
|
||||||
::
|
::
|
||||||
++ look :: inspect line
|
++ look :: inspect line
|
||||||
^- (unit trig)
|
^- (unit trig)
|
||||||
(wonk (look:parse naz los))
|
(wonk (look:parse naz los))
|
||||||
::
|
::
|
||||||
++ made :: compose block
|
++ close-item :: compose block
|
||||||
^+ .
|
^+ .
|
||||||
::
|
::
|
||||||
:: empty block, no action
|
:: empty block, no action
|
||||||
@ -350,7 +351,7 @@
|
|||||||
::
|
::
|
||||||
:: if block is preformatted code
|
:: if block is preformatted code
|
||||||
?: ?=($code p.cur)
|
?: ?=($code p.cur)
|
||||||
=- fold(lub ~, q.cur (weld - q.cur), col (sub col 4))
|
=- fold(lub ~, q.cur (weld - q.cur))
|
||||||
%+ turn q.u.lub
|
%+ turn q.u.lub
|
||||||
|= tape ^- mars
|
|= tape ^- mars
|
||||||
::
|
::
|
||||||
@ -410,7 +411,7 @@
|
|||||||
?~ pic
|
?~ pic
|
||||||
::
|
::
|
||||||
:: break section
|
:: break section
|
||||||
line:made:skip
|
=~(skip close-item line)
|
||||||
::
|
::
|
||||||
:: line is not blank
|
:: line is not blank
|
||||||
=> .(pic u.pic)
|
=> .(pic u.pic)
|
||||||
@ -423,13 +424,17 @@
|
|||||||
=/ bal lub
|
=/ bal lub
|
||||||
::
|
::
|
||||||
:: if within section
|
:: if within section
|
||||||
?~ bal (new-container pic)
|
?~ bal (open-item pic)
|
||||||
::
|
::
|
||||||
:: detect unspaced new containers
|
:: detect unspaced new containers
|
||||||
?: ?& ?=(?($down $lime $bloc) p.cur)
|
?: ?& ?=(?($down $lime $bloc) p.cur)
|
||||||
|(!=(%text sty.pic) (gth col.pic col))
|
|(!=(%text sty.pic) (gth col.pic col))
|
||||||
==
|
==
|
||||||
(new-container:made pic)
|
%- =>(close-item open-item) pic
|
||||||
|
::
|
||||||
|
:: if we see a fence at the end of a code block, complete the block
|
||||||
|
?: &(?=($fens sty.pic) ?=($code p.cur))
|
||||||
|
=~(skip close-item line)
|
||||||
::
|
::
|
||||||
:: first line of container is legal
|
:: first line of container is legal
|
||||||
?~ q.u.bal
|
?~ q.u.bal
|
||||||
@ -470,7 +475,7 @@
|
|||||||
q.cur (weld (flop `marl:twig`res) q.cur) :: prepend to the stack
|
q.cur (weld (flop `marl:twig`res) q.cur) :: prepend to the stack
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ new-container :: enter list/quote
|
++ open-item :: enter list/quote
|
||||||
|= pic/trig
|
|= pic/trig
|
||||||
::
|
::
|
||||||
:: if column has retreated, adjust stack
|
:: if column has retreated, adjust stack
|
||||||
@ -494,26 +499,29 @@
|
|||||||
:: nap: take first line
|
:: nap: take first line
|
||||||
..$(lub `[naz ~])
|
..$(lub `[naz ~])
|
||||||
::
|
::
|
||||||
++ apex ^+ . :: by column offset
|
++ apex ^+ . :: by column offset
|
||||||
?+ dif fail ::
|
?+ dif fail ::
|
||||||
$0 apse :: unindented forms
|
$8 (push %poem) :: verse literal
|
||||||
$4 (push %code) :: code literal
|
$0 :: unindented forms
|
||||||
$8 (push %poem) :: verse literal
|
?- sty.pic
|
||||||
==
|
$done !! :: blank
|
||||||
::
|
$rule (take %rule) :: horizontal ruler
|
||||||
++ apse ^+ . :: by prefix style
|
$fens (take %code) :: code bloc
|
||||||
?- sty.pic
|
$head (push %head) :: heading
|
||||||
$done !! :: blank
|
$bloc (entr %bloc) :: blockquote line
|
||||||
$rule (push %rule) :: horizontal ruler
|
$lite (lent %list) :: unnumbered list
|
||||||
$head (push %head) :: heading
|
$lint (lent %lord) :: numbered list
|
||||||
$bloc (entr %bloc) :: blockquote line
|
$text text :: anything else
|
||||||
$lite (lent %list) :: unnumbered list
|
==
|
||||||
$lint (lent %lord) :: numbered list
|
|
||||||
$text text :: anything else
|
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ fail .(err `erp) :: set error position
|
++ fail .(err `erp) :: set error position
|
||||||
++ push |=(mite +>(hac [cur hac], cur [+< ~])):: push context
|
++ push |=(mite +>(hac [cur hac], cur [+< ~])):: push context
|
||||||
|
++ take
|
||||||
|
|= a/mite
|
||||||
|
^+ +>
|
||||||
|
=. ..skip skip
|
||||||
|
(push a)
|
||||||
++ entr :: enter container
|
++ entr :: enter container
|
||||||
|= typ/mite
|
|= typ/mite
|
||||||
^+ +>
|
^+ +>
|
||||||
@ -560,6 +568,7 @@
|
|||||||
(full (easy %done)) :: end of input
|
(full (easy %done)) :: end of input
|
||||||
(cold ~ (just `@`10)) :: blank line
|
(cold ~ (just `@`10)) :: blank line
|
||||||
(cold %rule ;~(plug hep hep hep)) :: --- horizontal ruler
|
(cold %rule ;~(plug hep hep hep)) :: --- horizontal ruler
|
||||||
|
(cold %fens ;~(plug tec tec tec)) :: ``` code fence
|
||||||
(cold %head ;~(plug (star hax) ace)) :: # heading
|
(cold %head ;~(plug (star hax) ace)) :: # heading
|
||||||
(cold %lite ;~(plug hep ace)) :: - line item
|
(cold %lite ;~(plug hep ace)) :: - line item
|
||||||
(cold %lint ;~(plug lus ace)) :: + line item
|
(cold %lint ;~(plug lus ace)) :: + line item
|
||||||
|
Loading…
Reference in New Issue
Block a user