mirror of
https://github.com/urbit/shrub.git
synced 2024-12-14 01:08:54 +03:00
improved markdown, now with html printer
This commit is contained in:
parent
9951d710bd
commit
e5bc25e3a1
@ -5,11 +5,13 @@
|
|||||||
+
|
+
|
||||||
=> +
|
=> +
|
||||||
|%
|
|%
|
||||||
|
:::: markdown parser
|
||||||
|
::
|
||||||
++ down (list bloc) :: markdown model
|
++ down (list bloc) :: markdown model
|
||||||
++ bloc :: block elements
|
++ bloc :: block elements
|
||||||
$% [%head p=@ud q=(list span) r=(unit tape)]
|
$% [%head p=@ud q=(list span) r=(unit tape)]
|
||||||
[%para p=(list span)]
|
[%para p=(list span)]
|
||||||
[%lise q=down]
|
[%lise p=down]
|
||||||
[%list p=? q=down]
|
[%list p=? q=down]
|
||||||
[%quot p=down]
|
[%quot p=down]
|
||||||
[%horz ~]
|
[%horz ~]
|
||||||
@ -30,17 +32,18 @@
|
|||||||
|= tub=nail
|
|= tub=nail
|
||||||
^- (like down)
|
^- (like down)
|
||||||
=+ sep=(sepa tub)
|
=+ sep=(sepa tub)
|
||||||
?~ q.sep
|
?~ q.sep [p.sep ~]
|
||||||
[p.sep ~]
|
|
||||||
[p.sep (some [(turn p.u.q.sep |=(a=tape (scan a blos))) [p.sep ~]])]
|
[p.sep (some [(turn p.u.q.sep |=(a=tape (scan a blos))) [p.sep ~]])]
|
||||||
::
|
::
|
||||||
|
++ base (stag %para ;~(plug (stag %text (plus ;~(pose prn eol))) (easy ~)))
|
||||||
++ blos :: block element
|
++ blos :: block element
|
||||||
(knee *bloc |.(~+(;~(pose head quot lasd horz code codf html para))))
|
(knee *bloc |.(~+(;~(pose head quot lasd horz code codf html para base))))
|
||||||
::
|
::
|
||||||
++ brek (stag %brek (cold ~ ;~(plug fas fas))) :: line break
|
++ brek (stag %brek (cold ~ ;~(plug fas fas))) :: line break
|
||||||
++ chrd ;~(pose escp prn (cold ' ' eol)) :: span character data
|
++ chrd ;~(pose escp prn (cold ' ' eol)) :: span character data
|
||||||
++ code :: code block
|
++ code :: code block
|
||||||
%+ stag %code
|
%+ stag %code
|
||||||
|
%- full
|
||||||
%- plus
|
%- plus
|
||||||
;~ pfix (stun [4 4] ace)
|
;~ pfix (stun [4 4] ace)
|
||||||
;~(pose (cook welp ;~(plug (plus prn) (cold "\0a" eol))) (full (plus prn)))
|
;~(pose (cook welp ;~(plug (plus prn) (cold "\0a" eol))) (full (plus prn)))
|
||||||
@ -48,6 +51,7 @@
|
|||||||
::
|
::
|
||||||
++ codf :: fenced code block
|
++ codf :: fenced code block
|
||||||
%+ stag %code
|
%+ stag %code
|
||||||
|
%- full
|
||||||
%+ ifix [;~(plug tec tec tec eol) ;~(plug tec tec tec)]
|
%+ ifix [;~(plug tec tec tec eol) ;~(plug tec tec tec)]
|
||||||
%- plus
|
%- plus
|
||||||
;~ pose
|
;~ pose
|
||||||
@ -56,7 +60,7 @@
|
|||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ cods :: code span
|
++ cods :: code span
|
||||||
%+ stag %text
|
%+ stag %cods
|
||||||
=+ chx=;~(pose (cold ' ' eol) prn)
|
=+ chx=;~(pose (cold ' ' eol) prn)
|
||||||
;~ pose
|
;~ pose
|
||||||
%+ ifix [(jest '```') (jest '```')] (plus ;~(less (jest '```') chx))
|
%+ ifix [(jest '```') (jest '```')] (plus ;~(less (jest '```') chx))
|
||||||
@ -119,20 +123,22 @@
|
|||||||
==
|
==
|
||||||
;~(plug (spas eol) (easy ~))
|
;~(plug (spas eol) (easy ~))
|
||||||
==
|
==
|
||||||
;~ pose
|
%- full
|
||||||
;~ pfix (jest '######') (stag 6 hed) ==
|
;~ pose
|
||||||
;~ pfix (jest '#####') (stag 5 hed) ==
|
;~ pfix (jest '######') (stag 6 hed) ==
|
||||||
;~ pfix (jest '####') (stag 4 hed) ==
|
;~ pfix (jest '#####') (stag 5 hed) ==
|
||||||
;~ pfix (jest '###') (stag 3 hed) ==
|
;~ pfix (jest '####') (stag 4 hed) ==
|
||||||
;~ pfix (jest '##') (stag 2 hed) ==
|
;~ pfix (jest '###') (stag 3 hed) ==
|
||||||
;~ pfix (jest '#') (stag 1 hed) ==
|
;~ pfix (jest '##') (stag 2 hed) ==
|
||||||
(stag 1 (ifix [wits ;~(plug eol (plus tis))] sed))
|
;~ pfix (jest '#') (stag 1 hed) ==
|
||||||
(stag 2 (ifix [wits ;~(plug eol (plus hep))] sed))
|
(stag 1 (ifix [wits ;~(plug eol (plus tis))] sed))
|
||||||
==
|
(stag 2 (ifix [wits ;~(plug eol (plus hep))] sed))
|
||||||
|
==
|
||||||
::
|
::
|
||||||
++ horz :: horizontal rule
|
++ horz :: horizontal rule
|
||||||
%+ stag %horz
|
%+ stag %horz
|
||||||
%+ cold ~
|
%+ cold ~
|
||||||
|
%- full
|
||||||
;~ pose
|
;~ pose
|
||||||
;~(plug (stun [0 3] ace) hep wits hep wits hep (star ;~(pose hep wite)))
|
;~(plug (stun [0 3] ace) hep wits hep wits hep (star ;~(pose hep wite)))
|
||||||
;~(plug (stun [0 3] ace) tar wits tar wits tar (star ;~(pose tar wite)))
|
;~(plug (stun [0 3] ace) tar wits tar wits tar (star ;~(pose tar wite)))
|
||||||
@ -142,12 +148,13 @@
|
|||||||
++ html (stag %html apex:xmlp) :: html bloc
|
++ html (stag %html apex:xmlp) :: html bloc
|
||||||
++ lasd :: top level list
|
++ lasd :: top level list
|
||||||
%+ stag %list
|
%+ stag %list
|
||||||
;~ pose
|
%- full
|
||||||
(stag & (lisd ;~(plug (star nud) dot)))
|
;~ pose
|
||||||
(stag | (lisd hep))
|
(stag & (lisd ;~(plug (star nud) dot)))
|
||||||
(stag | (lisd tar))
|
(stag | (lisd hep))
|
||||||
(stag | (lisd lus))
|
(stag | (lisd tar))
|
||||||
==
|
(stag | (lisd lus))
|
||||||
|
==
|
||||||
::
|
::
|
||||||
++ lisd :: list funk
|
++ lisd :: list funk
|
||||||
|* bus=_rule
|
|* bus=_rule
|
||||||
@ -191,9 +198,10 @@
|
|||||||
==
|
==
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ para (stag %para (spas fail)) :: paragraph
|
++ para (stag %para (full (spas fail))) :: paragraph
|
||||||
++ quot :: blockquotes
|
++ quot :: blockquotes
|
||||||
%+ stag %quot
|
%+ stag %quot
|
||||||
|
%- full
|
||||||
|= tub=nail
|
|= tub=nail
|
||||||
^- (like down)
|
^- (like down)
|
||||||
=- ?~ q.pre
|
=- ?~ q.pre
|
||||||
@ -216,7 +224,7 @@
|
|||||||
(sepl (cold "*" tar))
|
(sepl (cold "*" tar))
|
||||||
(sepl (cold "+" lus))
|
(sepl (cold "+" lus))
|
||||||
(sepl (cook welp ;~(plug (star nud) (cold "." dot))))
|
(sepl (cook welp ;~(plug (star nud) (cold "." dot))))
|
||||||
(plus ;~(less lin ;~(pose prn eol)))
|
(plus ;~(less lin ;~(pose prn ;~(simu ;~(plug eol prn) eol))))
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ sepl :: separate list
|
++ sepl :: separate list
|
||||||
@ -249,46 +257,55 @@
|
|||||||
++ wite (mask ~[`@`0x20 `@`0x9]) :: whitespace
|
++ wite (mask ~[`@`0x20 `@`0x9]) :: whitespace
|
||||||
++ wits (star wite)
|
++ wits (star wite)
|
||||||
::
|
::
|
||||||
++ samp
|
:::::: down to manx
|
||||||
"""
|
|
||||||
- 1asdfasf
|
|
||||||
asdfafd
|
|
||||||
asdfasf
|
|
||||||
|
|
||||||
2asdasfd
|
++ dank
|
||||||
|
|%
|
||||||
|
++ apex
|
||||||
|
|= don=down
|
||||||
|
^- marl
|
||||||
|
(turn don |=(bol=bloc (blok bol)))
|
||||||
|
++ blok
|
||||||
|
|= bol=bloc
|
||||||
|
^- manx
|
||||||
|
?- bol
|
||||||
|
[%head *]
|
||||||
|
:_ (turn q.bol sank)
|
||||||
|
[(cat 3 'h' (scot %ud p.bol)) ?~(r.bol ~ [[%id u.r.bol] ~])]
|
||||||
|
[%para *] [[%p ~] (turn p.bol sank)]
|
||||||
|
[%horz *] [[%hr ~] ~]
|
||||||
|
[%code *] [[%pre ~] ~[[[%$ [[%$ (zing p.bol)] ~]] ~]]]
|
||||||
|
[%quot *] [[%blockquote ~] (apex p.bol)]
|
||||||
|
[%lise *] [[%li ~] (apex p.bol)]
|
||||||
|
[%list *] ?: =(& p.bol) [[%ol ~] (apex q.bol)]
|
||||||
|
[[%ul ~] (apex q.bol)]
|
||||||
|
[%html *] p.bol
|
||||||
|
==
|
||||||
|
|
||||||
- 3asfasf
|
++ sank
|
||||||
asdfas
|
|= san=span
|
||||||
|
^- manx
|
||||||
|
?- san
|
||||||
|
[%text *] [[%$ [[%$ p.san] ~]] ~]
|
||||||
|
[%brek *] [[%br ~] ~]
|
||||||
|
[%stri *] [[%del ~] (turn p.san ..$)]
|
||||||
|
[%cods *] [[%code ~] ~[[[%$ [[%$ p.san] ~]] ~]]]
|
||||||
|
[%emph *]
|
||||||
|
?: =(%ital p.san) [[%em ~] (turn q.san ..$)]
|
||||||
|
?: =(%bold p.san) [[%strong ~] (turn q.san ..$)]
|
||||||
|
[[%em ~] ~[[[%strong ~] (turn q.san ..$)]]]
|
||||||
|
[%link *]
|
||||||
|
?~ r.san [[%a ~[[%href q.san]]] (turn p.san ..$)]
|
||||||
|
[[%a ~[[%href q.san] [%title u.r.san]]] (turn p.san ..$)]
|
||||||
|
==
|
||||||
|
--
|
||||||
|
|
||||||
4asdfasf
|
|
||||||
|
|
||||||
- 5asfasf
|
|
||||||
asdfas
|
|
||||||
|
|
||||||
6asdfas
|
|
||||||
|
|
||||||
- 7asfasf
|
|
||||||
asdfas
|
|
||||||
|
|
||||||
8asfass
|
|
||||||
|
|
||||||
9asdfas
|
|
||||||
|
|
||||||
10asdfasf
|
|
||||||
|
|
||||||
11asfasfaf
|
|
||||||
|
|
||||||
- 13asdasdf
|
|
||||||
adfadaf
|
|
||||||
"""
|
|
||||||
::
|
::
|
||||||
++ samp2
|
++ samp
|
||||||
"""
|
"""
|
||||||
An h1 header
|
An h1 header
|
||||||
============
|
============
|
||||||
|
|
||||||
#An h1 header
|
|
||||||
|
|
||||||
Paragraphs are separated by a blank line.
|
Paragraphs are separated by a blank line.
|
||||||
|
|
||||||
2nd paragraph. *Italic*, **bold**, ***both*** and `monospace`.
|
2nd paragraph. *Italic*, **bold**, ***both*** and `monospace`.
|
||||||
@ -309,44 +326,11 @@ Itemized lists
|
|||||||
look like:
|
look like:
|
||||||
|
|
||||||
* this one
|
* this one
|
||||||
|
|
||||||
* that one
|
* that one
|
||||||
|
|
||||||
* the other one
|
* the other one
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
Indented code block:
|
|
||||||
|
|
||||||
++ sepa :: separate blocs
|
|
||||||
%+ knee *wall |. ~+
|
|
||||||
=+ lin=;~(plug eol wits eol)
|
|
||||||
%+ ifix [(star whit) (star whit)]
|
|
||||||
%+ more ;~(plug eol wits (more wits eol))
|
|
||||||
;~ pose
|
|
||||||
(sepl (cold "-" hep))
|
|
||||||
(sepl (cold "*" tar))
|
|
||||||
(sepl (cold "+" lus))
|
|
||||||
(sepl (cook welp ;~(plug (star nud) (cold "." dot))))
|
|
||||||
(plus ;~(less lin ;~(pose prn eol)))
|
|
||||||
==
|
|
||||||
|
|
||||||
Fenced code block
|
|
||||||
|
|
||||||
```
|
|
||||||
++ sepa :: separate blocs
|
|
||||||
%+ knee *wall |. ~+
|
|
||||||
=+ lin=;~(plug eol wits eol)
|
|
||||||
%+ ifix [(star whit) (star whit)]
|
|
||||||
%+ more ;~(plug eol wits (more wits eol))
|
|
||||||
;~ pose
|
|
||||||
(sepl (cold "-" hep))
|
|
||||||
(sepl (cold "*" tar))
|
|
||||||
(sepl (cold "+" lus))
|
|
||||||
(sepl (cook welp ;~(plug (star nud) (cold "." dot))))
|
|
||||||
(plus ;~(less lin ;~(pose prn eol)))
|
|
||||||
==
|
|
||||||
```
|
|
||||||
"""
|
"""
|
||||||
--
|
--
|
||||||
==
|
==
|
||||||
@ -356,4 +340,5 @@ Fenced code block
|
|||||||
:_ ~ :_ ~
|
:_ ~ :_ ~
|
||||||
:- %$
|
:- %$
|
||||||
!>
|
!>
|
||||||
`down`(scan samp2 apex)
|
(xmll | (apex:dank (scan samp apex)) ~)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user