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 ++++++++++++++++--------------- 1 file changed, 40 insertions(+), 36 deletions(-) (limited to 'mod/tex/context/third/rst/rst_context.lua') 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 , -- cgit v1.2.3