summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rst_context.lua52
1 files changed, 36 insertions, 16 deletions
diff --git a/rst_context.lua b/rst_context.lua
index 6420b5d..692f458 100644
--- a/rst_context.lua
+++ b/rst_context.lua
@@ -242,10 +242,19 @@ local corresponding = {
local inline_parser = P{
[1] = "block",
- block = Cs((V"inquotes" + V"inline_element" + 1)^1),
+ block = Cs(V"inline_as_first"^-1 * (V"enclosed" + V"inline_element" + 1)^1),
inline_element = V"precede_inline"
- * Cs((V"strong_emphasis"
+ * 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.
+ inline_as_first = V"inline_do_elements" * V"succede_inline",
+
+ inline_do_elements = V"strong_emphasis"
+ V"substitution_reference"
+ V"anon_reference"
+ V"reference"
@@ -253,12 +262,12 @@ local inline_parser = P{
+ V"inline_literal"
+ V"interpreted_text"
+ V"inline_internal_target"
- + V"footnote_reference"
- + V"link_standalone")
- * V"succede_inline"),
+ + V"link_standalone"
+ ,
precede_inline = V"spacing"
+ V"eol"
+ + -P(1)
+ S[['"([{<-/:]]
+ P"‘" + P"“" + P"’" + P"«" + P"¡" + P"¿"
+ V"inline_delimiter"
@@ -271,13 +280,14 @@ local inline_parser = P{
+ -P(1)
+ P"“", -- non-standard again but who cares
- inquotes = V"precede_inline"^-1
+ enclosed = V"precede_inline"^-1
* Cg(V"quote_single" + V"quote_double" + V"leftpar", "lastgroup")
* V"inline_delimiter"
* Cmt(C(V"quote_single" + V"quote_double" + V"rightpar") * Cb("lastgroup"), function(s, i, char, oldchar)
return corresponding[oldchar] == char
end)
- --* V"succede_inline"
+ * V"succede_inline"^-1
+ * -V"underscore"
,
space = P" ",
@@ -766,12 +776,10 @@ function rst_context.line_block_empty()
end
function rst_context.block_quote (tab)
+ rst_context.addsetups("blockquote")
local str = [[
-\\setupdelimitedtext [blockquote][style={\\setupbodyfont[11pt]}] % awful placeholder
-\\definedelimitedtext[attribution][blockquote]
-\\setupdelimitedtext [attribution][style={\\setupbodyfont[11pt]\\it}]
-
\\startlinecorrection
+\\blank[small]
\\startblockquote
]] .. inline_parser:match(tab[1]) .. [[
@@ -779,11 +787,14 @@ function rst_context.block_quote (tab)
]]
return tab[2] and str .. [[
+\\blank[small]
\\startattribution
-]] .. tab[2] .. [[
+]] .. inline_parser:match(tab[2]) .. [[
\\stopattribution
+\\blank[small]
\\stoplinecorrection
]] or str .. [[
+\\blank[small]
\\stoplinecorrection
]]
end
@@ -803,8 +814,8 @@ function rst_context.grid_table (tab)
local head
if tab.has_head then
head = [[
-\\setupTABLE[c][each] [frame=on]
-\\setupTABLE[r][each] [frame=on]
+\\setupTABLE[c][each] [frame=off]
+\\setupTABLE[r][each] [frame=off]
%\\startlinecorrection
\\bTABLE[split=repeat,option=stretch]
\\bTABLEhead
@@ -851,8 +862,8 @@ function rst_context.grid_table (tab)
]]
else
head = [[
-\\setupTABLE[c][each] [frame=on]
-\\setupTABLE[r][each] [frame=on]
+\\setupTABLE[c][each] [frame=off]
+\\setupTABLE[r][each] [frame=off]
%\\startlinecorrection
\\bTABLE[split=repeat,option=stretch]
\\bTABLEbody
@@ -1150,4 +1161,13 @@ function optional_setups.substitutions ()
return substitutions
end
+function optional_setups.blockquote ()
+ return [[
+\setupdelimitedtext [blockquote][style={\tfx}] % awful placeholder
+\definedelimitedtext[attribution][blockquote]
+\setupdelimitedtext [attribution][style={\tfx\it}]
+]]
+end
+
+
return rst_context