Skip to content
This repository has been archived by the owner on Jun 9, 2018. It is now read-only.

Commit

Permalink
allow HtmlComment as HmtlBlock
Browse files Browse the repository at this point in the history
test "Inline HTML comments.text" pass
  • Loading branch information
fperrad committed Mar 30, 2009
1 parent 1432d7a commit 10c470f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
19 changes: 19 additions & 0 deletions src/Compiler.pir
Expand Up @@ -77,6 +77,21 @@ Markdown::HTML::Compiler implements a compiler for MAST nodes.
.return (str)
.end

.sub 'detabn' :anon
.param string str
$P0 = split "\n", str
$P1 = new 'ResizableStringArray'
L1:
unless $P0 goto L2
$S0 = shift $P0
$S0 = detab($S0)
push $P1, $S0
goto L1
L2:
str = join "\n", $P1
.return (str)
.end

.sub 'obscure_text' :anon
.param string str
$S0 = ''
Expand Down Expand Up @@ -506,6 +521,10 @@ Return generated HTML for all of its children.
.sub 'html' :method :multi(_, ['Markdown'; 'Entity'])
.param pmc node
$S0 = node.'text'()
$I0 = node.'detab'()
unless $I0 goto L1
$S0 = detabn($S0)
L1:
.local pmc code
new code, 'CodeString'
set code, $S0
Expand Down
3 changes: 0 additions & 3 deletions src/Node.pir
Expand Up @@ -47,9 +47,6 @@ for Markdown.
.tailcall self.'attr'('text', value, has_value)
.end
.namespace ['Markdown'; 'Line']
.sub 'detab' :method
.param pmc value :optional
.param int has_value :opt_flag
Expand Down
7 changes: 6 additions & 1 deletion src/parser/actions.pm
Expand Up @@ -255,6 +255,10 @@ method OrderedListItem($/) {
make $( $<ListItem> );
}

method HtmlBlock($/, $key) {
make $( $/{$key} );
}

method Emph($/, $key) {
make $( $/{$key} );
}
Expand Down Expand Up @@ -365,7 +369,8 @@ method RawHtml($/, $key) {
}

method HtmlComment($/) {
make Markdown::Entity.new( :text( $/.text() ) );
make Markdown::Entity.new( :text( $/.text() ),
:detab( 1 ) );
}

method HtmlTag($/) {
Expand Down
5 changes: 5 additions & 0 deletions src/parser/grammar.pg
Expand Up @@ -25,6 +25,7 @@ token Block {
| <Heading> {*} #= Heading
| <OrderedList> {*} #= OrderedList
| <BulletList> {*} #= BulletList
| <HtmlBlock> {*} #= HtmlBlock
| <Para> {*} #= Para
]
}
Expand Down Expand Up @@ -197,6 +198,10 @@ token _ListItem {
<.Indent>? [ <BulletListItem> | <OrderedListItem> ]
}

token HtmlBlock {
| <HtmlComment> {*} #= HtmlComment
}

token Inlines {
<_Inline>+
<.Endline>?
Expand Down

0 comments on commit 10c470f

Please sign in to comment.