From ec7dbffb15a99faa6c366a049ed3fdf919a51aaf Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 22 Sep 2010 22:07:51 +0200 Subject: fixed literal blocks --- rst_context.lua | 6 +++++- rst_directives.lua | 14 ++++++++++++++ rst_parser.lua | 16 ++++++---------- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/rst_context.lua b/rst_context.lua index 77e0966..f41fd6a 100644 --- a/rst_context.lua +++ b/rst_context.lua @@ -245,7 +245,7 @@ local corresponding = { local inline_parser = P{ [1] = "block", - block = Cs(V"inline_as_first"^-1 * (V"enclosed" + V"inline_element" + 1)^1), + block = Cs(V"inline_as_first"^-1 * (V"except" + V"inline_element" + 1)^1), inline_element = V"precede_inline" * Cs(V"inline_do_elements") @@ -257,6 +257,10 @@ local inline_parser = P{ -- formatted. inline_as_first = V"inline_do_elements" * V"succede_inline", + except = P"\\starttyping" * (1 - P"\\stoptyping")^1 * P"\\stoptyping" + + V"enclosed" + , + inline_do_elements = V"strong_emphasis" + V"substitution_reference" + V"anon_reference" diff --git a/rst_directives.lua b/rst_directives.lua index 0b042df..0d4b4e9 100644 --- a/rst_directives.lua +++ b/rst_directives.lua @@ -204,6 +204,20 @@ rst_directives.DANGER = function(addendum) ]], result) end +rst_directives.mp = function(name, data) + local mpcode = string.format([[ +\startreusableMPgraphic{%s} +%s +\stopreusableMPgraphic +]], name, data) + mpcode = mpcode .. string.format([[ +\def\RSTsubstitution%s{%% + \reuseMPgraphic{%s}%% +} +]], name, name) + return mpcode +end + rst_directives.ctx = function(name, data) local ctx = string.format([[ diff --git a/rst_parser.lua b/rst_parser.lua index bbe1f15..23aa042 100644 --- a/rst_parser.lua +++ b/rst_parser.lua @@ -127,13 +127,13 @@ local parser = P{ block = V"explicit_markup" + V"target_block" + + V"literal_block" + Cs(V"list") / rst.escape + Cs(V"line_block") / rst.escape + Cs(V"table_block") / rst.escape + V"transition" --/ rst.escape + V"comment_block" + Cs(V"section") / rst.escape - + V"literal_block" + Cs(V"block_quote") / rst.escape + Cs(V"paragraph") / rst.escape , @@ -609,12 +609,8 @@ local parser = P{ -- Literal blocks -------------------------------------------------------------------------------- - literal_block = V"unquoted_literal_block" - + V"quoted_literal_block", - literal_block = V"literal_block_marker" - * Cs(V"literal_block_lines" - * (V"blank_line"^1 * V"literal_block_lines")^0) + * Cs(V"literal_block_lines") * V"end_block" / rst.literal_block, @@ -624,12 +620,12 @@ local parser = P{ + V"quoted_literal_block_lines", unquoted_literal_block_lines = V"literal_block_first" - * (V"literal_block_other" - - V"blank_line")^0, + * (V"blank_line"^-1 * V"literal_block_other")^0 + , quoted_literal_block_lines = V"quoted_literal_block_first" - * (V"quoted_literal_block_other" - - V"blank_line")^0, + * (V"blank_line"^-1 * V"quoted_literal_block_other")^0 + , literal_block_first = Cmt(V"space"^1, function (s, i, indent) warn("lbk-f", #indent, "", "", i) -- cgit v1.2.3