From 95482834c8a7a99f677fc6ffafd72399d157f58d Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 16 Sep 2010 19:37:13 +0200 Subject: fixed spacing before colons in paragraph-contained literal blocks --- rst_context.lua | 7 +++++-- rst_parser.lua | 31 +++++++++++++++---------------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/rst_context.lua b/rst_context.lua index a46e0a2..3107a29 100644 --- a/rst_context.lua +++ b/rst_context.lua @@ -740,6 +740,11 @@ function rst_context.option_item (tab) ]], tab[1], tab[2]) end +function rst_context.test(str) + print("This:>>"..str.."<<") + return ":" +end + function rst_context.literal_block (str, included) local indent = P" "^1 local stripme = indent:match(str) or 0 @@ -756,8 +761,6 @@ function rst_context.literal_block (str, included) } str = strip:match(str) - --strip:print() -- grammar consists of 45 rules only; wheras a plain - -- pattern has 60+ str = [[ \starttyping[lines=hyphenated] diff --git a/rst_parser.lua b/rst_parser.lua index 46142ba..f5e3f28 100644 --- a/rst_parser.lua +++ b/rst_parser.lua @@ -988,18 +988,12 @@ local parser = P{ -- Paragraphs * Inline Markup -------------------------------------------------------------------------------- - --paragraph = V"par_setindent" - --* Ct(C((1 - V"eol")^1) * V"eol" - --* (V"par_matchindent" * C((1 - V"eol")^1) * V"eol")^0) - --* V"end_block" - --/ rst.paragraph, - paragraph = Ct(V"par_first" * V"par_other"^0) * V"end_block" / rst.paragraph, - par_first = V"par_setindent" * C((1 - V"eol")^1) * V"eol", + par_first = V"par_setindent" * C((1 - V"literal_block_shorthand" - V"eol")^1) * V"eol", par_other = V"par_matchindent" * C((1 - V"literal_block_shorthand" - V"eol")^1) @@ -1034,20 +1028,25 @@ local parser = P{ end) , - --literal_block_shorthand = ((V"colon" * V"space"^1)^-1 - --* V"double_colon") / ":" - --* (V"eol" * V"blank_line" / "") - --, - - literal_block_shorthand = (((V"double_colon" * V"space"^0) - + (V"colon" * V"space"^1 * V"double_colon")) + literal_block_shorthand = Cs(((V"colon" * V"space" * V"double_colon") + + V"double_colon") + * V"whitespace"^0 * V"eol" - * V"blank_line" / ":") + * V"blank_line") + -- The \unskip is necessary because the lines of a + -- paragraph get concatenated from a table with a + -- space as separator. And the literal block is + -- treated as one such line, hence it would be + -- preceded by a space. As the ":" character + -- always follows a non-space this should be a + -- safe, albeit unpleasant, hack. If you don't + -- agree then file a bug report and I'll look into + -- it. + / "\\\\unskip:" , literal_block_markerless = Cs(V"literal_block_lines" * (V"blank_line"^1 * V"literal_block_lines")^0) - --* V"end_block" * V"blank_line" / rst.included_literal_block , -- cgit v1.2.3