summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/semantex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-09-09 20:57:07 +0000
committerKarl Berry <karl@freefriends.org>2020-09-09 20:57:07 +0000
commit736754172b88861049bf28a4e4b381af4f42a4af (patch)
treed3bdb4c75ec4600f21a0611d8d96bc7cb5b6d098 /Master/texmf-dist/tex/latex/semantex
parent080e671e46f4a5c2997b53c4f689ccd0d97703e6 (diff)
semantex (9sep20)
git-svn-id: svn://tug.org/texlive/trunk@56304 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/semantex')
-rw-r--r--Master/texmf-dist/tex/latex/semantex/semantex.sty2
-rw-r--r--Master/texmf-dist/tex/latex/semantex/semtex.sty83
-rw-r--r--Master/texmf-dist/tex/latex/semantex/stripsemantex.lua38
-rw-r--r--Master/texmf-dist/tex/latex/semantex/stripsemantex.sty14
4 files changed, 132 insertions, 5 deletions
diff --git a/Master/texmf-dist/tex/latex/semantex/semantex.sty b/Master/texmf-dist/tex/latex/semantex/semantex.sty
index c2ca6e552b9..2da252301b4 100644
--- a/Master/texmf-dist/tex/latex/semantex/semantex.sty
+++ b/Master/texmf-dist/tex/latex/semantex/semantex.sty
@@ -1,5 +1,5 @@
\RequirePackage{xparse,l3keys2e,semtex,leftindex}
-\ProvidesExplPackage{semantex}{2020/09/07}{0.4beta}{}
+\ProvidesExplPackage{semantex}{2020/09/08}{0.41beta}{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
diff --git a/Master/texmf-dist/tex/latex/semantex/semtex.sty b/Master/texmf-dist/tex/latex/semantex/semtex.sty
new file mode 100644
index 00000000000..3b9196c3613
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/semantex/semtex.sty
@@ -0,0 +1,83 @@
+\RequirePackage{xparse}
+\ProvidesExplPackage{semtex}{2020/07/29}{0.1beta}{}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% semtex -- for documents stripped of SemanTeX markup %
+% https://ctan.org/pkg/semantex %
+% (C) 2020 Sebastian Ørsted %
+% sorsted@gmail.com %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% Bullets:
+
+\box_new:N \g__semantex_bullet_box
+\hbox_set:Nn \g__semantex_bullet_box { $\cdot$ }
+\box_scale:Nnn \g__semantex_bullet_box {1.2} {1.2}
+\tl_set:Nn\g_semantex_bullet
+{
+ \box_move_up:nn{-0.25ex}{\box_use:N \g__semantex_bullet_box}
+}
+
+\tl_set:Nn\g_semantex_double_bullet{\g_semantex_bullet \g_semantex_bullet}
+
+\tl_set_eq:NN\SemantexBullet \g_semantex_bullet
+
+\tl_set_eq:NN \SemantexDoubleBullet \g_semantex_double_bullet
+
+
+% Parentheses:
+
+\cs_new:Npn\SemantexLeft { \mathopen{}\mathclose\bgroup\left }
+
+\cs_new:Npn\SemantexRight { \aftergroup\egroup\right }
+
+\tl_new:N\SemantexDelimiterSize
+
+\DeclareDocumentCommand\SemantexParentheses { mmmm }
+{
+ \str_case:nnF { #1 } % This is where \big,\Big, etc. go.
+ {
+ { normal } {
+ \group_begin:
+ \tl_clear:N \SemantexDelimiterSize
+ \str_if_eq:nnF { #2 } { . } { \mathopen #2 }
+ #4
+ \str_if_eq:nnF { #3 } { . } { \mathclose #3 }
+ \group_end:
+ }
+ { auto } {
+ \group_begin:
+ \tl_set_eq:NN \SemantexDelimiterSize \middle
+ \SemantexLeft #2
+ #4
+ \SemantexRight #3
+ \group_end:
+ }
+ { * } {
+ \group_begin:
+ \tl_set_eq:NN \SemantexDelimiterSize \middle
+ \SemantexLeft #2
+ #4
+ \SemantexRight #3
+ \group_end:
+ }
+ }
+ {
+ \group_begin:
+ \tl_set_eq:NN\SemantexDelimiterSize #1
+ \mathopen #1 #2
+ #4
+ \mathclose #1 #3
+ \group_end:
+ }
+}
+
+\DeclareDocumentCommand\SemantexNoParentheses { m }
+{
+ \group_begin:
+ \tl_clear:N\SemantexDelimiterSize
+ #1
+ \group_end:
+} \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/semantex/stripsemantex.lua b/Master/texmf-dist/tex/latex/semantex/stripsemantex.lua
index 769d5b05516..ba3eb9f2dac 100644
--- a/Master/texmf-dist/tex/latex/semantex/stripsemantex.lua
+++ b/Master/texmf-dist/tex/latex/semantex/stripsemantex.lua
@@ -55,7 +55,12 @@ end
addIDsToRegisters = function(str)
str = removeStricttexFormatting(str)
- content = content:gsub('\\' .. str .. '%f[^%a]' ,'\\SemantexIDcommand{}\\' .. str)
+ content = content:gsub('\\' .. str .. '([^%a])' ,'\\SemantexIDcommand{}\\' .. str .. '%1')
+ -- '%f[^%a]' does not work here, as it will not react if the last character of str is a number,
+ -- which stricttex allows.
+ -- Because of this choice, there will be an issue if you use stricttex and let
+ -- \<command> by a SemanTeX command and \<command>' be a non-SemanTeX command.
+ -- So simply *don't do that*.
end
removeSuperfluousIDs = function()
@@ -106,7 +111,7 @@ semantexIDluacommand = function(id, source, output)
content = content:sub(1 , p-1) .. content:sub(p+1, -1)
i = i + 1
elseif s:match('%s') then
- content = content:sub(1, p-1) .. content:sub (p+1, -1)
+ content = content:sub(1, p-1) .. content:sub(p+1, -1)
elseif s == '%' then
content = content:sub(1 , p-1) .. content:sub(p,-1):gsub('%%.-\n','',1)
elseif s == '{' then
@@ -123,9 +128,38 @@ semantexIDluacommand = function(id, source, output)
netto = netto + 1
elseif e == '\\' then
q = q + 1
+ elseif e == '%' then
+ content = content:sub(1, p+q-1) .. content:sub(p+q,-1):gsub('%%.-\n','',1)
+ q = q - 1
end
end
content = content:sub(1,p-1) .. content:sub(p+1,p+q-1) .. content:sub(p+q+1,-1)
+ elseif s == '<' and content:sub(p+1,p+2) == '[>' then
+ content = content:sub(1,p-1) .. content:sub(p+3,-1)
+ i = i + 1
+ elseif s == '<' and content:sub(p+1,p+2) == ']>' then
+ content = content:sub(1,p-1) .. content:sub(p+3,-1)
+ i = i + 1
+ elseif source:sub(i,i) == '{' then
+ -- In this case, we remove the corresponding right brace,
+ -- once we find it
+ local netto = 1 -- The current brace group level
+ local q = 0 -- The position we have moved forward so far
+ while netto > 0 do
+ q = q + 1
+ local e = source:sub(i+q,i+q)
+ if e == '}' then
+ netto = netto - 1
+ elseif e == '{' then
+ netto = netto + 1
+ elseif e == '\\' then
+ q = q + 1
+ -- there is no chance that the source contains a %, so we do not
+ -- check for this
+ end
+ end
+ source = source:sub(1,i-1) .. source:sub(i+1,i+q-1) .. source:sub(i+q+1,-1)
+ length = source:len()
else
tex.sprint( [[\begingroup\ExplSyntaxOn
\msg_fatal:nnnn { stripsemantex } { source_not_expected } { ]] .. source:sub(i,i) .. [[ } { ]] .. s .. [[ }
diff --git a/Master/texmf-dist/tex/latex/semantex/stripsemantex.sty b/Master/texmf-dist/tex/latex/semantex/stripsemantex.sty
index eba56386248..96c40fdb873 100644
--- a/Master/texmf-dist/tex/latex/semantex/stripsemantex.sty
+++ b/Master/texmf-dist/tex/latex/semantex/stripsemantex.sty
@@ -1,4 +1,5 @@
-\ProvidesExplPackage{stripsemantex}{2020/09/07}{0.1alpha}{}
+\RequirePackage{xparse}
+\ProvidesExplPackage{stripsemantex}{2020/09/05}{0.1alpha}{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
@@ -66,7 +67,16 @@
openFile('\lua_escape:e{#1}_stripped.tex')
}
- \cs_set:Npn\SemantexID##1\BeginSource##2\EndSource\BeginOutput##3\EndOutput
+ \DeclareDocumentCommand\SemantexID{ m t{\BeginSource} }
+ {
+ \IfBooleanT{##2}
+ {
+ \strip_semantex_id_command:w ##1 \BeginSource
+ }
+ }
+
+
+ \cs_set:Npn\strip_semantex_id_command:w##1\BeginSource##2\EndSource\BeginOutput##3\EndOutput
{
\lua_now:e
{