From 46203f2d8a6fcbd87efc95f42bb0cd3a83f43de0 Mon Sep 17 00:00:00 2001 From: Max Leonhardt <33464273+glugg23@users.noreply.github.com> Date: Wed, 2 Dec 2020 20:54:22 +0000 Subject: [PATCH] Support escaped percent sign (#70) --- detex.l | 1 + test.pl | 1 + test/comments-correct.txt | 2 ++ test/comments.tex | 5 +++++ 4 files changed, 9 insertions(+) create mode 100644 test/comments-correct.txt create mode 100644 test/comments.tex diff --git a/detex.l b/detex.l index 02f6db8..0b0590a 100644 --- a/detex.l +++ b/detex.l @@ -423,6 +423,7 @@ VERBSYMBOL =|\\leq|\\geq|\\in|>|<|\\subseteq|\subseteq|\\subset|\\supset|\\sim|\ /* escaping commands */ "\\slash" putchar('/'); +"\\%" putchar('%'); \\(aa|AA|ae|AE|oe|OE|ss)[ \t]*[ \t\n}] /* handle ligatures */ {(void)printf("%.2s", yytext+1);} \\[OoijLl][ \t]*[ \t\n}] {(void)printf("%.1s", yytext+1);} diff --git a/test.pl b/test.pl index de51920..0272c55 100755 --- a/test.pl +++ b/test.pl @@ -7,6 +7,7 @@ assert_produces_correct_output('words.tex', 'words-correct.txt', '-w -l'); assert_produces_correct_output('nouns.tex', 'nouns-correct.txt', '-r'); assert_produces_correct_output('with-srcloc.tex', 'with-srcloc-correct.txt', '-1'); +assert_produces_correct_output('comments.tex', 'comments-correct.txt'); run_for_wrong_input("non-existent-file"); run_for_wrong_input("non-existent-file.tex"); diff --git a/test/comments-correct.txt b/test/comments-correct.txt new file mode 100644 index 0000000..58b1168 --- /dev/null +++ b/test/comments-correct.txt @@ -0,0 +1,2 @@ + +This 100% has a percent sign and will be included. diff --git a/test/comments.tex b/test/comments.tex new file mode 100644 index 0000000..f4a81f7 --- /dev/null +++ b/test/comments.tex @@ -0,0 +1,5 @@ +\documentclass[draft]{book} +\begin{document} +%This is a comment and will not be included. +This 100\% has a percent sign and will be included. +\end{document} \ No newline at end of file