diff options
author | Norbert Preining <norbert@preining.info> | 2021-08-15 03:00:39 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2021-08-15 03:00:39 +0000 |
commit | 8e38006fd2e220c3a27208477dab7abbf7256370 (patch) | |
tree | d63fa0168a10601bb6a10a1e3684ed25e52a68c9 /indexing/xindex/scripts | |
parent | 769e7ba80785adf6ccb03041b687fcd0253e9371 (diff) |
CTAN sync 202108150300
Diffstat (limited to 'indexing/xindex/scripts')
-rw-r--r-- | indexing/xindex/scripts/xindex-yannis.lua | 262 | ||||
-rwxr-xr-x | indexing/xindex/scripts/xindex.lua | 93 |
2 files changed, 60 insertions, 295 deletions
diff --git a/indexing/xindex/scripts/xindex-yannis.lua b/indexing/xindex/scripts/xindex-yannis.lua deleted file mode 100644 index 2ef45e4360..0000000000 --- a/indexing/xindex/scripts/xindex-yannis.lua +++ /dev/null @@ -1,262 +0,0 @@ ------------------------------------------------------------------------ --- FILE: xindex-yannis.lua --- DESCRIPTION: configuration file for xindex.lua --- REQUIREMENTS: --- AUTHOR: Herbert Voß --- LICENSE: LPPL1.3 --- --- $Id: xindex-yannis.lua 4 2021-07-07 07:25:04Z hvoss $ ------------------------------------------------------------------------ - -if not modules then modules = { } end modules ['xindex-yannis'] = { - version = 0.30, - comment = "main configuration to xindex.lua", - author = "Herbert Voss", - copyright = "Herbert Voss", - license = "LPPL 1.3" -} - -itemPageDelimiter = "," -- Hello, 14 -compressPages = true -- something like 12--15, instaead of 12,13,14,15. the |( ... |) syntax is still valid -fCompress = false -- 3f -> page 3, 4 and 3ff -> page 3, 4, 5 -minCompress = 2 -- 14--17 or -rangeSymbol = "-" -- 14-17 instead of -- -numericPage = true -- for non numerical pagenumbers, like "VI-17" -sublabels = {"", "-\\,", "--\\,", "---\\,"} -- for the (sub(sub(sub-items first one is for item -pageNoPrefixDel = "" -- a delimiter for page numbers like "VI-17" -- not used !!! -indexOpening = "" -- commands after \begin{theindex} -idxnewletter = "\\textbf" -- Only valid if -n is not set - - ---[[ - Each character's position in this array-like table determines its 'priority'. - Several characters in the same slot have the same 'priority'. -]] -alphabet_lower = { -- for sorting - { 'α', 'ά', 'ὰ', 'ᾶ', 'ἀ', 'ἄ', 'ἂ', 'ἆ', 'ἁ', 'ἅ', 'ἃ', 'ἇ', 'ᾳ', 'ᾴ', 'ᾲ', 'ᾷ', 'ᾀ', 'ᾄ', 'ᾂ', 'ᾆ', 'ᾁ', 'ᾅ', 'ᾃ', 'ᾇ' }, - { 'β', 'ϐ' }, - { 'γ' }, - { 'δ' }, - { 'ε', 'έ', 'ὲ', 'ἐ', 'ἔ', 'ἒ', 'ἑ', 'ἕ', 'ἓ' }, - { 'ζ' }, - { 'η', 'ή', 'ὴ', 'ῆ', 'ἠ', 'ἤ', 'ἢ', 'ἦ', 'ἡ', 'ἥ', 'ἣ', 'ἧ', 'ῃ', 'ῄ', 'ῂ', 'ῇ', 'ᾐ', 'ᾔ', 'ᾒ', 'ᾖ', 'ᾑ', 'ᾕ', 'ᾓ', 'ᾗ' }, - { 'θ' }, - { 'ι', 'ί', 'ὶ', 'ῖ', 'ἰ', 'ἴ', 'ἲ', 'ἶ', 'ἱ', 'ἵ', 'ἳ', 'ἷ', 'ϊ', 'ΐ', 'ῒ', 'ῗ' }, - { 'κ' }, - { 'λ' }, - { 'μ' }, - { 'ν' }, - { 'ξ' }, - { 'ο', 'ό', 'ὸ', 'ὀ', 'ὄ', 'ὂ', 'ὁ', 'ὅ', 'ὃ' }, - { 'π' }, - { 'ρ' }, - { 'σ', 'ς' }, - { 'τ' }, - { 'υ', 'ύ', 'ὺ', 'ῦ', 'ὐ', 'ὔ', 'ὒ', 'ὖ', 'ὑ', 'ὕ', 'ὓ', 'ὗ', 'ϋ', 'ΰ', 'ῢ', 'ῧ' }, - { 'φ' }, - { 'χ' }, - { 'ψ' }, - { 'ω', 'ώ', 'ὼ', 'ῶ', 'ὠ', 'ὤ', 'ὢ', 'ὦ', 'ὡ', 'ὥ', 'ὣ', 'ὧ', 'ῳ', 'ῴ', 'ῲ', 'ῷ', 'ᾠ', 'ᾤ', 'ᾢ', 'ᾦ', 'ᾡ', 'ᾥ', 'ᾣ', 'ᾧ' }, - { 'a', 'á', 'à', 'ä', 'å', 'æ', }, - { 'b' }, - { 'c', 'ç' }, - { 'd' }, - { 'e', 'é', 'è', 'ë' }, - { 'f' }, - { 'g' }, - { 'h' }, - { 'i', 'í', 'ì', 'ï' }, - { 'j' }, - { 'k' }, - { 'l' }, - { 'm' }, - { 'n', 'ñ' }, - { 'o', 'ó', 'ò', 'ö', 'ø', 'œ'}, - { 'p' }, - { 'q' }, - { 'r' }, - { 's', 'š', 'ß' }, - { 't' }, - { 'u', 'ú', 'ù', 'ü' }, - { 'v' }, - { 'w' }, - { 'x' }, - { 'y', 'ý', 'ÿ' }, - { 'z', 'ž' }, - { 'а' }, - { 'б' }, - { 'в' }, - { 'г', 'ѓ' }, - { 'д' }, - { 'е', 'ё' }, - { 'ж' }, - { 'з' }, - { 'и', 'і' }, - { 'й' }, - { 'к' }, - { 'л' }, - { 'м' }, - { 'н' }, - { 'о' }, - { 'п' }, - { 'р' }, - { 'с' }, - { 'т' }, - { 'у' }, - { 'ф' }, - { 'х' }, - { 'ц' }, - { 'ч' }, - { 'ш' }, - { 'щ' }, - { 'ъ' }, - { 'ы' }, - { 'ь' }, - { 'э' }, - { 'ю' }, - { 'я' }, -} -alphabet_upper = { -- for sorting - { 'Α', 'Ά', 'Ἀ', 'Ἄ', 'Ἂ', 'Ἆ', 'Ἁ', 'Ἅ', 'Ἃ', 'Ἇ', 'ᾼ', 'ᾈ', 'ᾌ', 'ᾊ', 'ᾎ', 'ᾉ', 'ᾍ', 'ᾋ', 'ᾏ' }, - { 'Β' }, - { 'Γ' }, - { 'Δ' }, - { 'Ε', 'Έ', 'Ἐ', 'Ἔ', 'Ἒ', 'Ἑ', 'Ἕ', 'Ἓ' }, - { 'Ζ' }, - { 'Η', 'Ή', 'Ἠ', 'Ἤ', 'Ἢ', 'Ἦ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З' }, - { 'И', 'І' }, - { 'Й' }, - { 'К' }, - { 'Л' }, - { 'М' }, - { 'Н' }, - { 'О' }, - { 'П' }, - { 'Р' }, - { 'С' }, - { 'Т' }, - { 'У' }, - { 'Ф' }, - { 'Х' }, - { 'Ц' }, - { 'Ч' }, - { 'Ш' }, - { 'Щ' }, - { 'Ъ' }, - { 'Ы' }, - { 'Ь' }, - { 'Э' }, - { 'Ю' }, - { 'Я' }, -} - - -function SORTendhook(list) - print ("We have "..#list.." total list entries") - local greek = {} - local latin = {} - local cyrillic = {} - local symbols = {} - local numbers = {} - local others = {} - local firstChar, charType - local firstCharNumber - local v - for i=1,#list do - v = list[i] - firstChar = NormalizedUppercase(utf.sub(v["sortChar"],1,1)) - v["sortChar"] = firstChar -- to be sure it is an uppercase unicode char - firstCharNumber = string.utfvalue(firstChar) - charType = getCharType(firstChar) --- print (utf.sub(v["sortChar"],1,1).."->"..firstChar.." ("..firstCharNumber..") ".." ("..charType..")") - if charType == 0 then - symbols[#symbols+1] = v - elseif charType == 1 then - numbers[#numbers+1] = v - elseif firstCharNumber > 0x052F then -- 0x052F is last cyrillic character - others[#others+1] = v - elseif firstCharNumber >= 0x0400 then -- 0x0400-0x052F cyrillic characters - cyrillic[#cyrillic+1] = v - elseif firstCharNumber <= 0x03FF then -- 0x03FF is last greek character - if firstCharNumber >= 0x0370 then - greek[#greek+1] = v -- 0x0370-0x03FF greek characters - elseif firstCharNumber <= 0x024F then - if firstCharNumber >= 0x041 then -- 0x041-0x024F latin character - latin[#latin+1] = v - else - others[#others+1] = v -- everything else - end - end - end - end - print ("We have "..#greek.." Greek entries") - print ("We have "..#latin.." Latin entries") - print ("We have "..#cyrillic.." Cyrillic entries") - print ("We have "..#symbols.." Symbol entries") - print ("We have "..#numbers.." Number entries") - print ("We have "..#others.." other entries") - list = {} - for i = 1,#greek do list[#list+1] = greek[i] end - list[#list]["Macro"] = "\\vspace{1cm}" - for i = 1,#latin do list[#list+1] = latin[i] end - list[#list]["Macro"] = "\\vspace{1cm}" - for i = 1,#cyrillic do list[#list+1] = cyrillic[i] end - list[#list]["Macro"] = "\\vspace{1cm}" - for i = 1,#symbols do list[#list+1] = symbols[i] end - for i = 1,#numbers do list[#list+1] = numbers[i] end - for i = 1,#others do list[#list+1] = others[i] end - print ("Sorted "..#list.." entries") - return list -end - diff --git a/indexing/xindex/scripts/xindex.lua b/indexing/xindex/scripts/xindex.lua index fdcbfb2172..3a9655c61d 100755 --- a/indexing/xindex/scripts/xindex.lua +++ b/indexing/xindex/scripts/xindex.lua @@ -6,11 +6,11 @@ -- AUTHOR: Herbert Voß -- LICENSE: LPPL 1.3 -- --- $Id: xindex.lua 4 2021-07-07 07:25:04Z hvoss $ +-- $Id: xindex.lua 10 2021-08-14 07:50:17Z hvoss $ ----------------------------------------------------------------------- xindex = xindex or { } - local version = 0.30 + local version = 0.31 xindex.version = version --xindex.self = "xindex" @@ -32,13 +32,13 @@ Report bugs to kpse.set_program_name("luatex") local f = kpse.find_file("lualibs.lua") -print ("filename "..f) +--print ("filename "..f) + require("lualibs") -- all part of LuaTeX require('unicode') require('string') require("lpeg") - local args = require ('xindex-lapp') [[ parameter handling -q,--quiet @@ -53,10 +53,10 @@ local args = require ('xindex-lapp') [[ -l,--language (default en) -p,--prefix (default L) -u,--use_UCA - <input> (string) + -s,--use_stdin + <files...> (default stdin) .idx file(s) ]] - --[[ No -v flag, v is just { false }. not args.v[1] is true, so vlevel becomes 0. One -v flags, v is { true } @@ -76,6 +76,8 @@ if (luaVersion < "Lua 5.3") then os.exit() end +useStdInput = args["use_stdin"] + --local inspect = require 'inspect' --print(inspect(args)) @@ -91,46 +93,70 @@ be no log file created. end ]] - ---[[ -if not args["input"] then - io.write ("Filename: ") - inFile = io.read() -else - inFile = args["input"] +require('xindex-baselib') + +local nInFiles = #args.files +if not useStdInput then + --print(tostring(nInFiles).." input files are given!") + inFiles = {} --args.files as strings + for i = 1,nInFiles do + local file = args.files_name[i] +-- test for extension is in xindex-lapp +-- if not file_exists(file) then +-- if file_exists(file..".idx") then +-- inFiles[#inFiles+1] = file..".idx" +-- else +-- print("Inputfile "..file.." or "..file..".idx not found!\n") +-- end +-- else + inFiles[#inFiles+1] = file +-- end + end end -]] -require('xindex-lib') - -inFile = args["input"] -if not file_exists(inFile) then - if file_exists(inFile..".idx") then - inFile = inFile..".idx" - else - writeLog(2,"Inputfile "..inFile.." or "..inFile..".idx not found!\n",0) - os.exit() - end -end +-- print ("Check Logfile:") local filename -local logfilename +logfilename = "" + if args["output"] == '""' then - if inFile:sub(inFile:len()-3,inFile:len()) == ".idx" then - filename = inFile:sub(1,inFile:len()-3).."ind" - logfilename = inFile:sub(1,inFile:len()-3).."ilg" + if not useStdInput then + if inFiles[1]:sub(inFiles[1]:len()-3,inFiles[1]:len()) == ".idx" then + filename = inFiles[1]:sub(1,inFiles[1]:len()-3).."ind" + if nInFiles > 1 then + logfilename = "xindex.ilg" + else + logfilename = inFiles[1]:sub(1,inFiles[1]:len()-3).."ilg" + end + else + filename = inFiles[1]..".ind" + if nInFiles > 1 then + logfilename = "xindex.ilg" + else + logfilename = inFiles[1]..".ilg" + end + end else - filename = inFile..".ind" - logfilename = inFile..".ilg" + filename = "xindex.ind" + logfilename = "xindex.ilg" end else filename = args.output - logfilename = filename:gsub('%p...','')..".ilg" + if nInFiles > 1 or useStdInput then + logfilename = "xindex.ilg" + else + logfilename = filename:gsub('%p...','')..".ilg" + end end + + logFile = io.open(logfilename,"w+") +require('xindex-lib') + writeLog(2,"xindex v."..version.." (c) Herbert Voß\n",-1) writeLog(1,"Verbose level = "..vlevel.."\n",1) +writeLog(2,"Logfile:",logfilename,1) writeLog(2,"Open outputfile "..filename,0) outFile = io.open(filename,"w+") @@ -147,7 +173,7 @@ if vlevel > 0 then writeLog(1,"---------- parameter ----------\n",1) end -writeLog(2,"Using input file: "..inFile.."\n",0) +-- writeLog(2,"Using input file: "..inFile.."\n",0) labelPrefix = args.prefix writeLog(2,"Label prefix: "..labelPrefix.."\n",-1) @@ -254,6 +280,7 @@ outFile = io.open(filename,"w+") writeLog(2,"... done\n",0) writeLog(1,"Starting base file ... \n",2) + BaseRunFile = kpse.find_file("xindex-base.lua") dofile(BaseRunFile) |