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

Commit

Permalink
parse reference (needed by reference link)
Browse files Browse the repository at this point in the history
  • Loading branch information
fperrad committed Mar 22, 2009
1 parent 4bf8542 commit 866ea7f
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Compiler.pir
Expand Up @@ -261,6 +261,18 @@ Return generated HTML for all of its children.
.return (code)
.end

=item html(Markdown::Reference node)

=cut

.sub 'html' :method :multi(_,['Markdown';'Reference'])
.param pmc node
.local pmc code
new code, 'CodeString'
set code, ''
.return (code)
.end

=item html(Markdown::Email node)

=cut
Expand Down
1 change: 1 addition & 0 deletions src/Node.pir
Expand Up @@ -31,6 +31,7 @@ for Markdown.
p6meta.'new_class'('Markdown::OrderedList', 'parent'=>base)
p6meta.'new_class'('Markdown::Para', 'parent'=>base)
p6meta.'new_class'('Markdown::RefLink', 'parent'=>base)
p6meta.'new_class'('Markdown::Reference', 'parent'=>base)
p6meta.'new_class'('Markdown::Space', 'parent'=>base)
p6meta.'new_class'('Markdown::Strong', 'parent'=>base)
p6meta.'new_class'('Markdown::Title', 'parent'=>base)
Expand Down
4 changes: 4 additions & 0 deletions src/parser/actions.pm
Expand Up @@ -255,6 +255,10 @@ method AutoLinkEmail($/) {
make Markdown::Email.new( :text( $/[0].text() ) );
}

method Reference($/) {
make Markdown::Reference.new( );
}

method Code($/) {
make Markdown::Code.new( :text( $/[0].text() ) );
}
Expand Down
41 changes: 41 additions & 0 deletions src/parser/grammar.pg
Expand Up @@ -19,6 +19,7 @@ token TOP {
token Block {
<.BlankLine>* [
| <BlockQuote> {*} #= BlockQuote
| <Reference> {*} #= Reference
| <HorizontalRule> {*} #= HorizontalRule
| <Heading> {*} #= Heading
| <OrderedList> {*} #= OrderedList
Expand Down Expand Up @@ -367,12 +368,52 @@ token AutoLinkEmail {

token _Gt { '>' }

token Reference {
<.NonindentSpace> <!_EmptyLabel> <Label> ':' <.Spnl> <RefSrc> <.Spnl> <RefTitle> <.BlankLine>*
{*}
}

token Label {
'[' [ <!_EndLabel> <Inline> ]* ']'
}

token _EndLabel { ']' }

token RefSrc { <.Nonspacechar>+ }

token RefTitle {
| <RefTitleSingle>
| <RefTitleDouble>
| <RefTitleParens>
| <EmptyTitle>
}

token EmptyTitle { '' }

token RefTitleSingle {
'\'' ( [ <!_RefTitleS> . ]* ) '\''
}

token _RefTitleS {
[ '\'' <.Sp> <.Newline> | <.Newline> ]
}

token RefTitleDouble {
'"' ( [ <!_RefTitleD> . ]* ) '"'
}

token _RefTitleD {
[ '"' <.Sp> <.Newline> | <.Newline> ]
}

token RefTitleParens {
'(' ( [ <!_RefTitleP> . ]* ) ')'
}

token _RefTitleP {
[ ')' <.Sp> <.Newline> | <.Newline> ]
}

token Ticks1 { '`' }
token Ticks2 { '``' }
token Ticks3 { '```' }
Expand Down

0 comments on commit 866ea7f

Please sign in to comment.