aboutsummaryrefslogtreecommitdiff
path: root/ekdosis.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'ekdosis.dtx')
-rw-r--r--ekdosis.dtx68
1 files changed, 21 insertions, 47 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index 8354459..6e0bf42 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -1557,6 +1557,19 @@ function ekdosis.newenvtotag(env, tag, attr, closep)
1557 return true 1557 return true
1558end 1558end
1559 1559
1560-- Get values of attributes
1561local function get_attr_value(str, attr)
1562 local attrval = string.match(str, "%f[%w]"..attr.."%s?%=%s?%b{}")
1563 or string.match(str, "%f[%w]"..attr.."%s?%=%s?.-%,")
1564 or ""
1565 attrval = string.gsub(attrval, attr.."%s?%=%s?(%b{})", function(bbraces)
1566 bbraces = string.sub(bbraces, 2, -2)
1567 return string.format("%s", bbraces)
1568 end)
1569 attrval = string.gsub(attrval, attr.."%s?%=%s?(.-)%s?%,", "%1")
1570 return attrval
1571end
1572
1560local function xml_entities(str) 1573local function xml_entities(str)
1561 str = string.gsub(str, "%<", "&lt;") 1574 str = string.gsub(str, "%<", "&lt;")
1562 str = string.gsub(str, "%>", "&gt;") 1575 str = string.gsub(str, "%>", "&gt;")
@@ -1949,17 +1962,6 @@ function ekdosis.setekddivsfalse()
1949 ekddivs = false 1962 ekddivs = false
1950end 1963end
1951 1964
1952--[[
1953 teitype = string.match(opt, "%f[%w]type%s?%=%s?%b{}")
1954 or string.match(opt, "%f[%w]type%s?%=%s?%w+%f[%W]")
1955 or ""
1956 teitype = string.gsub(teitype, "type%s?%=%s?(%b{})", function(bbraces)
1957 bbraces = string.sub(bbraces, 2, -2)
1958 return string.format("%s", bbraces)
1959 end)
1960 teitype = string.gsub(teitype, "(type%s?%=%s?)(%w+%f[%W])", "%2")
1961--]]
1962
1963local function ekddivs_totei(str) 1965local function ekddivs_totei(str)
1964 str = gsub(str, dblbkslash * lpeg.Cs("ekddiv") * spce^-1 * bcbraces, 1966 str = gsub(str, dblbkslash * lpeg.Cs("ekddiv") * spce^-1 * bcbraces,
1965 function(bkslash, cmd, space, arg) 1967 function(bkslash, cmd, space, arg)
@@ -1968,43 +1970,15 @@ local function ekddivs_totei(str)
1968 arg = string.sub(arg, 2, -2) 1970 arg = string.sub(arg, 2, -2)
1969 arg = arg.."," 1971 arg = arg..","
1970 -- 1972 --
1971 teitype = string.match(arg, "%f[%w]type%s?%=%s?%b{}") 1973 teitype = get_attr_value(arg, "type")
1972 or string.match(arg, "%f[%w]type%s?%=%s?[%w%s]+%,") 1974 tein = get_attr_value(arg, "n")
1973 or "" 1975 teihead = get_attr_value(arg, "head")
1974 teitype = string.gsub(teitype, "type%s?%=%s?(%b{})", function(bbraces) 1976 teidepth = get_attr_value(arg, "depth")
1975 bbraces = string.sub(bbraces, 2, -2)
1976 return string.format("%s", bbraces)
1977 end)
1978 teitype = string.gsub(teitype, "(type%s?%=%s?)([%w%s]+)(%,)", "%2")
1979 --
1980 tein = string.match(arg, "%f[%w]n%s?%=%s?%b{}")
1981 or string.match(arg, "%f[%w]n%s?%=%s?[%w%s]+%,")
1982 or ""
1983 tein = string.gsub(tein, "n%s?%=%s?(%b{})", function(bbraces)
1984 bbraces = string.sub(bbraces, 2, -2)
1985 return string.format("%s", bbraces)
1986 end)
1987 tein = string.gsub(tein, "(n%s?%=%s?)([%w%s]+)(%,)", "%2")
1988 --
1989 teihead = string.match(arg, "%f[%w]head%s?%=%s?%b{}")
1990 or string.match(arg, "%f[%w]head%s?%=%s?[%w%s]+%,")
1991 or ""
1992 teihead = string.gsub(teihead, "head%s?%=%s?(%b{})", function(bbraces)
1993 bbraces = string.sub(bbraces, 2, -2)
1994 return string.format("%s", bbraces)
1995 end)
1996 teihead = string.gsub(teihead, "(head%s?%=%s?)([%w%s]+)(%,)", "%2")
1997 --
1998 teidepth = string.match(arg, "%f[%w]depth%s?%=%s?%b{}")
1999 or string.match(arg, "%f[%w]depth%s?%=%s?[%w%s]+%,")
2000 or ""
2001 teidepth = string.gsub(teidepth, "depth%s?%=%s?(%b{})", function(bbraces)
2002 bbraces = string.sub(bbraces, 2, -2)
2003 return string.format("%s", bbraces)
2004 end)
2005 teidepth = string.gsub(teidepth, "(depth%s?%=%s?)([%w%s]+)(%,)", "%2")
2006 -- 1977 --
2007 return string.format("\\par <div type=\"%s\" n=\"%s\" depth=\"%s\"/><head>%s</head>", 1978 if teitype ~= "" then teitype = " type=\""..teitype.."\"" else end
1979 if tein ~= "" then tein = " n=\""..tein.."\"" else end
1980 if teidepth ~= "" then teidepth = " depth=\""..teidepth.."\"" else end
1981 return string.format("\\par <div%s%s%s/><head>%s</head>",
2008 teitype, tein, teidepth, teihead) 1982 teitype, tein, teidepth, teihead)
2009 else 1983 else
2010 return "" 1984 return ""