texlive[56294] Master: semantex (8sep20)

commits+karl at tug.org commits+karl at tug.org
Tue Sep 8 23:04:49 CEST 2020


Revision: 56294
          http://tug.org/svn/texlive?view=revision&revision=56294
Author:   karl
Date:     2020-09-08 23:04:49 +0200 (Tue, 08 Sep 2020)
Log Message:
-----------
semantex (8sep20)

Modified Paths:
--------------
    trunk/Master/tlpkg/libexec/ctan2tds

Added Paths:
-----------
    trunk/Master/texmf-dist/tex/latex/semantex/stripsemantex.lua

Removed Paths:
-------------
    trunk/Master/texmf-dist/doc/latex/semantex/stripsemantex.lua

Deleted: trunk/Master/texmf-dist/doc/latex/semantex/stripsemantex.lua
===================================================================
--- trunk/Master/texmf-dist/doc/latex/semantex/stripsemantex.lua	2020-09-07 23:54:39 UTC (rev 56293)
+++ trunk/Master/texmf-dist/doc/latex/semantex/stripsemantex.lua	2020-09-08 21:04:49 UTC (rev 56294)
@@ -1,212 +0,0 @@
--- aliases for protected environments
-local assert, io_open
-    = assert, io.open
-
--- load the ltn12 module
-local ltn12 = require("ltn12")
-
--- No more global accesses after this point
-if _VERSION == "Lua 5.2" then _ENV = nil end
-
--- copy a file
-copy_file = function(path_src, path_dst)
-  ltn12.pump.all(
-      ltn12.source.file(assert(io_open(path_src, "rb"))),
-      ltn12.sink.file(assert(io_open(path_dst, "wb")))
-    )
-end
-
-openFile = function(file)
- f = io.open(file, "r")
- filecontent = f:read("*all")
- local beginDocPosition = filecontent:find('\\begin{document}')
- if not beginDocPosition then
-	tex.sprint( [[\begingroup\ExplSyntaxOn
-		\msg_fatal:nnn { stripsemantex } { begin_document_not_found } { ]] .. file .. [[ }
-		\endgroup]] )
-	return
- end
- precontent = filecontent:sub(1,beginDocPosition-1)
- content = filecontent:sub(beginDocPosition,-1)
- f:close()
-end
-
-closeFile = function(file)
- f = io.open(file, "w")
- f:write(precontent .. content)
- f:close()
-end
-
-removeStricttexFormatting = function(str)
-	-- We do this in case the package "stricttex" was used
-	str = str:gsub('numberZERO','0')
-	str = str:gsub('numberONE','1')
-	str = str:gsub('numberTWO','2')
-	str = str:gsub('numberTHREE','3')
-	str = str:gsub('numberFOUR','4')
-	str = str:gsub('numberFIVE','5')
-	str = str:gsub('numberSIX','6')
-	str = str:gsub('numberSEVEN','7')
-	str = str:gsub('numberEIGHT','8')
-	str = str:gsub('numberNINE','9')
-	str = str:gsub('symbolPRIME','\'')
-	return str
-end
-
-addIDsToRegisters = function(str)
-	str = removeStricttexFormatting(str)
-	content = content:gsub('\\' .. str .. '%f[^%a]' ,'\\SemantexIDcommand{}\\' .. str)
-end
-
-removeSuperfluousIDs = function()
-	content = content:gsub('parent(%s*)=(%s*)\\SemantexIDcommand{}','parent%1=%2')
-	content = content:gsub('class(%s*)=(%s*)\\SemantexIDcommand{}','class%1=%2')
-	content = content:gsub('clone(%s*)=(%s*)\\SemantexIDcommand{}','clone%1=%2')
-	content = content:gsub('copy(%s*)=(%s*)\\SemantexIDcommand{}','copy%1=%2')
-	content = content:gsub('\\New(%w+)Class(%s*{?)\\SemantexIDcommand{}','\\New%1Class%2')
-	content = content:gsub('\\NewObject(%s*{?%s*)\\SemantexIDcommand{}(\\%w+%s*}?%s*{?%s*)\\SemantexIDcommand{}', '\\NewObject%1%2')
-	content = content:gsub('\\SetupClass(%s*{?%s*)\\SemantexIDcommand{}', '\\SetupClass%1')
-	content = content:gsub('\\SetupObject(%s*{?%s*)\\SemantexIDcommand{}', '\\SetupObject%1')
-end
-
-addNumbersToIDs = function()
-	local n = 1	
-	local p,q = string.find(content,'\\SemantexIDcommand{}')
-	while q do
-		content = content:sub(1,q-1) .. n .. content:sub(q,-1)
-		p, q = string.find(content,'\\SemantexIDcommand{}')	
-		n = n + 1
-	end
-end
-
-semantexIDluacommand = function(id, source, output)
-	local p, q = string.find(content, '\\SemantexIDcommand{' .. id .. '}')
-	
-	while p do
-		content = content:sub(1,p-1) .. content:sub(q+1,-1)
-		
-		source = source:gsub('%s+', '')
-		
-		-- We do this in case the package "stricttex" was used
-		source = removeStricttexFormatting(source)
-		
-		-- This is because #1's in the code becomes ##1
-		-- in the .semtex file.
-		source = source:gsub('#(%d)', '%1')
-		
-		local length = source:len()
-	
-		local i = 1
-		
-		local s
-		
-		while i <= length do
-			s = content:sub(p,p)
-			if s == source:sub(i,i) then
-				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)
-			elseif s == '%' then
-				content = content:sub(1 , p-1) .. content:sub(p,-1):gsub('%%.-\n','',1)
-			elseif s == '{' 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 = content:sub(p+q,p+q)
-					if e == '}' then
-						netto = netto - 1
-					elseif e == '{' then
-						netto = netto + 1
-					elseif e == '\\' then
-						q = q + 1
-					end
-				end
-				content = content:sub(1,p-1) .. content:sub(p+1,p+q-1) .. content:sub(p+q+1,-1)
-			else
-				tex.sprint( [[\begingroup\ExplSyntaxOn
-				\msg_fatal:nnnn { stripsemantex } { source_not_expected } { ]] .. source:sub(i,i) .. [[ } { ]] .. s  .. [[ }
-				\endgroup]] )
-				break
-			end
-		end
-		
-		
-		output = output:gsub('%s*\\sp {', '^{')
-		output = output:gsub('%s*\\sb {', '_{')
-		output = output:gsub('\\mathopen \\big ', '\\bigl')
-		output = output:gsub('\\mathclose \\big ', '\\bigr')
-		output = output:gsub('\\mathopen \\Big ', '\\Bigl')
-		output = output:gsub('\\mathclose \\Big ', '\\Bigr')
-		output = output:gsub('\\mathopen \\bigg ', '\\biggl')
-		output = output:gsub('\\mathclose \\bigg ', '\\biggr')
-		output = output:gsub('\\mathopen \\Bigg ', '\\Biggl')
-		output = output:gsub('\\mathclose \\Bigg ', '\\Biggr')
-		output = output:gsub('\\mathopen %(', '(')
-		output = output:gsub('\\mathclose %)', ')')
-		output = output:gsub('\\mathopen %[', '[')
-		output = output:gsub('\\mathclose %]', ']')
-		output = output:gsub('\\mathopen \\{', '\\{')
-		output = output:gsub('\\mathclose \\}', '\\}')
-		output = output:gsub('\\mathopen \\lbrace', '\\lbrace')
-		output = output:gsub('\\mathclose \\rbrace', '\\rbrace')
-		output = output:gsub('\\mathopen \\lbrack', '\\rbrack')
-		output = output:gsub('\\mathclose \\rbrack', '\\rbrack')
-		output = output:gsub('\\mathopen \\langle', '\\langle')
-		output = output:gsub('\\mathclose \\rangle', '\\rangle')
-		output = output:gsub('\\mathopen \\lvert', '\\rvert')
-		output = output:gsub('\\mathclose \\rvert', '\\rvert')
-		output = output:gsub('\\mathopen \\lVert', '\\rVert')
-		output = output:gsub('\\mathclose \\rVert', '\\rVert')
-		
-		output = output:gsub('%s+%f[{}%[%]%(%)%$,]','')
-		output = output:gsub('([}%]%)])%f[\\%w%+%-%(%[=]', '%1 ')
-		output = output:gsub(',',', ')
-		output = output:gsub('%s+$', '')
-		
-		
-		-- We now check whether the string we add will follow right
-		-- after a control sequence, causing it to be interpreted
-		-- as part of that control sequence.
-		-- Because we want to allow the user to use stricttex, we
-		-- check for alphanumerical control sequences rather than
-		-- just alphabetic ones. This could add spaces that
-		-- the user might not have intended, but it's a minor issue.
-		if output:sub(1,1):match('%w') and content:sub(1, p-1):match('\\%w+$') then
-			content = content:sub(1,p-1) .. ' ' .. output .. content:sub(p,-1)
-		else
-			content = content:sub(1,p-1) .. output .. content:sub(p,-1)
-		end
-		p, q = string.find(content, '\\SemantexIDcommand{' .. id .. '}')
-	end
-end
-
-stripRemainingSemantexIDs = function()
-	content = content:gsub('\\SemantexIDcommand{%d+}', '')
-end
-
-addSemtexPackageToFile = function()
-	content = [[% The following was added by "stripsemantex"
-
-\usepackage{semtex,leftindex,graphicx}
-
-\providecommand\SemantexLeft{%
-	\mathopen{}\mathclose\bgroup\left
-}
-
-\providecommand\SemantexRight{%
-	\aftergroup\egroup\right
-}
-
-\providecommand\SemantexBullet{%
-	\raisebox{-0.25ex}{\scalebox{1.2}{$\cdot$}}%
-}
-\providecommand\SemantexDoubleBullet{%
-	\SemantexBullet\SemantexBullet
-}
-
-]] .. content
-end
\ No newline at end of file

