summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/util-prs.lua
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2016-05-16 00:21:21 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2016-05-16 00:21:21 +0200
commitb344014638169aad6e5f6d2a9a703cb03a8b5064 (patch)
treea4457c5d1fdb99f6e8cfe67d53db97b297c1b3ef /tex/context/base/mkiv/util-prs.lua
parentc7a8e05aac805e409247e3b36c000ab196831727 (diff)
downloadcontext-b344014638169aad6e5f6d2a9a703cb03a8b5064.tar.gz
2016-05-15 20:51:00
Diffstat (limited to 'tex/context/base/mkiv/util-prs.lua')
-rw-r--r--tex/context/base/mkiv/util-prs.lua28
1 files changed, 21 insertions, 7 deletions
diff --git a/tex/context/base/mkiv/util-prs.lua b/tex/context/base/mkiv/util-prs.lua
index 01138f1bb..02729dd0e 100644
--- a/tex/context/base/mkiv/util-prs.lua
+++ b/tex/context/base/mkiv/util-prs.lua
@@ -36,6 +36,8 @@ local lbrace = P("{")
local rbrace = P("}")
local lparent = P("(")
local rparent = P(")")
+local lbracket = P("[")
+local rbracket = P("]")
local period = S(".")
local punctuation = S(".,:;")
local spacer = lpegpatterns.spacer
@@ -44,8 +46,9 @@ local newline = lpegpatterns.newline
local anything = lpegpatterns.anything
local endofstring = lpegpatterns.endofstring
-local nobrace = 1 - (lbrace + rbrace )
-local noparent = 1 - (lparent + rparent)
+local nobrace = 1 - (lbrace + rbrace )
+local noparent = 1 - (lparent + rparent)
+local nobracket = 1 - (lbracket + rbracket)
-- we could use a Cf Cg construct
@@ -56,11 +59,12 @@ lpegpatterns.balanced = P {
[2] = left * V(1) * right
}
-local nestedbraces = P { lbrace * (nobrace + V(1))^0 * rbrace }
-local nestedparents = P { lparent * (noparent + V(1))^0 * rparent }
-local spaces = space^0
-local argument = Cs((lbrace/"") * ((nobrace + nestedbraces)^0) * (rbrace/""))
-local content = (1-endofstring)^0
+local nestedbraces = P { lbrace * (nobrace + V(1))^0 * rbrace }
+local nestedparents = P { lparent * (noparent + V(1))^0 * rparent }
+local nestedbrackets = P { lbracket * (nobracket + V(1))^0 * rbracket }
+local spaces = space^0
+local argument = Cs((lbrace/"") * ((nobrace + nestedbraces)^0) * (rbrace/""))
+local content = (1-endofstring)^0
lpegpatterns.nestedbraces = nestedbraces -- no capture
lpegpatterns.nestedparents = nestedparents -- no capture
@@ -193,6 +197,16 @@ function parsers.settings_to_array(str,strict)
end
end
+local value = P(lbrace * C((nobrace + nestedbraces)^0) * rbrace)
+ + C((nestedbraces + nestedbrackets + nestedparents + (1-comma))^0)
+local pattern = spaces * Ct(value*(separator*value)^0)
+
+function parsers.settings_to_array_obey_fences(str)
+ return lpegmatch(pattern,str)
+end
+
+-- inspect(parsers.settings_to_array_obey_fences("url(http://a,b.c)"))
+
-- this one also strips end spaces before separators
--
-- "{123} , 456 " -> "123" "456"