Skip to content

Commit

Permalink
Fixed Str parser so it handles apostrophes inside words.
Browse files Browse the repository at this point in the history
Previously the --smart option would trigger exponential slowdown
in text heavy with intraword apostrophes.  This fixes the problem.

Str is now a bunch of NormalChars followed by a list of StrChunks.
A StrChunk is either a bunch of NormalChars, an underscore followed
by alphanumeric, or (in smart mode) an apostrophe.
  • Loading branch information
jgm committed Mar 22, 2011
1 parent fff88fe commit 4bb5083
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions markdown_parser.leg
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,15 @@ Space = Spacechar+
{ $$ = mk_str(" ");
$$->key = SPACE; }

Str = < NormalChar (NormalChar | '_'+ &Alphanumeric)* >
{ $$ = mk_str(yytext); }
Str = a:StartList < NormalChar+ > { a = cons(mk_str(yytext), a); }
( StrChunk { a = cons($$, a); } )*
{ if (a->next == NULL) { $$ = a; } else { $$ = mk_list(LIST, a); } }

StrChunk = < (NormalChar | '_'+ &Alphanumeric)+ > { $$ = mk_str(yytext); } |
AposChunk

AposChunk = &{ extension(EXT_SMART) } '\'' &Alphanumeric
{ $$ = mk_element(APOSTROPHE); }

EscapedChar = '\\' !Newline < [-\\`|*_{}[\]()#+.!><] >
{ $$ = mk_str(yytext); }
Expand Down Expand Up @@ -664,7 +671,7 @@ EnDash = '-' &Digit
EmDash = ("---" | "--")
{ $$ = mk_element(EMDASH); }

SingleQuoteStart = '\'' ![)!\],.;:-? \t\n] !( ( "s" | "t" | "m" | "ve" | "ll" | "re" ) !Alphanumeric )
SingleQuoteStart = '\'' ![)!\],.;:-? \t\n]

SingleQuoteEnd = '\'' !Alphanumeric

Expand Down

0 comments on commit 4bb5083

Please sign in to comment.