Open GoogleCodeExporter opened 8 years ago
Here's the grammar from peg-markdown:
# This keeps the parser from getting bogged down on long strings of '*' or '_',
# or strings of '*' or '_' with space on each side:
UlOrStarLine = UlLine | StarLine { $$ = mk_str(yytext); }
StarLine = < "****" '*'* > | < Spacechar '*'+ &Spacechar >
UlLine = < "____" '_'* > | < Spacechar '_'+ &Spacechar >
Emph = EmphStar | EmphUl
OneStarOpen = !StarLine '*' !Spacechar !Newline
OneStarClose = !Spacechar !Newline a:Inline !StrongStar '*' { $$ = a; }
EmphStar = OneStarOpen
a:StartList
( !OneStarClose Inline { a = cons($$, a); } )*
OneStarClose { a = cons($$, a); }
{ $$ = mk_list(EMPH, a); }
OneUlOpen = !UlLine '_' !Spacechar !Newline
OneUlClose = !Spacechar !Newline a:Inline !StrongUl '_' !Alphanumeric { $$ = a;
}
EmphUl = OneUlOpen
a:StartList
( !OneUlClose Inline { a = cons($$, a); } )*
OneUlClose { a = cons($$, a); }
{ $$ = mk_list(EMPH, a); }
Strong = StrongStar | StrongUl
TwoStarOpen = !StarLine "**" !Spacechar !Newline
TwoStarClose = !Spacechar !Newline a:Inline "**" { $$ = a; }
StrongStar = TwoStarOpen
a:StartList
( !TwoStarClose Inline { a = cons($$, a); } )*
TwoStarClose { a = cons($$, a); }
{ $$ = mk_list(STRONG, a); }
TwoUlOpen = !UlLine "__" !Spacechar !Newline
TwoUlClose = !Spacechar !Newline a:Inline "__" !Alphanumeric { $$ = a; }
StrongUl = TwoUlOpen
a:StartList
( !TwoUlClose Inline { a = cons($$, a); } )*
TwoUlClose { a = cons($$, a); }
{ $$ = mk_list(STRONG, a); }
Original comment by fiddloso...@gmail.com
on 11 Aug 2008 at 2:45
Original comment by fiddloso...@gmail.com
on 5 Dec 2009 at 8:04
Here's how lunamark does it:
UlOrStarLine = p"*"^4 + p"_"^4 + (generic.space * lpeg.S("*_")^1 *
#generic.space) / writer.str,
Emph = _"EmphStar" + _"EmphUl",
EmphStar = p"*" * -(generic.spacechar + generic.newline) * lpeg.Ct((_"Inline" -
p"*")^1) * p"*" / writer.emph,
EmphUl = p"_" * -(generic.spacechar + generic.newline) * lpeg.Ct((_"Inline" -
p"_")^1) * p"_" / writer.emph,
Strong = _"StrongStar" + _"StrongUl",
StrongStar = p"**" * -(generic.spacechar + generic.newline) * lpeg.Ct((_"Inline"
- p"**")^1) * p"**" / writer.strong,
StrongUl = p"__" * -(generic.spacechar + generic.newline) * lpeg.Ct((_"Inline" -
p"__")^1) * p"__" / writer.strong,
Original comment by fiddloso...@gmail.com
on 5 Dec 2009 at 5:12
Current peg-markdown:
# This keeps the parser from getting bogged down on long strings of '*' or '_',
# or strings of '*' or '_' with space on each side:
UlOrStarLine = (UlLine | StarLine) { $$ = mk_str(yytext); }
StarLine = < "****" '*'* > | < Spacechar '*'+ &Spacechar >
UlLine = < "____" '_'* > | < Spacechar '_'+ &Spacechar >
Emph = EmphStar | EmphUl
OneStarOpen = !StarLine '*' !Spacechar !Newline
OneStarClose = !Spacechar !Newline a:Inline !StrongStar '*' { $$ = a; }
EmphStar = OneStarOpen
a:StartList
( !OneStarClose Inline { a = cons($$, a); } )*
OneStarClose { a = cons($$, a); }
{ $$ = mk_list(EMPH, a); }
OneUlOpen = !UlLine '_' !Spacechar !Newline
OneUlClose = !Spacechar !Newline a:Inline !StrongUl '_' !Alphanumeric { $$ = a;
}
EmphUl = OneUlOpen
a:StartList
( !OneUlClose Inline { a = cons($$, a); } )*
OneUlClose { a = cons($$, a); }
{ $$ = mk_list(EMPH, a); }
Strong = StrongStar | StrongUl
TwoStarOpen = !StarLine "**" !Spacechar !Newline
TwoStarClose = !Spacechar !Newline a:Inline "**" { $$ = a; }
StrongStar = TwoStarOpen
a:StartList
( !TwoStarClose Inline { a = cons($$, a); } )*
TwoStarClose { a = cons($$, a); }
{ $$ = mk_list(STRONG, a); }
TwoUlOpen = !UlLine "__" !Spacechar !Newline
TwoUlClose = !Spacechar !Newline a:Inline "__" !Alphanumeric { $$ = a; }
StrongUl = TwoUlOpen
a:StartList
( !TwoUlClose Inline { a = cons($$, a); } )*
TwoUlClose { a = cons($$, a); }
{ $$ = mk_list(STRONG, a); }
Original comment by fiddloso...@gmail.com
on 5 Dec 2009 at 7:02
Original comment by fiddloso...@gmail.com
on 5 Dec 2009 at 7:10
Original comment by fiddloso...@gmail.com
on 5 Dec 2009 at 7:10
Original issue reported on code.google.com by
fiddloso...@gmail.com
on 18 Apr 2008 at 3:02