From bf71f70b10ff6b472f78c88372b62b8659845e9a Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 3 Apr 2012 00:00:39 +0200 Subject: pass through (escape) {brackets,braces} from input --- mod/tex/context/third/rst/rst_context.lua | 76 ++++++++++++++++--------------- mod/tex/context/third/rst/rst_parser.lua | 20 ++++---- 2 files changed, 50 insertions(+), 46 deletions(-) (limited to 'mod') diff --git a/mod/tex/context/third/rst/rst_context.lua b/mod/tex/context/third/rst/rst_context.lua index 6a5aa05..03216d4 100644 --- a/mod/tex/context/third/rst/rst_context.lua +++ b/mod/tex/context/third/rst/rst_context.lua @@ -40,7 +40,7 @@ do } function string.strip(str) return stripper:match(str) or "" - end + end end local stringstrip = string.strip local fmt = string.format @@ -368,7 +368,7 @@ do skip2 = P"\\type" * V"balanced", skip3 = P"\\mathematics" * V"balanced", skip = V"skip1" + V"skip2" + V"skip3", - --literal = Cs(P"\\" / "") * 1 + --literal = Cs(P"\\" / "") * 1 } function rst_context.escape (str) @@ -393,13 +393,13 @@ local corresponding = { local inline_parser = P{ [1] = "block", - block = Cs(V"inline_as_first"^-1 * (V"except" + V"inline_element" + 1)^0), + block = Cs(V"inline_as_first"^-1 * (V"except" + V"inline_element" + V"normal_char")^0), inline_element = V"precede_inline" - * Cs(V"inline_do_elements") - * #V"succede_inline" - + V"footnote_reference" - , + * Cs(V"inline_do_elements") + * #V"succede_inline" + + V"footnote_reference" + , -- Ugly but needed in case the first element of a paragraph is inline -- formatted. @@ -410,15 +410,15 @@ local inline_parser = P{ , inline_do_elements = V"strong_emphasis" - + V"substitution_reference" - + V"anon_reference" - + V"inline_literal" - + V"reference" - + V"emphasis" - + V"interpreted_text" - + V"inline_internal_target" - + V"link_standalone" - , + + V"substitution_reference" + + V"anon_reference" + + V"inline_literal" + + V"reference" + + V"emphasis" + + V"interpreted_text" + + V"inline_internal_target" + + V"link_standalone" + , precede_inline = V"spacing" + V"eol" @@ -489,15 +489,19 @@ local inline_parser = P{ lparenthesis = P"(", rparenthesis = P")", - lsquare = P"[", - rsquare = P"]", - lbrace = P"{", - rbrace = P"}", + lsquare = P"[" / [[{\\letterleftbracket}]], + rsquare = P"]" / [[{\\letterrightbracket}]], + lbrace = P"{" / [[{\\letterleftbrace}]], + rbrace = P"}" / [[{\\letterrightbrace}]], less = P"<", greater = P">", leftpar = V"lparenthesis" + V"lsquare" + V"lbrace" + V"less", rightpar = V"rparenthesis" + V"rsquare" + V"rbrace" + V"greater", + normal_char = V"lbrace" + V"rbrace" + V"lsquare" + V"rsquare" -- escape those if in input + + 1 + , + --groupchars = S"()[]{}", groupchars = V"leftpar" + V"rightpar", apostrophe = P"’" + P"'", @@ -512,36 +516,36 @@ local inline_parser = P{ letter = R"az" + R"AZ", punctuation = V"apostrophe" - + V"colon" - + V"comma" + + V"colon" + + V"comma" + V"dashes" - + V"dot" + + V"dot" + V"ellipsis" + V"exclamationmark" + V"guillemets" + V"hyphen" + V"interpunct" + V"interrobang" - + V"questionmark" + + V"questionmark" + V"quotationmarks" - + V"semicolon" + + V"semicolon" + V"slash" + V"solidus" + V"underscore" , - emphasis = (V"asterisk" - V"double_asterisk") + emphasis = (V"asterisk" - V"double_asterisk") * Cs((1 - V"spacing" - V"eol" - V"asterisk") - * ((1 - (1 * V"asterisk"))^0 - * (1 - V"spacing" - V"eol" - V"asterisk"))^-1) - * V"asterisk" + * ((1 - (1 * V"asterisk"))^0 + * (1 - V"spacing" - V"eol" - V"asterisk"))^-1) + * V"asterisk" / rst_context.emphasis, - strong_emphasis = V"double_asterisk" + strong_emphasis = V"double_asterisk" * Cs((1 - V"spacing" - V"eol" - V"asterisk") - * ((1 - (1 * V"double_asterisk"))^0 - * (1 - V"spacing" - V"eol" - V"asterisk"))^-1) - * V"double_asterisk" + * ((1 - (1 * V"double_asterisk"))^0 + * (1 - V"spacing" - V"eol" - V"asterisk"))^-1) + * V"double_asterisk" / rst_context.strong_emphasis, inline_literal = V"double_bareia" @@ -586,9 +590,9 @@ local inline_parser = P{ * V"bareia" * V"underscore" , - footnote_reference = V"lsquare" - * Cs(V"footnote_label" + V"citation_reference_label") - * V"rsquare" + footnote_reference = V"lsquare" + * Cs(V"footnote_label" + V"citation_reference_label") + * V"rsquare" * V"underscore" / rst_context.footnote_reference , diff --git a/mod/tex/context/third/rst/rst_parser.lua b/mod/tex/context/third/rst/rst_parser.lua index 9735635..1f3a257 100644 --- a/mod/tex/context/third/rst/rst_parser.lua +++ b/mod/tex/context/third/rst/rst_parser.lua @@ -207,7 +207,7 @@ local parser = P{ * C((1 - V"bar" - V"eol")^1) * V"bar" , - + data_directive_block = V"data_directive_block_long" + V"data_directive_block_short" , @@ -284,7 +284,7 @@ local parser = P{ end) * (1 - V"eol")^1 * V"eol" , - + fn_matchindent = Cmt(V"space"^1, function(s, i, indent) local tc = state.currentindent warn("fn-ma", tc == indent, #tc, #indent, i) @@ -330,7 +330,7 @@ local parser = P{ st_first_row = V"st_setindent" * C(V"st_setlayout") - * V"space"^0 + * V"space"^0 * V"eol" , @@ -1269,19 +1269,19 @@ local parser = P{ punctuation = V"apostrophe" - + V"colon" - + V"comma" + + V"colon" + + V"comma" + V"dashes" - + V"dot" + + V"dot" + V"ellipsis" + V"exclamationmark" + V"guillemets" + V"hyphen" + V"interpunct" + V"interrobang" - + V"questionmark" + + V"questionmark" + V"quotationmarks" - + V"semicolon" + + V"semicolon" + V"slash" + V"solidus" + V"underscore" @@ -1291,7 +1291,7 @@ local parser = P{ letter = R"az" + R"AZ", digit = R"09", - + space = P" ", spaces = V"space"^1, whitespace = (P" " + Cs(P"\t") / " " + Cs(S"\v") / " "), @@ -1387,7 +1387,7 @@ local function load_file (name) tmp = fh.crlf(tmp) end if thirddata.rst.expandtab then - tmp = fh.expandtab(tmp) + tmp = fh.expandtab(tmp) end return fh.insert_blank(tmp) end -- cgit v1.2.3