aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2021-04-16 08:33:02 +0200
committerRobert Alessi <alessi@robertalessi.net>2021-04-16 08:33:02 +0200
commita150a011bb28e5728aa95534403bb43d026a6a41 (patch)
treeb8610310b70a5d09fb19aca0ac2533146fc718a2
parent29db848e5028b0bae1171dd54f0adc4e05adf7e0 (diff)
downloadekdosis-a150a011bb28e5728aa95534403bb43d026a6a41.tar.gz
improved \TeXtoTEIPat
-rw-r--r--ekdosis.dtx39
-rw-r--r--ekdosis.el4
2 files changed, 36 insertions, 7 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index c9161cc..5efc419 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -5872,6 +5872,14 @@ many mathematical writings and to the sense of
5872% strings captured are inserted where each of them is expected in 5872% strings captured are inserted where each of them is expected in
5873% the \texttt{TEI} element. 5873% the \texttt{TEI} element.
5874% 5874%
5875% \danger If the entire string to be captured be enclosed in square or
5876% curly brackets, it is advisable to use |@b|\texttt{\emph{n}} (for
5877% curly brackets) or |@s|\texttt{\emph{n}} (for square brackets)
5878% instead of |#|\texttt{\emph{n}}, where \texttt{\emph{n}} is the the
5879% number that is expected in the sequence. This will prevent any
5880% brackets that may be found in the captured string from being
5881% interpreted.
5882%
5875% \danger Strings must be entered exactly as \pkg{ekdosis} will find 5883% \danger Strings must be entered exactly as \pkg{ekdosis} will find
5876% them as the |.tex| source file is compiled. Specifically, 5884% them as the |.tex| source file is compiled. Specifically,
5877% \emph{control sequences}, namely the coded commands immediately 5885% \emph{control sequences}, namely the coded commands immediately
@@ -5886,14 +5894,22 @@ many mathematical writings and to the sense of
5886% \iffalse 5894% \iffalse
5887%<*example> 5895%<*example>
5888% \fi 5896% \fi
5889\begin{minted}[linenos=false]{latex} 5897\begin{minted}[linenos]{latex}
5890\TeXtoTEIPat{\textcolor␣{#1}{#2}}{<hi rend="#1">#2</hi>} 5898\TeXtoTEIPat{\textcolor␣{#1}@b2}{<hi rend="#1">@b2</hi>}
5891 5899
5892Sample text with a \textcolor{red}{word} in red. 5900Sample text with a \textcolor{red}{word} in red.
5893\end{minted} 5901\end{minted}
5894% \iffalse 5902% \iffalse
5895%</example> 5903%</example>
5896% \fi 5904% \fi
5905%
5906% \begin{remarks}
5907% \item[\textsc{Rem.}] As can be seen from l.~1, it is safe to use
5908% |#1| for the first string for color names are naturally formed of
5909% letters without braces. However, |@b2| is preferable to capture
5910% the whole second argument of \cs{textcolor} for it may contain
5911% words within braces.
5912% \end{remarks}
5897% 5913%
5898% \iffalse 5914% \iffalse
5899%<*example> 5915%<*example>
@@ -9203,7 +9219,7 @@ end
9203 9219
9204local function checkxmlid(str) 9220local function checkxmlid(str)
9205 if string.find(str, "^[0-9]") 9221 if string.find(str, "^[0-9]")
9206 or string.find(str, "[:; ]") 9222 or string.find(str, "[%{%}%[%]%(%):; ]")
9207 then 9223 then
9208 return false 9224 return false
9209 else 9225 else
@@ -9515,16 +9531,17 @@ local texpatttotags = {
9515 {a="\\pagebreak%s+%[[1-4]%]", b=""}, 9531 {a="\\pagebreak%s+%[[1-4]%]", b=""},
9516 {a="\\pagebreak%s+", b=""}, 9532 {a="\\pagebreak%s+", b=""},
9517 {a="\\altrfont%s+", b=""}, 9533 {a="\\altrfont%s+", b=""},
9518 {a="\\mbox%s+{(.-)}", b="%1"}, 9534 {a="\\mbox%s+(%b{})", b="ekd@ob%1ekd@cb"},
9519 {a="\\LR%s+{(.-)}", b="%1"}, 9535 {a="\\LR%s+(%b{})", b="ekd@ob%1ekd@cb"},
9520 {a="\\RL%s+{(.-)}", b="%1"}, 9536 {a="\\RL%s+(%b{})", b="ekd@ob%1ekd@cb"},
9521 {a="\\%=%=%=%s?", b="—"}, 9537 {a="\\%=%=%=%s?", b="—"},
9522 {a="\\%-%-%-%s?", b="—"}, 9538 {a="\\%-%-%-%s?", b="—"},
9523 {a="\\%=%=%s?", b="–"}, 9539 {a="\\%=%=%s?", b="–"},
9524 {a="\\%-%-%s?", b="–"}, 9540 {a="\\%-%-%s?", b="–"},
9525 {a="\\%=%/%s?", b="‐"}, 9541 {a="\\%=%/%s?", b="‐"},
9526 {a="\\%-%/%s?", b="‐"}, 9542 {a="\\%-%/%s?", b="‐"},
9527 {a="\\vin%s+", b=""} 9543 {a="\\vin%s+", b=""},
9544 {a="\\uc%s+(%b{})", b="ekd@ob%1ekd@cb"}
9528} 9545}
9529 9546
9530local envtotags = { 9547local envtotags = {
@@ -9568,8 +9585,12 @@ end
9568 9585
9569function ekdosis.newpatttotag(pat, repl) 9586function ekdosis.newpatttotag(pat, repl)
9570 pat = string.gsub(pat, "([%[%]])", "%%%1") 9587 pat = string.gsub(pat, "([%[%]])", "%%%1")
9588 pat = string.gsub(pat, "%@b[1-9]", "(%%b{})")
9589 pat = string.gsub(pat, "%@s[1-9]", "(%%b[])")
9571 pat = string.gsub(pat, "%#[1-9]", "(.-)") 9590 pat = string.gsub(pat, "%#[1-9]", "(.-)")
9572 repl = string.gsub(repl, "%#([1-9])", "%%%1") 9591 repl = string.gsub(repl, "%#([1-9])", "%%%1")
9592 repl = string.gsub(repl, "%@b([1-9])", "ekd@ob%%%1ekd@cb")
9593 repl = string.gsub(repl, "%@s([1-9])", "ekd@os%%%1ekd@cs")
9573 if isintable(texpatttotags, pat) 9594 if isintable(texpatttotags, pat)
9574 then 9595 then
9575 local index = get_a_index(pat, texpatttotags) 9596 local index = get_a_index(pat, texpatttotags)
@@ -9892,6 +9913,10 @@ end
9892local function texpatttotei(str) 9913local function texpatttotei(str)
9893 for i = 1,#texpatttotags do 9914 for i = 1,#texpatttotags do
9894 str = string.gsub(str, texpatttotags[i].a, texpatttotags[i].b) 9915 str = string.gsub(str, texpatttotags[i].a, texpatttotags[i].b)
9916 str = string.gsub(str, "ekd@ob%{", "")
9917 str = string.gsub(str, "%}ekd@cb", "")
9918 str = string.gsub(str, "ekd@os%[", "")
9919 str = string.gsub(str, "%]ekd@cs", "")
9895 end 9920 end
9896 return str 9921 return str
9897end 9922end
diff --git a/ekdosis.el b/ekdosis.el
index 1df3fd3..f1d40b0 100644
--- a/ekdosis.el
+++ b/ekdosis.el
@@ -56,6 +56,8 @@
56 56
57(defvar LaTeX-ekdosis-lem-options 57(defvar LaTeX-ekdosis-lem-options
58 '(("wit") 58 '(("wit")
59 ("source")
60 ("resp")
59 ("alt") 61 ("alt")
60 ("pre") 62 ("pre")
61 ("post") 63 ("post")
@@ -68,6 +70,8 @@
68 70
69(defvar LaTeX-ekdosis-rdg-options 71(defvar LaTeX-ekdosis-rdg-options
70 '(("wit") 72 '(("wit")
73 ("source")
74 ("resp")
71 ("alt") 75 ("alt")
72 ("pre") 76 ("pre")
73 ("post") 77 ("post")