From 9fae6fd2ddf6442f782bc70f6a51248d5274c5d8 Mon Sep 17 00:00:00 2001 From: "Fletcher T. Penney" Date: Fri, 10 Mar 2017 13:39:05 -0500 Subject: [PATCH] FIXED: Fix abbreviations in ODF; Improve test suite --- Sources/libMultiMarkdown/lexer.c | 208 ++++++++++++---------------- Sources/libMultiMarkdown/lexer.re | 2 +- Sources/libMultiMarkdown/odf.c | 4 +- tests/MMD6Tests/Abbreviations.fodt | 29 ++-- tests/MMD6Tests/Abbreviations.html | 29 ++-- tests/MMD6Tests/Abbreviations.htmlc | 31 +++-- tests/MMD6Tests/Abbreviations.tex | 45 ++++-- tests/MMD6Tests/Abbreviations.text | 40 ++++-- 8 files changed, 216 insertions(+), 172 deletions(-) diff --git a/Sources/libMultiMarkdown/lexer.c b/Sources/libMultiMarkdown/lexer.c index ed85c4c..9622db5 100644 --- a/Sources/libMultiMarkdown/lexer.c +++ b/Sources/libMultiMarkdown/lexer.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.14.3 on Thu Mar 9 19:02:17 2017 */ +/* Generated by re2c 0.14.3 on Fri Mar 10 13:21:57 2017 */ /** MultiMarkdown 6 -- Lightweight markup processor to produce HTML, LaTeX, and more. @@ -132,12 +132,12 @@ yy2: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { - case '+': goto yy269; - case '-': goto yy268; - case '=': goto yy265; - case '>': goto yy267; - case '{': goto yy263; - case '~': goto yy266; + case '+': goto yy264; + case '-': goto yy263; + case '=': goto yy260; + case '>': goto yy262; + case '{': goto yy258; + case '~': goto yy261; default: goto yy3; } yy3: @@ -146,7 +146,7 @@ yy4: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { - case '+': goto yy260; + case '+': goto yy255; default: goto yy5; } yy5: @@ -154,7 +154,7 @@ yy5: yy6: ++YYCURSOR; switch ((yych = *YYCURSOR)) { - case '-': goto yy254; + case '-': goto yy249; default: goto yy7; } yy7: @@ -163,7 +163,7 @@ yy8: yyaccept = 2; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { - case '<': goto yy251; + case '<': goto yy246; default: goto yy9; } yy9: @@ -172,8 +172,8 @@ yy10: yyaccept = 3; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { - case '>': goto yy247; - case '~': goto yy246; + case '>': goto yy242; + case '~': goto yy241; default: goto yy11; } yy11: @@ -182,7 +182,7 @@ yy12: yyaccept = 4; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { - case '=': goto yy243; + case '=': goto yy238; default: goto yy13; } yy13: @@ -190,11 +190,11 @@ yy13: yy14: ++YYCURSOR; switch ((yych = *YYCURSOR)) { - case '#': goto yy239; - case '%': goto yy233; - case '>': goto yy241; - case '?': goto yy235; - case '^': goto yy237; + case '#': goto yy234; + case '%': goto yy228; + case '>': goto yy236; + case '?': goto yy230; + case '^': goto yy232; default: goto yy15; } yy15: @@ -205,7 +205,7 @@ yy16: yy18: ++YYCURSOR; switch ((yych = *YYCURSOR)) { - case '[': goto yy231; + case '[': goto yy226; default: goto yy19; } yy19: @@ -222,7 +222,7 @@ yy24: yy26: ++YYCURSOR; switch ((yych = *YYCURSOR)) { - case '}': goto yy229; + case '}': goto yy224; default: goto yy27; } yy27: @@ -233,21 +233,17 @@ yy28: yy30: ++YYCURSOR; switch ((yych = *YYCURSOR)) { - case '\'': goto yy227; + case '\'': goto yy222; default: goto yy31; } yy31: { return QUOTE_SINGLE; } yy32: - YYCTXMARKER = YYCURSOR + 1; yyaccept = 5; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { - case '\t': goto yy217; - case '\n': goto yy214; - case '\r': goto yy216; - case ' ': goto yy219; - case '.': goto yy220; + case ' ': goto yy214; + case '.': goto yy215; default: goto yy19; } yy33: @@ -433,8 +429,7 @@ yy70: case 6: goto yy36; case 7: goto yy49; case 8: goto yy127; - case 9: goto yy215; - default: goto yy264; + default: goto yy259; } yy71: ++YYCURSOR; @@ -880,213 +875,192 @@ yy212: ++YYCURSOR; { return AMPERSAND_LONG; } yy214: - ++YYCURSOR; -yy215: - YYCURSOR = YYCTXMARKER; - { return TEXT_PERIOD; } -yy216: yych = *++YYCURSOR; switch (yych) { - case '\n': goto yy214; - default: goto yy215; - } -yy217: - ++YYCURSOR; - yych = *YYCURSOR; -yy218: - switch (yych) { - case '\t': - case ' ': goto yy217; - default: goto yy215; - } -yy219: - yyaccept = 9; - yych = *(YYMARKER = ++YYCURSOR); - switch (yych) { - case '.': goto yy223; - default: goto yy218; + case '.': goto yy218; + default: goto yy70; } -yy220: +yy215: yych = *++YYCURSOR; switch (yych) { - case '.': goto yy221; + case '.': goto yy216; default: goto yy70; } -yy221: +yy216: ++YYCURSOR; { return ELLIPSIS; } -yy223: +yy218: yych = *++YYCURSOR; switch (yych) { - case ' ': goto yy224; + case ' ': goto yy219; default: goto yy70; } -yy224: +yy219: yych = *++YYCURSOR; switch (yych) { - case '.': goto yy225; + case '.': goto yy220; default: goto yy70; } -yy225: +yy220: ++YYCURSOR; { return ELLIPSIS; } -yy227: +yy222: ++YYCURSOR; { return QUOTE_RIGHT_ALT; } -yy229: +yy224: ++YYCURSOR; { return BRACE_DOUBLE_RIGHT; } -yy231: +yy226: ++YYCURSOR; { return BRACKET_IMAGE_LEFT; } -yy233: +yy228: ++YYCURSOR; { return BRACKET_VARIABLE_LEFT; } -yy235: +yy230: ++YYCURSOR; { return BRACKET_GLOSSARY_LEFT; } -yy237: +yy232: ++YYCURSOR; { return BRACKET_FOOTNOTE_LEFT; } -yy239: +yy234: ++YYCURSOR; { return BRACKET_CITATION_LEFT; } -yy241: +yy236: ++YYCURSOR; { return BRACKET_ABBREVIATION_LEFT; } -yy243: +yy238: yych = *++YYCURSOR; switch (yych) { - case '}': goto yy244; + case '}': goto yy239; default: goto yy70; } -yy244: +yy239: ++YYCURSOR; { return CRITIC_HI_CLOSE; } -yy246: +yy241: yych = *++YYCURSOR; switch (yych) { - case '}': goto yy249; + case '}': goto yy244; default: goto yy70; } -yy247: +yy242: ++YYCURSOR; { return CRITIC_SUB_DIV; } -yy249: +yy244: ++YYCURSOR; { return CRITIC_SUB_CLOSE; } -yy251: +yy246: yych = *++YYCURSOR; switch (yych) { - case '}': goto yy252; + case '}': goto yy247; default: goto yy70; } -yy252: +yy247: ++YYCURSOR; { return CRITIC_COM_CLOSE; } -yy254: +yy249: ++YYCURSOR; switch ((yych = *YYCURSOR)) { - case '-': goto yy258; - case '}': goto yy256; - default: goto yy255; + case '-': goto yy253; + case '}': goto yy251; + default: goto yy250; } -yy255: +yy250: { return DASH_N; } -yy256: +yy251: ++YYCURSOR; { return CRITIC_DEL_CLOSE; } -yy258: +yy253: ++YYCURSOR; { return DASH_M; } -yy260: +yy255: yych = *++YYCURSOR; switch (yych) { - case '}': goto yy261; + case '}': goto yy256; default: goto yy70; } -yy261: +yy256: ++YYCURSOR; { return CRITIC_ADD_CLOSE; } -yy263: - yyaccept = 10; +yy258: + yyaccept = 9; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { - case 'T': goto yy280; - default: goto yy264; + case 'T': goto yy275; + default: goto yy259; } -yy264: +yy259: { return BRACE_DOUBLE_LEFT; } -yy265: +yy260: yych = *++YYCURSOR; switch (yych) { - case '=': goto yy278; + case '=': goto yy273; default: goto yy70; } -yy266: +yy261: yych = *++YYCURSOR; switch (yych) { - case '~': goto yy276; + case '~': goto yy271; default: goto yy70; } -yy267: +yy262: yych = *++YYCURSOR; switch (yych) { - case '>': goto yy274; + case '>': goto yy269; default: goto yy70; } -yy268: +yy263: yych = *++YYCURSOR; switch (yych) { - case '-': goto yy272; + case '-': goto yy267; default: goto yy70; } -yy269: +yy264: yych = *++YYCURSOR; switch (yych) { - case '+': goto yy270; + case '+': goto yy265; default: goto yy70; } -yy270: +yy265: ++YYCURSOR; { return CRITIC_ADD_OPEN; } -yy272: +yy267: ++YYCURSOR; { return CRITIC_DEL_OPEN; } -yy274: +yy269: ++YYCURSOR; { return CRITIC_COM_OPEN; } -yy276: +yy271: ++YYCURSOR; { return CRITIC_SUB_OPEN; } -yy278: +yy273: ++YYCURSOR; { return CRITIC_HI_OPEN; } -yy280: +yy275: yych = *++YYCURSOR; switch (yych) { - case 'O': goto yy281; + case 'O': goto yy276; default: goto yy70; } -yy281: +yy276: yych = *++YYCURSOR; switch (yych) { - case 'C': goto yy282; + case 'C': goto yy277; default: goto yy70; } -yy282: +yy277: yych = *++YYCURSOR; switch (yych) { - case '}': goto yy283; + case '}': goto yy278; default: goto yy70; } -yy283: +yy278: yych = *++YYCURSOR; switch (yych) { - case '}': goto yy284; + case '}': goto yy279; default: goto yy70; } -yy284: +yy279: ++YYCURSOR; { return TOC; } } diff --git a/Sources/libMultiMarkdown/lexer.re b/Sources/libMultiMarkdown/lexer.re index 7417f6e..9648f66 100644 --- a/Sources/libMultiMarkdown/lexer.re +++ b/Sources/libMultiMarkdown/lexer.re @@ -219,7 +219,7 @@ int scan(Scanner * s, const char * stop) { '\\' { return TEXT_BACKSLASH; } [0-9]+ '.' / (SP|NL) { return TEXT_NUMBER_POSS_LIST; } - '.' / (SP|NL) { return TEXT_PERIOD; } +// '.' / (SP|NL) { return TEXT_PERIOD; } TEXT_LINEBREAK { return TEXT_LINEBREAK; } '\\' NL { return TEXT_LINEBREAK; } diff --git a/Sources/libMultiMarkdown/odf.c b/Sources/libMultiMarkdown/odf.c index 33146b8..2f687a7 100644 --- a/Sources/libMultiMarkdown/odf.c +++ b/Sources/libMultiMarkdown/odf.c @@ -1181,11 +1181,11 @@ void mmd_export_token_odf(DString * out, const char * source, token * t, scratch if (temp_short3 == scratch->inline_abbreviations_to_free->size) { // This is a reference definition - mmd_print_string_odf(out, temp_note->clean_text); + mmd_print_string_odf(out, temp_note->label_text); // mmd_export_token_tree_odf(out, source, t->child, scratch); } else { // This is an inline definition - mmd_print_string_odf(out, temp_note->clean_text); + mmd_print_string_odf(out, temp_note->label_text); // mmd_export_token_tree_odf(out, source, t->child, scratch); } } else { diff --git a/tests/MMD6Tests/Abbreviations.fodt b/tests/MMD6Tests/Abbreviations.fodt index eed1c05..35ccef2 100644 --- a/tests/MMD6Tests/Abbreviations.fodt +++ b/tests/MMD6Tests/Abbreviations.fodt @@ -276,27 +276,36 @@ -FOO (foo) +FOO (foo) foo -BAR (bar) +F.O.O. (f.o.o.) f.o.o. -FOO BAR +f-o-o f-o-o -FOOBAR (foobar) +F O O (f o o) f o o -FOO BAR (foo bar) +fo’o fo’o 5 -BAZ (BAT) (baz) +BAR (bar) bar + +B.A.R. (b.a.r.) b.a.r. + +B-A-R (b-a-r) b-a-r -FOO +B A R (b a r) b a r -BAR +BA'R (ba'r) ba'r + +10 + +FOO BAR (foo bar) -FOOBAR +foo +bar -FOO BAR baz +foo bar diff --git a/tests/MMD6Tests/Abbreviations.html b/tests/MMD6Tests/Abbreviations.html index 539a78b..9f580e0 100644 --- a/tests/MMD6Tests/Abbreviations.html +++ b/tests/MMD6Tests/Abbreviations.html @@ -6,27 +6,36 @@ -

FOO (foo)

+

FOO (foo) foo

-

BAR (bar)

+

F.O.O. (f.o.o.) f.o.o.

-

foo bar

+

f-o-o f-o-o

-

FOOBAR (foobar)

+

F O O (f o o) f o o

-

FOO BAR (foo bar)

+

fo’o fo’o

5

-

BAZ (BAT) (baz)

+

BAR (bar) bar

+ +

B.A.R. (b.a.r.) b.a.r.

+ +

B-A-R (b-a-r) b-a-r

-

foo

+

B A R (b a r) b a r

-

bar

+

BA'R (ba’r) ba’r

-

foobar

+

10

-

foo bar baz

+

FOO BAR (foo bar)

+ +

foo +bar

+ +

foo bar

diff --git a/tests/MMD6Tests/Abbreviations.htmlc b/tests/MMD6Tests/Abbreviations.htmlc index dabcbaf..6e5db01 100644 --- a/tests/MMD6Tests/Abbreviations.htmlc +++ b/tests/MMD6Tests/Abbreviations.htmlc @@ -1,24 +1,35 @@

Title: Abbreviations latex config: article

-

>foo

+

foo foo

-

>bar

+

f.o.o. f.o.o.

-

>foo >bar

+

f-o-o f-o-o

-

>foobar

+

f o o f o o

-

>foo bar

+

fo'o fo'o

5

-

[>(baz) BAZ (BAT)]

+

>bar >bar

-

foo

+

>b.a.r. >b.a.r.

-

bar

+

>b-a-r >b-a-r

-

foobar

+

>b a r >b a r

-

foo bar baz

+

>ba'r >ba'r

+ +

10

+ +

foo bar

+ +

foo +bar

+ +

foo bar

+ +

[>foo bar]: FOO BAR

diff --git a/tests/MMD6Tests/Abbreviations.tex b/tests/MMD6Tests/Abbreviations.tex index 3042175..fce4369 100644 --- a/tests/MMD6Tests/Abbreviations.tex +++ b/tests/MMD6Tests/Abbreviations.tex @@ -2,35 +2,58 @@ \def\mytitle{Abbreviations} \newacronym{foo}{foo}{FOO} +\newacronym{f.o.o.}{f.o.o.}{F.O.O.} + +\newacronym{f-o-o}{f-o-o}{F-O-O} + +\newacronym{f o o}{f o o}{F O O} + +\newacronym{fo'o}{fo'o}{FO'O} + \newacronym{bar}{bar}{BAR} -\newacronym{foobar}{foobar}{FOOBAR} +\newacronym{b.a.r.}{b.a.r.}{B.A.R.} + +\newacronym{b-a-r}{b-a-r}{B-A-R} + +\newacronym{b a r}{b a r}{B A R} + +\newacronym{ba'r}{ba'r}{BA'R} \newacronym{foo bar}{foo bar}{FOO BAR} \input{mmd6-article-begin} -\gls{foo} +\gls{foo} \gls{foo} -\gls{bar} +\gls{f.o.o.} \gls{f.o.o.} -\gls{foo} \gls{bar} +f-o-o f-o-o -\gls{foobar} +\gls{f o o} \gls{f o o} -\gls{foo bar} +fo'o fo'o 5 -\newacronym{baz}{baz}{BAZ (BAT)}\gls{baz} +\gls{bar} \gls{bar} -\gls{foo} +\gls{b.a.r.} \gls{b.a.r.} -\gls{bar} +\gls{b-a-r} \gls{b-a-r} + +\gls{b a r} \gls{b a r} + +\gls{ba'r} \gls{ba'r} + +10 -\gls{foobar} +\gls{foo bar} -\gls{foo bar} baz +\gls{foo} +\gls{bar} + +\gls{foo} \gls{bar} \input{mmd6-article-footer} \end{document} diff --git a/tests/MMD6Tests/Abbreviations.text b/tests/MMD6Tests/Abbreviations.text index cac55dc..4495019 100644 --- a/tests/MMD6Tests/Abbreviations.text +++ b/tests/MMD6Tests/Abbreviations.text @@ -1,30 +1,48 @@ Title: Abbreviations latex config: article -[>foo] +foo foo -[>bar] +f.o.o. f.o.o. -[>foo] [>bar] +f-o-o f-o-o -[>foobar] +f o o f o o -[>foo bar] +fo'o fo'o 5 -[>(baz) BAZ (BAT)] +[>bar] [>bar] -foo +[>b.a.r.] [>b.a.r.] -bar +[>b-a-r] [>b-a-r] + +[>b a r] [>b a r] + +[>ba'r] [>ba'r] + +10 -foobar +foo bar -foo bar baz +foo +bar + +foo bar [>foo]: FOO +[>f.o.o.]: F.O.O. +[>f-o-o]: F-O-O +[>f o o]: F O O +[>fo'o]: FO'O + [>bar]: BAR -[>foobar]: FOOBAR +[>b.a.r.]: B.A.R. +[>b-a-r]: B-A-R +[>b a r]: B A R +[>ba'r]: BA'R + [>foo bar]: FOO BAR -- 2.40.0