summaryrefslogtreecommitdiff
path: root/rst_context.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-15 20:34:46 +0200
committerPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-15 20:34:46 +0200
commitc0b5a4227e09a708ed0440599600cb784d071b9f (patch)
tree6aa5f8a3734b323b99d389cae6ec85b8e51aa713 /rst_context.lua
parentf1786af10f0be9675f83a335581593d45d56836c (diff)
downloadcontext-rst-c0b5a4227e09a708ed0440599600cb784d071b9f.tar.gz
ignoring inline markup delimiters enclosed by parentheses or quotes
Diffstat (limited to 'rst_context.lua')
-rw-r--r--rst_context.lua90
1 files changed, 62 insertions, 28 deletions
diff --git a/rst_context.lua b/rst_context.lua
index b85ef2c..6420b5d 100644
--- a/rst_context.lua
+++ b/rst_context.lua
@@ -230,13 +230,22 @@ function rst_context.joinindented (tab)
return table.concat (tab, "")
end
+local corresponding = {
+ ['"'] = '"',
+ ["'"] = "'",
+ ["{"] = "}",
+ ["("] = ")",
+ ["["] = "]",
+ ["<"] = ">",
+}
+
local inline_parser = P{
[1] = "block",
- block = Cs((V"inline_element" + 1)^1),
-
+ block = Cs((V"inquotes" + V"inline_element" + 1)^1),
- inline_element = Cs((V"strong_emphasis"
+ inline_element = V"precede_inline"
+ * Cs((V"strong_emphasis"
+ V"substitution_reference"
+ V"anon_reference"
+ V"reference"
@@ -248,14 +257,44 @@ local inline_parser = P{
+ V"link_standalone")
* V"succede_inline"),
+ precede_inline = V"spacing"
+ + V"eol"
+ + S[['"([{<-/:]]
+ + P"‘" + P"“" + P"’" + P"«" + P"¡" + P"¿"
+ + V"inline_delimiter"
+ + P"„", -- not in standard Murkin reST
+
+ succede_inline = V"spacing"
+ + S[['")]}>-/:.,;!?\]]
+ + P"’" + P"”" + P"»"
+ + V"inline_delimiter"
+ + -P(1)
+ + P"“", -- non-standard again but who cares
+
+ inquotes = 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"
+ ,
+
space = P" ",
whitespace = (P" " + Cs(P"\t") / " " + Cs(S"\v") / " "),
spacing = V"whitespace"^1,
eol = P"\n",
- inline_delimiters = P"‐" + P"‑" + P"‒" + P"–" + V"emdash" + V"space", -- inline markup
- --inline_delimiter = P"**" + P"``" + S"*`",
+ --inline_delimiters = P"‐" + P"‑" + P"‒" + P"–" + V"emdash" + V"space", -- inline markup
+ inline_delimiter = P"‐" + P"‑" + P"‒" + P"–" + V"emdash" + V"space"
+ + V"bareia"
+ + V"asterisk"
+ + V"bar"
+ + V"lsquare" + V"rsquare"
+ , -- inline markup
asterisk = P"*",
+ quote_single = P"'",
+ quote_double = P'"',
double_asterisk = V"asterisk" * V"asterisk",
bareia = P"`",
backslash = P"\\",
@@ -279,7 +318,20 @@ local inline_parser = P{
triple_dash = V"double_dash" * V"dash",
hyphen = P"‐",
dashes = V"dash" + P"‒" + P"–" + V"emdash" + P"―",
- groupchars = S"()[]{}",
+
+ lparenthesis = P"(",
+ rparenthesis = P")",
+ lsquare = P"[",
+ rsquare = P"]",
+ lbrace = P"{",
+ rbrace = P"}",
+ less = P"<",
+ greater = P">",
+ leftpar = V"lparenthesis" + V"lsquare" + V"lbrace" + V"less",
+ rightpar = V"rparenthesis" + V"rsquare" + V"rbrace" + V"greater",
+
+ --groupchars = S"()[]{}",
+ groupchars = V"leftpar" + V"rightpar",
apostrophe = P"’" + P"'",
guillemets = P"«" + P"»",
@@ -288,9 +340,6 @@ local inline_parser = P{
slash = P"/",
gartenzaun = P"#",
- lsquare = P"[",
- rsquare = P"]",
-
digit = R"09",
letter = R"az" + R"AZ",
@@ -313,19 +362,6 @@ local inline_parser = P{
+ V"underscore"
,
- precede_inline = V"spacing"
- + V"eol"
- + S[['"([{<-/:]]
- + P"‘" + P"“" + P"’" + P"«" + P"¡" + P"¿"
- + V"inline_delimiters"
- + P"„", -- not in standard Murkin reST
-
- succede_inline = V"spacing"
- + S[['")]}>-/:.,;!?\]]
- + P"’" + P"”" + P"»"
- + V"inline_delimiters"
- + P"“", -- non-standard again but who cares
-
emphasis = (V"asterisk" - V"double_asterisk")
* Cs((1 - V"spacing" - V"eol" - V"asterisk")
* ((1 - (1 * V"asterisk"))^0
@@ -859,7 +895,6 @@ function rst_context.grid_table (tab)
nr = nr + 1
end
local tail = [[
-
\\eTABLEbody
\\eTABLE
%\\stoplinecorrection
@@ -873,8 +908,8 @@ function rst_context.simple_table(tab)
local nr = 1
if tab.head_end 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=yes,option=stretch]
\\bTABLEhead
@@ -905,15 +940,14 @@ function rst_context.simple_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=yes,option=stretch]
\\bTABLEbody
]]
end
local tail = [[
-
\\eTABLEbody
\\eTABLE
%\\stoplinecorrection