From: Fletcher T. Penney Date: Mon, 13 Feb 2017 01:03:08 +0000 (-0500) Subject: FIXED: Work on escaping LaTeX characters X-Git-Tag: 0.3.0a^2~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=317a4d61c940119086e052b2464331e8a37a67aa;p=multimarkdown FIXED: Work on escaping LaTeX characters --- diff --git a/src/html.c b/src/html.c index ebb0a40..2c836a2 100644 --- a/src/html.c +++ b/src/html.c @@ -1340,6 +1340,7 @@ void mmd_export_token_html(DString * out, const char * source, token * t, size_t break; case TEXT_HASH: case TEXT_NUMBER_POSS_LIST: + case TEXT_PERCENT: case TEXT_PERIOD: case TEXT_PLAIN: case TOC: diff --git a/src/latex.c b/src/latex.c index 7c13adc..b7a9359 100644 --- a/src/latex.c +++ b/src/latex.c @@ -672,7 +672,10 @@ void mmd_export_token_latex(DString * out, const char * source, token * t, scrat print("\\]"); break; case MATH_DOLLAR_SINGLE: - print("$"); + if (t->mate) + print("$"); + else + print("\\$"); break; case MATH_DOLLAR_DOUBLE: print("$$"); @@ -1083,13 +1086,16 @@ void mmd_export_token_latex(DString * out, const char * source, token * t, scrat if (t->next) print_char('\n'); break; + case TEXT_PERCENT: + print("\\%"); + break; case TEXT_NUMBER_POSS_LIST: case TEXT_PERIOD: case TEXT_PLAIN: print_token(t); break; case UL: - print_token(t); + print("\\_"); break; default: fprintf(stderr, "Unknown token type: %d\n", t->type); diff --git a/src/lexer.c b/src/lexer.c index eee5df8..1982779 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.14.3 on Sun Feb 12 17:20:11 2017 */ +/* Generated by re2c 0.14.3 on Sun Feb 12 19:24:07 2017 */ /** MultiMarkdown 6 -- Lightweight markup processor to produce HTML, LaTeX, and more. @@ -85,18 +85,19 @@ int scan(Scanner * s, const char * stop) { yych = *YYCURSOR; switch (yych) { case '\t': goto yy42; - case '\n': goto yy48; - case '\r': goto yy50; + case '\n': goto yy50; + case '\r': goto yy52; case ' ': goto yy44; case '!': goto yy18; case '"': goto yy26; case '#': goto yy45; case '$': goto yy38; + case '%': goto yy47; case '&': goto yy33; case '\'': goto yy28; case '(': goto yy19; case ')': goto yy21; - case '*': goto yy51; + case '*': goto yy53; case '+': goto yy4; case '-': goto yy6; case '.': goto yy30; @@ -110,7 +111,7 @@ int scan(Scanner * s, const char * stop) { case '6': case '7': case '8': - case '9': goto yy47; + case '9': goto yy49; case ':': goto yy31; case '<': goto yy8; case '=': goto yy12; @@ -119,24 +120,24 @@ int scan(Scanner * s, const char * stop) { case '\\': goto yy37; case ']': goto yy16; case '^': goto yy40; - case '_': goto yy53; - case '`': goto yy55; + case '_': goto yy55; + case '`': goto yy57; case '{': goto yy2; - case '|': goto yy57; + case '|': goto yy59; case '}': goto yy25; case '~': goto yy10; - default: goto yy59; + default: goto yy61; } yy2: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { - case '+': goto yy257; - case '-': goto yy256; - case '=': goto yy253; - case '>': goto yy255; - case '{': goto yy251; - case '~': goto yy254; + case '+': goto yy259; + case '-': goto yy258; + case '=': goto yy255; + case '>': goto yy257; + case '{': goto yy253; + case '~': goto yy256; default: goto yy3; } yy3: @@ -145,7 +146,7 @@ yy4: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { - case '+': goto yy248; + case '+': goto yy250; default: goto yy5; } yy5: @@ -153,7 +154,7 @@ yy5: yy6: ++YYCURSOR; switch ((yych = *YYCURSOR)) { - case '-': goto yy242; + case '-': goto yy244; default: goto yy7; } yy7: @@ -162,7 +163,7 @@ yy8: yyaccept = 2; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { - case '<': goto yy239; + case '<': goto yy241; default: goto yy9; } yy9: @@ -171,8 +172,8 @@ yy10: yyaccept = 3; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { - case '>': goto yy235; - case '~': goto yy234; + case '>': goto yy237; + case '~': goto yy236; default: goto yy11; } yy11: @@ -181,7 +182,7 @@ yy12: yyaccept = 4; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { - case '=': goto yy231; + case '=': goto yy233; default: goto yy13; } yy13: @@ -189,9 +190,9 @@ yy13: yy14: ++YYCURSOR; switch ((yych = *YYCURSOR)) { - case '#': goto yy227; - case '%': goto yy225; - case '^': goto yy229; + case '#': goto yy229; + case '%': goto yy227; + case '^': goto yy231; default: goto yy15; } yy15: @@ -202,7 +203,7 @@ yy16: yy18: yych = *++YYCURSOR; switch (yych) { - case '[': goto yy223; + case '[': goto yy225; default: goto yy3; } yy19: @@ -217,7 +218,7 @@ yy23: yy25: yych = *++YYCURSOR; switch (yych) { - case '}': goto yy221; + case '}': goto yy223; default: goto yy3; } yy26: @@ -226,7 +227,7 @@ yy26: yy28: ++YYCURSOR; switch ((yych = *YYCURSOR)) { - case '\'': goto yy219; + case '\'': goto yy221; default: goto yy29; } yy29: @@ -236,11 +237,11 @@ yy30: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { - case '\t': goto yy209; - case '\n': goto yy206; - case '\r': goto yy208; - case ' ': goto yy211; - case '.': goto yy212; + case '\t': goto yy211; + case '\n': goto yy208; + case '\r': goto yy210; + case ' ': goto yy213; + case '.': goto yy214; default: goto yy3; } yy31: @@ -251,7 +252,7 @@ yy33: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case 'A': - case 'a': goto yy201; + case 'a': goto yy203; default: goto yy34; } yy34: @@ -262,45 +263,45 @@ yy35: yy37: yych = *++YYCURSOR; switch (yych) { - case ' ': goto yy129; - case '!': goto yy189; - case '"': goto yy179; - case '#': goto yy159; - case '$': goto yy157; - case '%': goto yy155; - case '&': goto yy143; - case '\'': goto yy177; - case '(': goto yy171; - case ')': goto yy169; - case '*': goto yy135; - case '+': goto yy153; - case ',': goto yy185; - case '-': goto yy151; - case '.': goto yy191; - case '/': goto yy139; - case ':': goto yy181; - case ';': goto yy183; - case '<': goto yy147; - case '=': goto yy149; - case '>': goto yy145; - case '?': goto yy187; - case '@': goto yy141; - case '[': goto yy163; - case '\\': goto yy127; - case ']': goto yy161; - case '^': goto yy137; - case '_': goto yy133; - case '`': goto yy175; - case '{': goto yy167; - case '|': goto yy131; - case '}': goto yy165; - case '~': goto yy173; + case ' ': goto yy131; + case '!': goto yy191; + case '"': goto yy181; + case '#': goto yy161; + case '$': goto yy159; + case '%': goto yy157; + case '&': goto yy145; + case '\'': goto yy179; + case '(': goto yy173; + case ')': goto yy171; + case '*': goto yy137; + case '+': goto yy155; + case ',': goto yy187; + case '-': goto yy153; + case '.': goto yy193; + case '/': goto yy141; + case ':': goto yy183; + case ';': goto yy185; + case '<': goto yy149; + case '=': goto yy151; + case '>': goto yy147; + case '?': goto yy189; + case '@': goto yy143; + case '[': goto yy165; + case '\\': goto yy129; + case ']': goto yy163; + case '^': goto yy139; + case '_': goto yy135; + case '`': goto yy177; + case '{': goto yy169; + case '|': goto yy133; + case '}': goto yy167; + case '~': goto yy175; default: goto yy3; } yy38: ++YYCURSOR; switch ((yych = *YYCURSOR)) { - case '$': goto yy125; + case '$': goto yy127; default: goto yy39; } yy39: @@ -314,9 +315,9 @@ yy42: yy44: yych = *++YYCURSOR; switch (yych) { - case '\n': goto yy48; - case '\r': goto yy116; - case ' ': goto yy114; + case '\n': goto yy50; + case '\r': goto yy118; + case ' ': goto yy116; default: goto yy3; } yy45: @@ -327,18 +328,21 @@ yy45: case '\t': case '\n': case '\r': - case ' ': goto yy75; - case '#': goto yy73; + case ' ': goto yy77; + case '#': goto yy75; default: goto yy46; } yy46: { return TEXT_HASH; } yy47: + ++YYCURSOR; + { return TEXT_PERCENT; } +yy49: YYCTXMARKER = YYCURSOR + 1; yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { - case '.': goto yy64; + case '.': goto yy66; case '0': case '1': case '2': @@ -348,66 +352,66 @@ yy47: case '6': case '7': case '8': - case '9': goto yy66; + case '9': goto yy68; default: goto yy3; } -yy48: +yy50: ++YYCURSOR; -yy49: +yy51: { return TEXT_NL; } -yy50: +yy52: yych = *++YYCURSOR; switch (yych) { - case '\n': goto yy48; - default: goto yy49; + case '\n': goto yy50; + default: goto yy51; } -yy51: +yy53: ++YYCURSOR; { return STAR; } -yy53: +yy55: ++YYCURSOR; { return UL; } -yy55: +yy57: ++YYCURSOR; yych = *YYCURSOR; - goto yy63; -yy56: + goto yy65; +yy58: { return BACKTICK; } -yy57: +yy59: ++YYCURSOR; yych = *YYCURSOR; - goto yy61; -yy58: + goto yy63; +yy60: { return PIPE; } -yy59: +yy61: yych = *++YYCURSOR; goto yy3; -yy60: +yy62: ++YYCURSOR; yych = *YYCURSOR; -yy61: +yy63: switch (yych) { - case '|': goto yy60; - default: goto yy58; + case '|': goto yy62; + default: goto yy60; } -yy62: +yy64: ++YYCURSOR; yych = *YYCURSOR; -yy63: +yy65: switch (yych) { - case '`': goto yy62; - default: goto yy56; + case '`': goto yy64; + default: goto yy58; } -yy64: +yy66: yych = *++YYCURSOR; switch (yych) { case '\t': - case ' ': goto yy71; - case '\n': goto yy68; - case '\r': goto yy70; - default: goto yy65; + case ' ': goto yy73; + case '\n': goto yy70; + case '\r': goto yy72; + default: goto yy67; } -yy65: +yy67: YYCURSOR = YYMARKER; switch (yyaccept) { case 0: goto yy3; @@ -417,16 +421,16 @@ yy65: case 4: goto yy13; case 5: goto yy34; case 6: goto yy46; - case 7: goto yy122; - case 8: goto yy207; - default: goto yy252; + case 7: goto yy124; + case 8: goto yy209; + default: goto yy254; } -yy66: +yy68: YYCTXMARKER = YYCURSOR + 1; ++YYCURSOR; yych = *YYCURSOR; switch (yych) { - case '.': goto yy64; + case '.': goto yy66; case '0': case '1': case '2': @@ -436,296 +440,293 @@ yy66: case '6': case '7': case '8': - case '9': goto yy66; - default: goto yy65; + case '9': goto yy68; + default: goto yy67; } -yy68: +yy70: ++YYCURSOR; -yy69: +yy71: YYCURSOR = YYCTXMARKER; { return TEXT_NUMBER_POSS_LIST; } -yy70: +yy72: yych = *++YYCURSOR; switch (yych) { - case '\n': goto yy68; - default: goto yy69; + case '\n': goto yy70; + default: goto yy71; } -yy71: +yy73: ++YYCURSOR; yych = *YYCURSOR; switch (yych) { case '\t': - case ' ': goto yy71; - default: goto yy69; + case ' ': goto yy73; + default: goto yy71; } -yy73: +yy75: YYCTXMARKER = YYCURSOR + 1; yych = *++YYCURSOR; switch (yych) { case '\t': case '\n': case '\r': - case ' ': goto yy81; - case '#': goto yy86; - default: goto yy65; + case ' ': goto yy83; + case '#': goto yy88; + default: goto yy67; } -yy74: +yy76: ++YYCURSOR; yych = *YYCURSOR; -yy75: +yy77: switch (yych) { case '\t': - case ' ': goto yy74; - case '\n': goto yy77; - case '\r': goto yy79; - default: goto yy76; + case ' ': goto yy76; + case '\n': goto yy79; + case '\r': goto yy81; + default: goto yy78; } -yy76: +yy78: { return HASH1; } -yy77: +yy79: ++YYCURSOR; -yy78: +yy80: YYCURSOR = YYCTXMARKER; { return HASH1; } -yy79: +yy81: yych = *++YYCURSOR; switch (yych) { - case '\n': goto yy77; - default: goto yy78; + case '\n': goto yy79; + default: goto yy80; } -yy80: +yy82: ++YYCURSOR; yych = *YYCURSOR; -yy81: +yy83: switch (yych) { case '\t': - case ' ': goto yy80; - case '\n': goto yy83; - case '\r': goto yy85; - default: goto yy82; + case ' ': goto yy82; + case '\n': goto yy85; + case '\r': goto yy87; + default: goto yy84; } -yy82: +yy84: { return HASH2; } -yy83: +yy85: ++YYCURSOR; -yy84: +yy86: YYCURSOR = YYCTXMARKER; { return HASH2; } -yy85: +yy87: yych = *++YYCURSOR; switch (yych) { - case '\n': goto yy83; - default: goto yy84; + case '\n': goto yy85; + default: goto yy86; } -yy86: +yy88: YYCTXMARKER = YYCURSOR + 1; yych = *++YYCURSOR; switch (yych) { case '\t': case '\n': case '\r': - case ' ': goto yy89; - case '#': goto yy87; - default: goto yy65; + case ' ': goto yy91; + case '#': goto yy89; + default: goto yy67; } -yy87: +yy89: YYCTXMARKER = YYCURSOR + 1; yych = *++YYCURSOR; switch (yych) { case '\t': case '\n': case '\r': - case ' ': goto yy95; - case '#': goto yy100; - default: goto yy65; + case ' ': goto yy97; + case '#': goto yy102; + default: goto yy67; } -yy88: +yy90: ++YYCURSOR; yych = *YYCURSOR; -yy89: +yy91: switch (yych) { case '\t': - case ' ': goto yy88; - case '\n': goto yy91; - case '\r': goto yy93; - default: goto yy90; + case ' ': goto yy90; + case '\n': goto yy93; + case '\r': goto yy95; + default: goto yy92; } -yy90: +yy92: { return HASH3; } -yy91: +yy93: ++YYCURSOR; -yy92: +yy94: YYCURSOR = YYCTXMARKER; { return HASH3; } -yy93: +yy95: yych = *++YYCURSOR; switch (yych) { - case '\n': goto yy91; - default: goto yy92; + case '\n': goto yy93; + default: goto yy94; } -yy94: +yy96: ++YYCURSOR; yych = *YYCURSOR; -yy95: +yy97: switch (yych) { case '\t': - case ' ': goto yy94; - case '\n': goto yy97; - case '\r': goto yy99; - default: goto yy96; + case ' ': goto yy96; + case '\n': goto yy99; + case '\r': goto yy101; + default: goto yy98; } -yy96: +yy98: { return HASH4; } -yy97: +yy99: ++YYCURSOR; -yy98: +yy100: YYCURSOR = YYCTXMARKER; { return HASH4; } -yy99: +yy101: yych = *++YYCURSOR; switch (yych) { - case '\n': goto yy97; - default: goto yy98; + case '\n': goto yy99; + default: goto yy100; } -yy100: +yy102: YYCTXMARKER = YYCURSOR + 1; yych = *++YYCURSOR; switch (yych) { case '\t': case '\n': case '\r': - case ' ': goto yy103; - case '#': goto yy101; - default: goto yy65; + case ' ': goto yy105; + case '#': goto yy103; + default: goto yy67; } -yy101: +yy103: YYCTXMARKER = YYCURSOR + 1; yych = *++YYCURSOR; switch (yych) { case '\t': case '\n': case '\r': - case ' ': goto yy109; - default: goto yy65; + case ' ': goto yy111; + default: goto yy67; } -yy102: +yy104: ++YYCURSOR; yych = *YYCURSOR; -yy103: +yy105: switch (yych) { case '\t': - case ' ': goto yy102; - case '\n': goto yy105; - case '\r': goto yy107; - default: goto yy104; + case ' ': goto yy104; + case '\n': goto yy107; + case '\r': goto yy109; + default: goto yy106; } -yy104: +yy106: { return HASH5; } -yy105: +yy107: ++YYCURSOR; -yy106: +yy108: YYCURSOR = YYCTXMARKER; { return HASH5; } -yy107: +yy109: yych = *++YYCURSOR; switch (yych) { - case '\n': goto yy105; - default: goto yy106; + case '\n': goto yy107; + default: goto yy108; } -yy108: +yy110: ++YYCURSOR; yych = *YYCURSOR; -yy109: +yy111: switch (yych) { case '\t': - case ' ': goto yy108; - case '\n': goto yy111; - case '\r': goto yy113; - default: goto yy110; + case ' ': goto yy110; + case '\n': goto yy113; + case '\r': goto yy115; + default: goto yy112; } -yy110: +yy112: { return HASH6; } -yy111: +yy113: ++YYCURSOR; -yy112: +yy114: YYCURSOR = YYCTXMARKER; { return HASH6; } -yy113: +yy115: yych = *++YYCURSOR; switch (yych) { - case '\n': goto yy111; - default: goto yy112; + case '\n': goto yy113; + default: goto yy114; } -yy114: +yy116: ++YYCURSOR; switch ((yych = *YYCURSOR)) { - case '\n': goto yy118; - case '\r': goto yy120; - case ' ': goto yy117; - default: goto yy115; + case '\n': goto yy120; + case '\r': goto yy122; + case ' ': goto yy119; + default: goto yy117; } -yy115: +yy117: { return NON_INDENT_SPACE; } -yy116: +yy118: yych = *++YYCURSOR; switch (yych) { - case '\n': goto yy48; - default: goto yy49; + case '\n': goto yy50; + default: goto yy51; } -yy117: +yy119: yych = *++YYCURSOR; switch (yych) { - case '\n': goto yy118; - case '\r': goto yy120; - case ' ': goto yy121; - default: goto yy115; + case '\n': goto yy120; + case '\r': goto yy122; + case ' ': goto yy123; + default: goto yy117; } -yy118: +yy120: ++YYCURSOR; -yy119: +yy121: { return TEXT_LINEBREAK; } -yy120: +yy122: yych = *++YYCURSOR; switch (yych) { - case '\n': goto yy118; - default: goto yy119; + case '\n': goto yy120; + default: goto yy121; } -yy121: +yy123: yyaccept = 7; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { - case '\n': goto yy118; - case '\r': goto yy120; - case ' ': goto yy123; - default: goto yy122; + case '\n': goto yy120; + case '\r': goto yy122; + case ' ': goto yy125; + default: goto yy124; } -yy122: +yy124: { return INDENT_SPACE; } -yy123: +yy125: ++YYCURSOR; yych = *YYCURSOR; switch (yych) { - case '\n': goto yy118; - case '\r': goto yy120; - case ' ': goto yy123; - default: goto yy65; + case '\n': goto yy120; + case '\r': goto yy122; + case ' ': goto yy125; + default: goto yy67; } -yy125: +yy127: ++YYCURSOR; { return MATH_DOLLAR_DOUBLE; } -yy127: +yy129: ++YYCURSOR; switch ((yych = *YYCURSOR)) { - case '(': goto yy193; - case ')': goto yy195; - case '[': goto yy197; - case ']': goto yy199; - default: goto yy128; + case '(': goto yy195; + case ')': goto yy197; + case '[': goto yy199; + case ']': goto yy201; + default: goto yy130; } -yy128: - { return ESCAPED_CHARACTER; } -yy129: - ++YYCURSOR; +yy130: { return ESCAPED_CHARACTER; } yy131: ++YYCURSOR; @@ -822,241 +823,244 @@ yy191: { return ESCAPED_CHARACTER; } yy193: ++YYCURSOR; - { return MATH_PAREN_OPEN; } + { return ESCAPED_CHARACTER; } yy195: ++YYCURSOR; - { return MATH_PAREN_CLOSE; } + { return MATH_PAREN_OPEN; } yy197: ++YYCURSOR; - { return MATH_BRACKET_OPEN; } + { return MATH_PAREN_CLOSE; } yy199: ++YYCURSOR; - { return MATH_BRACKET_CLOSE; } + { return MATH_BRACKET_OPEN; } yy201: + ++YYCURSOR; + { return MATH_BRACKET_CLOSE; } +yy203: yych = *++YYCURSOR; switch (yych) { case 'M': - case 'm': goto yy202; - default: goto yy65; + case 'm': goto yy204; + default: goto yy67; } -yy202: +yy204: yych = *++YYCURSOR; switch (yych) { case 'P': - case 'p': goto yy203; - default: goto yy65; + case 'p': goto yy205; + default: goto yy67; } -yy203: +yy205: yych = *++YYCURSOR; switch (yych) { - case ';': goto yy204; - default: goto yy65; + case ';': goto yy206; + default: goto yy67; } -yy204: +yy206: ++YYCURSOR; { return AMPERSAND_LONG; } -yy206: +yy208: ++YYCURSOR; -yy207: +yy209: YYCURSOR = YYCTXMARKER; { return TEXT_PERIOD; } -yy208: +yy210: yych = *++YYCURSOR; switch (yych) { - case '\n': goto yy206; - default: goto yy207; + case '\n': goto yy208; + default: goto yy209; } -yy209: +yy211: ++YYCURSOR; yych = *YYCURSOR; -yy210: +yy212: switch (yych) { case '\t': - case ' ': goto yy209; - default: goto yy207; + case ' ': goto yy211; + default: goto yy209; } -yy211: +yy213: yyaccept = 8; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { - case '.': goto yy215; - default: goto yy210; + case '.': goto yy217; + default: goto yy212; } -yy212: +yy214: yych = *++YYCURSOR; switch (yych) { - case '.': goto yy213; - default: goto yy65; + case '.': goto yy215; + default: goto yy67; } -yy213: +yy215: ++YYCURSOR; { return ELLIPSIS; } -yy215: +yy217: yych = *++YYCURSOR; switch (yych) { - case ' ': goto yy216; - default: goto yy65; + case ' ': goto yy218; + default: goto yy67; } -yy216: +yy218: yych = *++YYCURSOR; switch (yych) { - case '.': goto yy217; - default: goto yy65; + case '.': goto yy219; + default: goto yy67; } -yy217: +yy219: ++YYCURSOR; { return ELLIPSIS; } -yy219: +yy221: ++YYCURSOR; { return QUOTE_RIGHT_ALT; } -yy221: +yy223: ++YYCURSOR; { return BRACE_DOUBLE_RIGHT; } -yy223: +yy225: ++YYCURSOR; { return BRACKET_IMAGE_LEFT; } -yy225: +yy227: ++YYCURSOR; { return BRACKET_VARIABLE_LEFT; } -yy227: +yy229: ++YYCURSOR; { return BRACKET_CITATION_LEFT; } -yy229: +yy231: ++YYCURSOR; { return BRACKET_FOOTNOTE_LEFT; } -yy231: +yy233: yych = *++YYCURSOR; switch (yych) { - case '}': goto yy232; - default: goto yy65; + case '}': goto yy234; + default: goto yy67; } -yy232: +yy234: ++YYCURSOR; { return CRITIC_HI_CLOSE; } -yy234: +yy236: yych = *++YYCURSOR; switch (yych) { - case '}': goto yy237; - default: goto yy65; + case '}': goto yy239; + default: goto yy67; } -yy235: +yy237: ++YYCURSOR; { return CRITIC_SUB_DIV; } -yy237: +yy239: ++YYCURSOR; { return CRITIC_SUB_CLOSE; } -yy239: +yy241: yych = *++YYCURSOR; switch (yych) { - case '}': goto yy240; - default: goto yy65; + case '}': goto yy242; + default: goto yy67; } -yy240: +yy242: ++YYCURSOR; { return CRITIC_COM_CLOSE; } -yy242: +yy244: ++YYCURSOR; switch ((yych = *YYCURSOR)) { - case '-': goto yy246; - case '}': goto yy244; - default: goto yy243; + case '-': goto yy248; + case '}': goto yy246; + default: goto yy245; } -yy243: +yy245: { return DASH_N; } -yy244: +yy246: ++YYCURSOR; { return CRITIC_DEL_CLOSE; } -yy246: +yy248: ++YYCURSOR; { return DASH_M; } -yy248: +yy250: yych = *++YYCURSOR; switch (yych) { - case '}': goto yy249; - default: goto yy65; + case '}': goto yy251; + default: goto yy67; } -yy249: +yy251: ++YYCURSOR; { return CRITIC_ADD_CLOSE; } -yy251: +yy253: yyaccept = 9; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { - case 'T': goto yy268; - default: goto yy252; + case 'T': goto yy270; + default: goto yy254; } -yy252: +yy254: { return BRACE_DOUBLE_LEFT; } -yy253: +yy255: yych = *++YYCURSOR; switch (yych) { - case '=': goto yy266; - default: goto yy65; + case '=': goto yy268; + default: goto yy67; } -yy254: +yy256: yych = *++YYCURSOR; switch (yych) { - case '~': goto yy264; - default: goto yy65; + case '~': goto yy266; + default: goto yy67; } -yy255: +yy257: yych = *++YYCURSOR; switch (yych) { - case '>': goto yy262; - default: goto yy65; + case '>': goto yy264; + default: goto yy67; } -yy256: +yy258: yych = *++YYCURSOR; switch (yych) { - case '-': goto yy260; - default: goto yy65; + case '-': goto yy262; + default: goto yy67; } -yy257: +yy259: yych = *++YYCURSOR; switch (yych) { - case '+': goto yy258; - default: goto yy65; + case '+': goto yy260; + default: goto yy67; } -yy258: +yy260: ++YYCURSOR; { return CRITIC_ADD_OPEN; } -yy260: +yy262: ++YYCURSOR; { return CRITIC_DEL_OPEN; } -yy262: +yy264: ++YYCURSOR; { return CRITIC_COM_OPEN; } -yy264: +yy266: ++YYCURSOR; { return CRITIC_SUB_OPEN; } -yy266: +yy268: ++YYCURSOR; { return CRITIC_HI_OPEN; } -yy268: +yy270: yych = *++YYCURSOR; switch (yych) { - case 'O': goto yy269; - default: goto yy65; + case 'O': goto yy271; + default: goto yy67; } -yy269: +yy271: yych = *++YYCURSOR; switch (yych) { - case 'C': goto yy270; - default: goto yy65; + case 'C': goto yy272; + default: goto yy67; } -yy270: +yy272: yych = *++YYCURSOR; switch (yych) { - case '}': goto yy271; - default: goto yy65; + case '}': goto yy273; + default: goto yy67; } -yy271: +yy273: yych = *++YYCURSOR; switch (yych) { - case '}': goto yy272; - default: goto yy65; + case '}': goto yy274; + default: goto yy67; } -yy272: +yy274: ++YYCURSOR; { return TOC; } } diff --git a/src/lexer.re b/src/lexer.re index bc45c10..6abfebf 100644 --- a/src/lexer.re +++ b/src/lexer.re @@ -211,6 +211,7 @@ int scan(Scanner * s, const char * stop) { '#'{6} / SPNL { return HASH6; } '#' { return TEXT_HASH; } + '%' { return TEXT_PERCENT; } [0-9]+ / ('.' (SP|NL)) { return TEXT_NUMBER_POSS_LIST; } '.' / (SP|NL) { return TEXT_PERIOD; } diff --git a/src/libMultiMarkdown.h b/src/libMultiMarkdown.h index 77111f1..6ca1944 100644 --- a/src/libMultiMarkdown.h +++ b/src/libMultiMarkdown.h @@ -278,6 +278,7 @@ enum token_types { TEXT_LINEBREAK, TEXT_NL, TEXT_NUMBER_POSS_LIST, + TEXT_PERCENT, TEXT_PERIOD, TEXT_PLAIN, diff --git a/tests/MMD6Tests/Cross-References.tex b/tests/MMD6Tests/Cross-References.tex new file mode 100644 index 0000000..97ee372 --- /dev/null +++ b/tests/MMD6Tests/Cross-References.tex @@ -0,0 +1,27 @@ +\part{A Section } +\label{asection} + +\part{109\&*\&\#()\^{} Can Start With Digit } +\label{109canstartwithdigit} + +\part{Strip out \&\%\^{} characters \&*\^{} } +\label{stripoutcharacters} + +\autoref{asection}. + +\chapter{1 Cross-References: Special Characters!@\#\$\%\&*()$<$$>$\^{} } +\label{1cross-references:specialcharacters} + +5 + +And now, link to \autoref{1cross-references:specialcharacters} + +\part{Заголовок по-русски } +\label{Заголовокпо-русски} + +И ссылка на \autoref{Заголовокпо-русски}. + +\part{Test 的 Multibyte } +\label{test的multibyte} + +10 diff --git a/tests/MMD6Tests/Edge Cases 2.tex b/tests/MMD6Tests/Edge Cases 2.tex new file mode 100644 index 0000000..8e6cb8c --- /dev/null +++ b/tests/MMD6Tests/Edge Cases 2.tex @@ -0,0 +1,70 @@ +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} +\textbf{b}, \emph{u}, \textbf{v}, \emph{\textbf{w}}, \emph{\textbf{x}}, \textbf{\emph{y}}, \textbf{\emph{z}}, \emph{t \textbf{w} t} diff --git a/tests/MMD6Tests/Edge Cases.tex b/tests/MMD6Tests/Edge Cases.tex new file mode 100644 index 0000000..bbf5bde --- /dev/null +++ b/tests/MMD6Tests/Edge Cases.tex @@ -0,0 +1,94 @@ +\begin{itemize} +\item foo +bar + +\end{itemize} + +foo + +\begin{itemize} +\item bar + +\end{itemize} + +foo + +\begin{enumerate} +\item bar + +\end{enumerate} + +foo + +\begin{enumerate} +\item bar + +\end{enumerate} + +foo + +\begin{quote} +bar +\end{quote} + +5 + +foo + +\part{bar} +\label{bar} + +foo +bar + +The \textbf{\emph{quick}} brown \textbf{\emph{fox}} jumped + +The \textbf{\emph{quick}} brown fox jumped + +The \emph{\textbf{quick} brown fox} jumped + +10 + +The \textbf{\emph{quick} brown fox} jumped + +The \textbf{\emph{quick} brown \emph{fox}} jumped + +The \emph{\textbf{quick} brown \textbf{fox}} jumped + +This \emph{should} be parsed -- fo***o + +\emph{test this}thing + +15 + +\_test this\_thing + +\textbf{test this}thing + +\_\_test this\_\_thing + +\textbf{\emph{test this}}thing + +\_\_\_test this\_\_\_thing + +20 + +This is \textbf{\emph{another} test} of \emph{italics} and \textbf{bold}. + +This is \textbf{\emph{another} test} of \textbf{bold} and \emph{italics}. + +This is \emph{\textbf{another} test} of \textbf{bold} and \emph{italics}. + +This is \emph{\textbf{another} test} of \emph{italics} and \textbf{bold}. + +This is \textbf{\emph{another} test} of \emph{italics} and \textbf{bold}. + +25 + +This is \textbf{\emph{another} test} of \textbf{bold} and \emph{italics}. + +This is \emph{\textbf{another} test} of \textbf{bold} and \emph{italics}. + +This is \emph{\textbf{another} test} of \emph{italics} and \textbf{bold}. + +*a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a *a diff --git a/tests/MMD6Tests/Emph and Strong UL.tex b/tests/MMD6Tests/Emph and Strong UL.tex index 48d78f2..0c3a6e9 100644 --- a/tests/MMD6Tests/Emph and Strong UL.tex +++ b/tests/MMD6Tests/Emph and Strong UL.tex @@ -1,8 +1,8 @@ \emph{foo} -_\emph{foo} +\_\emph{foo} -\emph{foo}_ +\emph{foo}\_ \emph{foo bar} @@ -54,7 +54,7 @@ foo \textbf{bar} \textbf{foo \emph{bar}} -\emph{foo_bar} +\emph{foo\_bar} 25 @@ -62,29 +62,29 @@ foo \textbf{bar} \emph{\emph{\emph{\emph{foo} bar} foo} bar} -_foo bar_bar +\_foo bar\_bar -__foo bar__bar +\_\_foo bar\_\_bar -___foo bar___bar +\_\_\_foo bar\_\_\_bar 30 -foo_bar_foo +foo\_bar\_foo -foo__bar__foo +foo\_\_bar\_\_foo -foo___bar___foo +foo\_\_\_bar\_\_\_foo -foo_bar_foo +foo\_bar\_foo \textbf{foo \emph{foobarfoo} foo} 35 -foo__\texttt{_bar_}__ +foo\_\_\texttt{_bar_}\_\_ -_(\emph{foo}) +\_(\emph{foo}) \emph{foo}: @@ -94,100 +94,100 @@ _(\emph{foo}) 40 -foo_bar +foo\_bar -foo_bar foo_bar +foo\_bar foo\_bar -foo__bar +foo\_\_bar -foo__bar foo__bar +foo\_\_bar foo\_\_bar -foo___bar +foo\_\_\_bar 45 -foo___bar foo___bar +foo\_\_\_bar foo\_\_\_bar -foo __- bar__ +foo \_\_- bar\_\_ foo \textbf{1. bar} -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo -_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo +\_foo \emph{foo}