Added: trunk/Master/texmf-dist/tex/latex/semantex/stripsemantex.lua
===================================================================
--- trunk/Master/texmf-dist/tex/latex/semantex/stripsemantex.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/semantex/stripsemantex.lua	2020-09-08 21:04:49 UTC (rev 56294)
@@ -0,0 +1,212 @@
+-- aliases for protected environments
+local assert, io_open
+    = assert, io.open
+
+-- load the ltn12 module
+local ltn12 = require("ltn12")
+
+-- No more global accesses after this point
+if _VERSION == "Lua 5.2" then _ENV = nil end
+
+-- copy a file
+copy_file = function(path_src, path_dst)
+  ltn12.pump.all(
+      ltn12.source.file(assert(io_open(path_src, "rb"))),
+      ltn12.sink.file(assert(io_open(path_dst, "wb")))
+    )
+end
+
+openFile = function(file)
+ f = io.open(file, "r")
+ filecontent = f:read("*all")
+ local beginDocPosition = filecontent:find('\\begin{document}')
+ if not beginDocPosition then
+	tex.sprint( [[\begingroup\ExplSyntaxOn
+		\msg_fatal:nnn { stripsemantex } { begin_document_not_found } { ]] .. file .. [[ }
+		\endgroup]] )
+	return
+ end
+ precontent = filecontent:sub(1,beginDocPosition-1)
+ content = filecontent:sub(beginDocPosition,-1)
+ f:close()
+end
+
+closeFile = function(file)
+ f = io.open(file, "w")
+ f:write(precontent .. content)
+ f:close()
+end
+
+removeStricttexFormatting = function(str)
+	-- We do this in case the package "stricttex" was used
+	str = str:gsub('numberZERO','0')
+	str = str:gsub('numberONE','1')
+	str = str:gsub('numberTWO','2')
+	str = str:gsub('numberTHREE','3')
+	str = str:gsub('numberFOUR','4')
+	str = str:gsub('numberFIVE','5')
+	str = str:gsub('numberSIX','6')
+	str = str:gsub('numberSEVEN','7')
+	str = str:gsub('numberEIGHT','8')
+	str = str:gsub('numberNINE','9')
+	str = str:gsub('symbolPRIME','\'')
+	return str
+end
+
+addIDsToRegisters = function(str)
+	str = removeStricttexFormatting(str)
+	content = content:gsub('\\' .. str .. '%f[^%a]' ,'\\SemantexIDcommand{}\\' .. str)
+end
+
+removeSuperfluousIDs = function()
+	content = content:gsub('parent(%s*)=(%s*)\\SemantexIDcommand{}','parent%1=%2')
+	content = content:gsub('class(%s*)=(%s*)\\SemantexIDcommand{}','class%1=%2')
+	content = content:gsub('clone(%s*)=(%s*)\\SemantexIDcommand{}','clone%1=%2')
+	content = content:gsub('copy(%s*)=(%s*)\\SemantexIDcommand{}','copy%1=%2')
+	content = content:gsub('\\New(%w+)Class(%s*{?)\\SemantexIDcommand{}','\\New%1Class%2')
+	content = content:gsub('\\NewObject(%s*{?%s*)\\SemantexIDcommand{}(\\%w+%s*}?%s*{?%s*)\\SemantexIDcommand{}', '\\NewObject%1%2')
+	content = content:gsub('\\SetupClass(%s*{?%s*)\\SemantexIDcommand{}', '\\SetupClass%1')
+	content = content:gsub('\\SetupObject(%s*{?%s*)\\SemantexIDcommand{}', '\\SetupObject%1')
+end
+
+addNumbersToIDs = function()
+	local n = 1	
+	local p,q = string.find(content,'\\SemantexIDcommand{}')
+	while q do
+		content = content:sub(1,q-1) .. n .. content:sub(q,-1)
+		p, q = string.find(content,'\\SemantexIDcommand{}')	
+		n = n + 1
+	end
+end
+
+semantexIDluacommand = function(id, source, output)
+	local p, q = string.find(content, '\\SemantexIDcommand{' .. id .. '}')
+	
+	while p do
+		content = content:sub(1,p-1) .. content:sub(q+1,-1)
+		
+		source = source:gsub('%s+', '')
+		
+		-- We do this in case the package "stricttex" was used
+		source = removeStricttexFormatting(source)
+		
+		-- This is because #1's in the code becomes ##1
+		-- in the .semtex file.
+		source = source:gsub('#(%d)', '%1')
+		
+		local length = source:len()
+	
+		local i = 1
+		
+		local s
+		
+		while i <= length do
+			s = content:sub(p,p)
+			if s == source:sub(i,i) then
+				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)
+			elseif s == '%' then
+				content = content:sub(1 , p-1) .. content:sub(p,-1):gsub('%%.-\n','',1)
+			elseif s == '{' 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 = content:sub(p+q,p+q)
+					if e == '}' then
+						netto = netto - 1
+					elseif e == '{' then
+						netto = netto + 1
+					elseif e == '\\' then
+						q = q + 1
+					end
+				end
+				content = content:sub(1,p-1) .. content:sub(p+1,p+q-1) .. content:sub(p+q+1,-1)
+			else
+				tex.sprint( [[\begingroup\ExplSyntaxOn
+				\msg_fatal:nnnn { stripsemantex } { source_not_expected } { ]] .. source:sub(i,i) .. [[ } { ]] .. s  .. [[ }
+				\endgroup]] )
+				break
+			end
+		end
+		
+		
+		output = output:gsub('%s*\\sp {', '^{')
+		output = output:gsub('%s*\\sb {', '_{')
+		output = output:gsub('\\mathopen \\big ', '\\bigl')
+		output = output:gsub('\\mathclose \\big ', '\\bigr')
+		output = output:gsub('\\mathopen \\Big ', '\\Bigl')
+		output = output:gsub('\\mathclose \\Big ', '\\Bigr')
+		output = output:gsub('\\mathopen \\bigg ', '\\biggl')
+		output = output:gsub('\\mathclose \\bigg ', '\\biggr')
+		output = output:gsub('\\mathopen \\Bigg ', '\\Biggl')
+		output = output:gsub('\\mathclose \\Bigg ', '\\Biggr')
+		output = output:gsub('\\mathopen %(', '(')
+		output = output:gsub('\\mathclose %)', ')')
+		output = output:gsub('\\mathopen %[', '[')
+		output = output:gsub('\\mathclose %]', ']')
+		output = output:gsub('\\mathopen \\{', '\\{')
+		output = output:gsub('\\mathclose \\}', '\\}')
+		output = output:gsub('\\mathopen \\lbrace', '\\lbrace')
+		output = output:gsub('\\mathclose \\rbrace', '\\rbrace')
+		output = output:gsub('\\mathopen \\lbrack', '\\rbrack')
+		output = output:gsub('\\mathclose \\rbrack', '\\rbrack')
+		output = output:gsub('\\mathopen \\langle', '\\langle')
+		output = output:gsub('\\mathclose \\rangle', '\\rangle')
+		output = output:gsub('\\mathopen \\lvert', '\\rvert')
+		output = output:gsub('\\mathclose \\rvert', '\\rvert')
+		output = output:gsub('\\mathopen \\lVert', '\\rVert')
+		output = output:gsub('\\mathclose \\rVert', '\\rVert')
+		
+		output = output:gsub('%s+%f[{}%[%]%(%)%$,]','')
+		output = output:gsub('([}%]%)])%f[\\%w%+%-%(%[=]', '%1 ')
+		output = output:gsub(',',', ')
+		output = output:gsub('%s+$', '')
+		
+		
+		-- We now check whether the string we add will follow right
+		-- after a control sequence, causing it to be interpreted
+		-- as part of that control sequence.
+		-- Because we want to allow the user to use stricttex, we
+		-- check for alphanumerical control sequences rather than
+		-- just alphabetic ones. This could add spaces that
+		-- the user might not have intended, but it's a minor issue.
+		if output:sub(1,1):match('%w') and content:sub(1, p-1):match('\\%w+$') then
+			content = content:sub(1,p-1) .. ' ' .. output .. content:sub(p,-1)
+		else
+			content = content:sub(1,p-1) .. output .. content:sub(p,-1)
+		end
+		p, q = string.find(content, '\\SemantexIDcommand{' .. id .. '}')
+	end
+end
+
+stripRemainingSemantexIDs = function()
+	content = content:gsub('\\SemantexIDcommand{%d+}', '')
+end
+
+addSemtexPackageToFile = function()
+	content = [[% The following was added by "stripsemantex"
+
+\usepackage{semtex,leftindex,graphicx}
+
+\providecommand\SemantexLeft{%
+	\mathopen{}\mathclose\bgroup\left
+}
+
+\providecommand\SemantexRight{%
+	\aftergroup\egroup\right
+}
+
+\providecommand\SemantexBullet{%
+	\raisebox{-0.25ex}{\scalebox{1.2}{$\cdot$}}%
+}
+\providecommand\SemantexDoubleBullet{%
+	\SemantexBullet\SemantexBullet
+}
+
+]] .. content
+end
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/tex/latex/semantex/stripsemantex.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/tlpkg/libexec/ctan2tds
===================================================================
--- trunk/Master/tlpkg/libexec/ctan2tds	2020-09-07 23:54:39 UTC (rev 56293)
+++ trunk/Master/tlpkg/libexec/ctan2tds	2020-09-08 21:04:49 UTC (rev 56294)
@@ -2103,6 +2103,7 @@
  'sdaps',	'\.dict$|code128|' . $standardtex,
  'sduthesis',	'figures|' . $standardtex,
  'selnolig',    '\.lua|' . $standardtex,
+ 'semantex',	'\.lua|' . $standardtex,
  'seminar',     '\.bug|\.bg2|\.cls|\.sty|2up.tex',
  'shade',       'shade\.tex',  # not description.tex
  'shortmathj',	'shortmathj\.sty',
@@ -2117,7 +2118,6 @@
  'spotcolor',   'spotcolor.*\.tex|' . $standardtex,
  'startex',     '\.(tex|stx|lan)$',
  'stricttex',	'\.lua|' . $standardtex,
- 'subfig',      '\.sty|[^c]\.cfg',      # not ltxdoc.cfg, would be system-wide
  'subfigure',   '\.sty|[^c]\.cfg',      # not ltxdoc.cfg, would be system-wide
  'syntax',      'syntax\.tex',
  'systeme',     '^systeme\.tex$|' . $standardtex,



More information about the tex-live-commits mailing list.