diff options
Diffstat (limited to 'indexing/xindex')
-rw-r--r-- | indexing/xindex/CHANGELOG | 3 | ||||
-rw-r--r-- | indexing/xindex/doc/xindex-doc.pdf | bin | 580513 -> 586790 bytes | |||
-rw-r--r-- | indexing/xindex/doc/xindex-doc.tex | 261 | ||||
-rw-r--r-- | indexing/xindex/lualatex/xindex-AU.lua | 2 | ||||
-rw-r--r-- | indexing/xindex/lualatex/xindex-HAdW-eKO.lua | 2 | ||||
-rw-r--r-- | indexing/xindex/lualatex/xindex-RU.lua | 2 | ||||
-rw-r--r-- | indexing/xindex/lualatex/xindex-base.lua | 35 | ||||
-rw-r--r-- | indexing/xindex/lualatex/xindex-baselib.lua | 2 | ||||
-rw-r--r-- | indexing/xindex/lualatex/xindex-cfg-common.lua | 2 | ||||
-rw-r--r-- | indexing/xindex/lualatex/xindex-cfg-uca.lua | 2 | ||||
-rw-r--r-- | indexing/xindex/lualatex/xindex-cfg.lua | 2 | ||||
-rw-r--r-- | indexing/xindex/lualatex/xindex-danteedition.lua | 2 | ||||
-rw-r--r-- | indexing/xindex/lualatex/xindex-dtk.lua | 2 | ||||
-rw-r--r-- | indexing/xindex/lualatex/xindex-lib.lua | 86 | ||||
-rw-r--r-- | indexing/xindex/lualatex/xindex-norsk.lua | 2 | ||||
-rw-r--r-- | indexing/xindex/lualatex/xindex-pretty.lua | 2 | ||||
-rw-r--r-- | indexing/xindex/lualatex/xindex-yannis.lua | 2 | ||||
-rwxr-xr-x | indexing/xindex/scripts/xindex.lua | 32 |
18 files changed, 265 insertions, 176 deletions
diff --git a/indexing/xindex/CHANGELOG b/indexing/xindex/CHANGELOG index e7718d89ab..076944be3c 100644 --- a/indexing/xindex/CHANGELOG +++ b/indexing/xindex/CHANGELOG @@ -1,3 +1,6 @@ +0.53 2023-07-16 - added function literize to escape special lua characters + for gsub and xindex's escape character +0.52 2023-07-12 - fix for special escape characters 0.51 2023-07-10 - change \parenLeft|Right to \braceLeft|Right - added option for a fix for hyperref if using "| 0.50 2023-07-08 - fix for introduced bug diff --git a/indexing/xindex/doc/xindex-doc.pdf b/indexing/xindex/doc/xindex-doc.pdf Binary files differindex aae3e08927..dc94cd75cb 100644 --- a/indexing/xindex/doc/xindex-doc.pdf +++ b/indexing/xindex/doc/xindex-doc.pdf diff --git a/indexing/xindex/doc/xindex-doc.tex b/indexing/xindex/doc/xindex-doc.tex index 0c5974e046..62240e6037 100644 --- a/indexing/xindex/doc/xindex-doc.tex +++ b/indexing/xindex/doc/xindex-doc.tex @@ -37,7 +37,7 @@ \gdef\DoubleperCent{%%} } -\usepackage{xcolor,fancyvrb,varioref} +\usepackage{xcolor,fancyvrb,varioref,awesomebox} \usepackage{xltabular} \usepackage{hvlogos} % for Wikipedia W \usepackage{listings} @@ -81,7 +81,7 @@ \def\setVersion#1{\setVVersion#1!!} \def\setVVersion#1=#2!!{\def\xIndexVersion{#2}} -\setVersion{version = 0.51}% can be automatically changed by perl +\setVersion{version = 0.53}% can be automatically changed by perl @@ -95,7 +95,8 @@ \tableofcontents \clearpage -\bgroup\raggedright +\begin{noteblock} +\raggedright Thanks to: \\ Mark Baudoin; Denis Bitouzé; @@ -104,7 +105,7 @@ Brian Dunn; Gonzalo Pesquero Serrano; Michal Hoftich; Mykel Kochenderfer; -Alexey Kuznetzov; +Alexey Kuznetsov; Frank Mittelbach; Peter Müller; Heiko Oberdiek; @@ -114,12 +115,12 @@ Florent Rougon; Martin Sievers; Simon Spiegel; Jürgen Spitzmüller; -\egroup +\end{noteblock} \clearpage \section{Introduction} The Lua program -\XI is a \Index{unicode} aware program for creating an index file from an \Lext{idx} source +\XI is a \Index{unicode} aware program for creating an index (\Lext{ind}) file from an \Lext{idx} source file. It is completely compatible to the current \Lprog{makeindex} program, but can handle \Index{UTF-8}, 16, 32, and 64. The \LaTeX\ package \Lpack{xindex} is a package which provides a \LaTeX\ command which writes additional text into the index file. This text (comments and/or macros) @@ -173,30 +174,32 @@ xindex [-q,--quiet ] [-h,--help ] [-v ] verbose + [-V,--version ] + [-a,--no_casesensitive ] default is false + [-b,--no_labels ] default is false [-c,--config ] default is cfg [-e,--escapechar ] default is " - [-a, --no_casesensitive ] default is false - [-b,--no_labels ] default is false - [-n,--noheadings ] default is false + [-f,--fix_hyperref ] default is false + [-g,--no_pagenumber] default is false [-i,--ignoreSpace ] default is false - [-o,--output ] default is <input>.ind [-k,--checklang ] default ist false [-l,--language ] default is en - [-g,--no_pagenumber] default is false + [-n,--noheadings ] default is false + [-o,--output ] default is <input>.ind [-p,--prefix] default L - [-u,--use_UCA ] default is false [-s,--use_stdin ] default is false - [-V,--version ] + [-u,--use_UCA ] default is false <files...> (default stdin) file(s)[.idx] one or more files \end{verbatim} For example: -\begin{verbatim} -xindex -q -l fr -b myDoc -xindex -l de -c DIN2 demo1 demo2 demo3 +\begin{noteblock} +\ttfamily +xindex -q -l fr -b myDoc \newline +xindex -l de -c DIN2 demo1 demo2 demo3\newline xindex -c norsk -o index.ind demo1 demo2.bdx demo3.adx -\end{verbatim} +\end{noteblock} \begin{enumerate} \item \texttt{-q}: quiet; \texttt{-l fr}: french language setting; \texttt{-b}: no labels; \texttt{myDoc}: input data \texttt{myDoc} or \texttt{myDoc.idx)\newline @@ -211,17 +214,18 @@ xindex -c norsk -o index.ind demo1 demo2.bdx demo3.adx It is also possible to use standard input for the index data, which needs the \verb|-s| parameter: -\begin{verbatim} +\begin{noteblock}\ttfamily cat myDoc.idx | xindex -q -l fr -b -s xindex -l de -c DIN2 < myDoc.idx -\end{verbatim} +\end{noteblock} - -The \Index{language} has to be chosen as an international abbreviation in lower- or uppercase letters, see +\begin{importantblock} +The \Index{language} has to be chosen as an international abbreviation in +lower- or uppercase letters, see \url{https://en.wikipedia.org/wiki/ISO_3166-2} - +\end{importantblock} \subsection{How it works} \XI creates by default an \Index{output} file \texttt{<input>.ind} which can be read @@ -233,13 +237,20 @@ is given by the configuration file, which defines replacements for \Index{accent like \texttt{ö}$\rightarrow$\texttt{o}. \subsection{The \texttt{.idx} file} -There are four characters which must be escaped if used in the command \Lcs{index}: -\verb=!=, \verb=@=, \verb="=, or \verb=|=. These characters have a special meaning for -the index.\index{"!}\index{"@}\index{"|} -The default \Index{escape character} is the double quote \verb|"|: +There are three (four) characters which must be escaped if used in the command \Lcs{index}: +\verb=!=, \verb=@=, or \verb=|= and the current escape character itself. +These characters have a special meaning for +the index.\index{"!}\index{"@}\index{"|} + +\begin{importantblock} +The default \Index{escape character} is the double quote \verb|"|. The braces +\texttt{\{} and \texttt{\}} cannot be used as argument for the command \Lcs{index}. +Use \Lcs{braceLeft} and \Lcs{braceRight} instead (defined in the package \Lpack{xindex}). +\end{importantblock} \iffalse -To put a !\index{"!}, @\index{"@}, or |\index{"|} character in an index entry, quote it by preceding the +To put a !\index{"!}, @\index{"@}, or |\index{"|} character in an index entry, +quote it by preceding the character with a quote ". More precisely, any character is said to be quoted if it follows an unquoted " that is not part of a \" command. A quoted !, @, or | character is treated like an ordinary character rather than having its usual @@ -353,19 +364,10 @@ For the German language the double quote is an active character and it makes lif if one chooses another character. The escape character can be changed easily by the optional argument \verb|-e "<char>"| or \verb|--escapechar "<char">|. The following example shows how -it works for the \Index{escape character} > (greater). Internally the escape sequences are -now defined as: - -\begin{verbatim} -escape_chars = { -- by default " is the escape char - {esc_char..'"', '//escapedquote//', '"' }, - {esc_char..'@', '//escapedat//', '@' }, - {esc_char..'|', '//escapedvert//', '|' }, - {esc_char..'!', '//scapedexcl//', '!' } -} -\end{verbatim} +it works for the \Index{escape character} »>« (greater). By default the expression »>!">« will +be a \TeX\ ligature with the output »>>«. %Internally the escape sequences are -which is, of course, not of interest for the user. With the beginning the escaped chars +With the beginning of \Lprog{xindex }the escaped chars are converted into the internal strings and later back to the origin meaning. The two characters \verb|{}| cannot be used as \verb|\{\}| inside the argument of \Lcs{index}. The package \Lpack{xindex} defines the two helper macros @@ -383,6 +385,7 @@ The following example shows how to use it: frame, compiler=lualatex, crop, + force=true, xindex, xindexOptions=-e ">", runs=2,code,docType=latex, @@ -407,8 +410,8 @@ The following example shows how to use it: \begin{itemize} \item Exclamation mark ! \index{exclaim (>!)} \item Vertical bar| \index{Vertical bar (>|)} -\item Doublequote \verb|"| \index{>"} -\item Double doublequote \verb|""| \index{>">"} +\item Escapechar \verb|>| \index{>>} +\item Double escapechar \verb|>>| \index{>>>>} \item At character @ \index{At (>@)} \item Group start \{ \index{\braceLeft} \item Group end \{ \index{\braceRight} @@ -425,9 +428,11 @@ Run \texttt{xindex} with \texttt{xindex -e ">"}\index{<file.idx>}\index{123} The \Index{language} is only important for the first two headers in the output of the index data. They are by default \emph{Symbols} followed by \emph{Numbers}. In a new version of \Lprog{xindex} it will be customizable. -The predefined language is »en« and currently the following languages which its alias are possible: +The predefined language is »en« and currently the following languages which its alias are defined: + \begin{Verbatim}[commandchars=\\<>] +<id> = {<symbols>, <numbers>, <alias language name>, ...} indexheader = { cs = {"Symboly", "Čísla", "czech"}, da = {"Symboler", "Tal", "danish"}, @@ -451,6 +456,7 @@ The following example was run with \verb|xindex -l it <file>.idx|: frame, compiler=lualatex, crop, + force=true, xindex, xindexOptions=-l it -e ">", runs=2,code,docType=latex, @@ -471,23 +477,25 @@ The following example was run with \verb|xindex -l it <file>.idx|: %StopVisiblePreamble \pagestyle{empty} \begin{document} -\section{Escaping characters with >} +\section{Escaping simboli con >} \begin{itemize} -\item Exclamation mark ! \index{exclaim (>!)} -\item Vertical bar| \index{Vertical bar (>|)} -\item Doublequote \verb|"| \index{>"} -\item Double doublequote \verb|""| \index{>">"} -\item At character @ \index{At (>@)} +\item punto esclamativo ! \index{exclaim (>!)} +\item linea verticale | \index{Vertical bar (>|)} +\item escapechar \verb|>| \index{>>} +\item doppio escapechar \verb|>>| \index{>>>>} +\item At siboli @ \index{At (>@)} \end{itemize} -Run \texttt{xindex} with \texttt{xindex -l it -e ">"}\index{123} +Initio \texttt{xindex} con \texttt{xindex -l it -e ">"}\index{123} \newpage \printindex \end{document} \end{externalDocument} -The following example was run with \verb|xindex -k <file>.idx|. In this case \verb|xindex| tries to detect the language from -the \Lfile{aux} file(s). This is only possible if package \Lpack{babel} or \Lpack{polyglossia} are used. +The following example was run with \verb|xindex -k <file>.idx|. +In this case \verb|xindex| tries to detect the language from +the \Lfile{aux} file(s). This is only possible if +package \Lpack{babel} or \Lpack{polyglossia} are used. \begin{externalDocument}[ % grfOptions={width=\dimexpr\linewidth-2\fboxsep-2\fboxrule}, @@ -495,6 +503,7 @@ the \Lfile{aux} file(s). This is only possible if package \Lpack{babel} or \Lpa frame, compiler=lualatex, crop, + force=true, xindex, xindexOptions=-k -e "?", runs=2,code,docType=latex, @@ -510,7 +519,7 @@ the \Lfile{aux} file(s). This is only possible if package \Lpack{babel} or \Lpa \let\item\@idxitem} \makeatother %StartVisiblePreamble -\usepackage[dutch]{babel} +\usepackage[dutch]{babel} % !!!! \usepackage{makeidx}\makeindex %StopVisiblePreamble \pagestyle{empty} @@ -519,12 +528,12 @@ the \Lfile{aux} file(s). This is only possible if package \Lpack{babel} or \Lpa \begin{itemize} \item Exclamation mark ! \index{exclaim (?!)} \item Vertical bar| \index{Vertical bar (?|)} -\item Doublequote \verb|"| \index{?"} -\item Double doublequote \verb|""| \index{?"?"} -\item At character @ \index{At (?@)} +\item Escapechar \verb|?| \index{??} +\item Double escapechar \verb|??| \index{????} +\item At character @ \index{At (?@)}\index{?@} \end{itemize} Run \texttt{xindex} with \texttt{xindex -k -e "?"}\index{123} -\newpage +\newpage\index{xindex@\texttt{xindex}} \printindex \end{document} \end{externalDocument} @@ -865,6 +874,9 @@ The following runs with \verb|xindex -l jp <file>|: \end{externalDocument} %\end{minipage} + +\setsansfont{Libertinus Sans}\rmfamily + \subsection{Sorting by using UCA (Unicode Collation Algorithm)} With the optional argument \verb|-u| or alternatively \verb|--use_UCA| the sorting will be done by Michal Hoftich's Lua package \texttt{LUA-UCA}, which should be part of any \TeX{} installation. @@ -874,6 +886,20 @@ on how to do it and what languages are supported so far. Any additional code set UCA should be don't in the file \Lfile{xindex-cfg-uca.lua}, which will automatically be read by \Lprog{xindex}. +\iffalse +\begin{noteblock} +This package can display, in a +\begin{itemize} + \item to change dimensions and colors ; +\end{itemize} +It's +\end{noteblock} +\fi +\begin{importantblock} +If possible, you should use the Unicode sorting by default and only for some special cases +where you define your own sorting scheme, you should not use the \verb|-u| option. +\end{importantblock} + \begin{externalDocument}[ % grfOptions={width=\dimexpr\linewidth-2\fboxsep-2\fboxrule}, @@ -1151,8 +1177,11 @@ folium = { crop, xindex, xindexOptions=-l fr, - runs=2,code,docType=latex, + runs=2, + code,docType=latex, showFilename, +% runsequence={lualatex,{xindex -l fr},lualatex,lualatex}, +% shellesc=false, align=\centering, lstOptions={columns=fixed}]{xindex} %! lualatex @@ -1202,6 +1231,7 @@ of the same type, so we get \texttt{1f} in the output. frame=false, compiler=lualatex, crop, + force=true, xindex, xindexOptions=-l de, runs=2,code,docType=latex, @@ -1263,6 +1293,7 @@ envStop = "\\end{description}" frame=true, compiler=lualatex, verbose, + shellesc, % xindex, % xindexOptions=-c description -g, runs=2, @@ -1270,7 +1301,7 @@ envStop = "\\end{description}" force=true, %xindex -c description -n -g xindex-17.idx %xindex -c description -n --no_pagenumber gls.idx - runsequence={lualatex,{xindex -c description -n -g},lualatex,lualatex} +% runsequence={lualatex,{xindex -c description -n -g},lualatex,lualatex}, showFilename, align=\centering, grfOptions={width=0.45\linewidth}, @@ -1733,6 +1764,65 @@ Sorted with \verb|-l DE| +The following example fixes a problem with \Lpack{hyperref} and escaping the | character, +e.g.\verb/"|/. In such a case \Lpack{hyperref} ignores the vertical bar. +With the optional parameter \verb/-f | --fix_hyperref/, which is still experimental, +\Lprog{xindex} tries to fix this problem. However, instead +of using this problematic vertical character, you can use \Lcs{textbar}, which also solves the +problem. + + +\begin{externalDocument}[ +% grfOptions={width=\dimexpr\linewidth-2\fboxsep-2\fboxrule}, +% mpwidth=0.55\linewidth, + pages={3}, + frame=false, + compiler=lualatex, + crop, + force=true, + shellesc, +% xindex, +% xindexOptions=-, + runs=2,code,docType=latex, + showFilename, + align=\centering, +% grfOptions={width=\linewidth}, + lstOptions={columns=fixed}]{xindex} +%! lualatex --shell-escape +\documentclass{article} +\usepackage{libertinus} +\let\NewPage\newpage% only for demo +\makeatletter +\renewcommand\newpage{\NewPage\let\ps@plain\ps@empty} +\makeatother +%StartVisiblePreamble +\usepackage[imakeidx]{xindex} +\usepackage{hvindex} +\makeindex[columns=5, columnsep=6pt, options=--fix_hyperref] +\usepackage{hyperref} +%StopVisiblePreamble +\pagestyle{empty} +\begin{document} + Symbols:\\ + ! \index{"!} " \index{""} \# \index{#@\#} \$ \index{$@\$} + \% \index{%@\%} \& \index{&@\&} ' \index{'} ) \index{)} + ( \index{(} * \index{*} + \index{+} , \index{,@,\,} + - \index{-} . \index{.} / \index{/} : \index{:} + ; \index{;} < \index{<} = \index{=} > \index{>} + ? \index{?} @ \index{"@} [ \index{[} ] \index{]} + \_ \index{_@\_} ` \index{`} | \index{\textbar} + \newpage\index{"|}\index{\textbar}\index{123}\Index{Post} + \{ \index{\braceLeft} \} \index{\braceRight} + \textbackslash \index{\@\textbackslash} + \textasciicircum \index{^@\textasciicircum} + \textasciitilde \index{~@\textasciitilde} + Alphabet: \Index{Z},\Index{Zeppelin}\Index{Foo}\dots + \Index{...@\ldots} + \printindex +\end{document} +\end{externalDocument} + + \section{Including \LaTeX\ commands into the \Lext{idx} file} The command \Lcs{addtocontents} doesn't work for the index file. With the \LaTeX\ package @@ -2194,7 +2284,7 @@ Test \index{A!Test} oder auch \index{B!Test} \end{externalDocument} -\clearpage +%\clearpage \begin{externalDocument}[ @@ -2231,59 +2321,6 @@ Foo\index{foo!bar2!baz2} \end{document} \end{externalDocument} -The following example fixes a problem with \Lpack{hyperref} and escaping the | character - - -\begin{externalDocument}[ -% grfOptions={width=\dimexpr\linewidth-2\fboxsep-2\fboxrule}, -% mpwidth=0.55\linewidth, - pages={3}, - frame=false, - compiler=lualatex, - crop, - force=true, - shellesc, -% xindex, -% xindexOptions=-, - runs=2,code,docType=latex, - showFilename, - align=\centering, -% grfOptions={width=\linewidth}, - lstOptions={columns=fixed}]{xindex} -%! lualatex --shell-escape -\documentclass{article} -\usepackage{libertinus} -\let\NewPage\newpage% only for demo -\makeatletter -\renewcommand\newpage{\NewPage\let\ps@plain\ps@empty} -\makeatother -%StartVisiblePreamble -\usepackage[imakeidx]{xindex} -\usepackage{hvindex} -\makeindex[columns=4, columnsep=6pt, options=--fix_hyperref] -\usepackage[unicode]{hyperref} -%StopVisiblePreamble -\pagestyle{empty} -\begin{document} - Symbols:\\ - ! \index{"!} " \index{""} \# \index{#@\#} \$ \index{$@\$} - \% \index{%@\%} \& \index{&@\&} ' \index{'} ) \index{)} - ( \index{(} * \index{*} + \index{+} , \index{,@,\,} - - \index{-} . \index{.} / \index{/} : \index{:} - ; \index{;} < \index{<} = \index{=} > \index{>} - ? \index{?} @ \index{"@} [ \index{[} ] \index{]} - \_ \index{_@\_} ` \index{`} | \index{\textbar} - \newpage\index{"|}\index{123}\Index{Post} - \{ \index{\braceLeft} \} \index{\braceRight} - \textbackslash \index{\@\textbackslash} - \textasciicircum \index{^@\textasciicircum} - \textasciitilde \index{~@\textasciitilde} - Alphabet: \Index{Z},\Index{Zeppelin}\Index{Foo}\dots - \Index{...@\ldots} - \printindex -\end{document} -\end{externalDocument} - \printindex \end{document} diff --git a/indexing/xindex/lualatex/xindex-AU.lua b/indexing/xindex/lualatex/xindex-AU.lua index 19044b88c3..dac09700b3 100644 --- a/indexing/xindex/lualatex/xindex-AU.lua +++ b/indexing/xindex/lualatex/xindex-AU.lua @@ -9,7 +9,7 @@ ----------------------------------------------------------------------- if not modules then modules = { } end modules ['xindex-AU'] = { - version = 0.51, + version = 0.53, comment = "configuration to xindex.lua", author = "Herbert Voss", copyright = "Herbert Voss", diff --git a/indexing/xindex/lualatex/xindex-HAdW-eKO.lua b/indexing/xindex/lualatex/xindex-HAdW-eKO.lua index bb1155ac63..9f38541db4 100644 --- a/indexing/xindex/lualatex/xindex-HAdW-eKO.lua +++ b/indexing/xindex/lualatex/xindex-HAdW-eKO.lua @@ -11,7 +11,7 @@ -- configuration for index files of the Heidelberger Akademie der Wissenschaften if not modules then modules = { } end modules ['xindex-HAdW-eKO'] = { - version = 0.51, + version = 0.53, comment = "configuration to xindex.lua", author = "Herbert Voss", copyright = "Herbert Voss", diff --git a/indexing/xindex/lualatex/xindex-RU.lua b/indexing/xindex/lualatex/xindex-RU.lua index 8c52732d94..462f672adf 100644 --- a/indexing/xindex/lualatex/xindex-RU.lua +++ b/indexing/xindex/lualatex/xindex-RU.lua @@ -9,7 +9,7 @@ ----------------------------------------------------------------------- if not modules then modules = { } end modules ['xindex-RU'] = { - version = 0.51, + version = 0.53, comment = "configuration to xindex.lua", author = "Alexey Kuznetzov", copyright = "Herbert Voß", diff --git a/indexing/xindex/lualatex/xindex-base.lua b/indexing/xindex/lualatex/xindex-base.lua index 0999421e4d..98e2d3dd43 100644 --- a/indexing/xindex/lualatex/xindex-base.lua +++ b/indexing/xindex/lualatex/xindex-base.lua @@ -8,7 +8,7 @@ -- $Id: xindex-base.lua 22 2022-02-07 12:18:15Z hvoss $ ----------------------------------------------------------------------- -local info = { version = 0.51 } +local info = { version = 0.53 } -- check config if pageNoPrefixDel ~= "" then @@ -49,16 +49,16 @@ end writeLog(1,"check for hyperpages ... ",0) hyperpage, lines = checkHyperpage(lines) -- hyperref used? -writeLog(1,"done \n",0) +--writeLog(1,"done \n",0) if hyperpage then writeLog(1,"We have hyperpages.\n",1) end print("Presort of \\indexentry lines") -- for _,l in pairs(lines) do print (l) end table.sort(lines) -if vlevel > 1 then - print("Pre-Sorted index list:") - for _,l in pairs(lines) do print (l) end -end +--if vlevel > 1 then + --print("Pre-Sorted index list:") + --for _,l in pairs(lines) do print (l) end +--end if vlevel > 1 then writeLog(1,"--------------- Input data (presorted) -----------------\n",2) @@ -74,11 +74,15 @@ local noPagefound writeLog(1,"Change escape chars with macros ... \n",0) for k,v in ipairs(lines) do + --print("(k,v) ",k,v) if not commandEntry(v) then + --print() + --print(require 'xindex-pretty'.dump(escape_chars)) -- only for internal dump + --print() for i, str0 in ipairs(escape_chars) do -- str0: esc-char, coded, char --- print(str0[1],str0[2],v) - v = string.gsub(v,str0[1],str0[2]) --- print("==> "..v) + if i < 5 then + v,changed = v:gsub(literalize(str0[1]),str0[2]) -- some chars must be escaped + end end if k < #lines then if commandEntry(lines[k+1]) then -- is the next line not a \indexentry ? @@ -177,14 +181,11 @@ if use_UCA then writeLog(2,"done\n",0) else for i=1, #NewIndex do - v = NewIndex[i] - if findStr(v["SortKey"],"\\braceLeft") < 2 then v["SortKey"] = '{' v["sortChar"] = '{'end - if findStr(v["SortKey"],"\\braceRight") < 2 then v["SortKey"] = '}' end - if findStr(v["SortKey"],"//escapedexcl//") < 2 then v["SortKey"] = '!' end - if findStr(v["SortKey"],"//escapedquote//") < 2 then v["SortKey"] = '"' end - if findStr(v["SortKey"],"//escapedat//") < 2 then v["SortKey"] = '@' end - if findStr(v["SortKey"],"//escapedvert//") < 2 then v["SortKey"] = '|' end - NewIndex[i] = v + if NewIndex[i]["SortKey"] ~= nil then + for _,w in pairs(escape_chars) do + NewIndex[i]["SortKey"] = NewIndex[i]["SortKey"]:gsub(w[2], w[3]) + end + end end end diff --git a/indexing/xindex/lualatex/xindex-baselib.lua b/indexing/xindex/lualatex/xindex-baselib.lua index 645e0a9c2e..2085262bbd 100644 --- a/indexing/xindex/lualatex/xindex-baselib.lua +++ b/indexing/xindex/lualatex/xindex-baselib.lua @@ -9,7 +9,7 @@ ----------------------------------------------------------------------- if not modules then modules = { } end modules ['xindex-baselib'] = { - version = 0.51, + version = 0.53, comment = "base library to xindex.lua", author = "Herbert Voss", copyright = "Herbert Voss", diff --git a/indexing/xindex/lualatex/xindex-cfg-common.lua b/indexing/xindex/lualatex/xindex-cfg-common.lua index 76a1cead18..f1b43f5201 100644 --- a/indexing/xindex/lualatex/xindex-cfg-common.lua +++ b/indexing/xindex/lualatex/xindex-cfg-common.lua @@ -9,7 +9,7 @@ ----------------------------------------------------------------------- if not modules then modules = { } end modules ['xindex-cfg-common'] = { - version = 0.51, + version = 0.53, comment = "configuration to xindex.lua", author = "Herbert Voss", copyright = "Herbert Voss", diff --git a/indexing/xindex/lualatex/xindex-cfg-uca.lua b/indexing/xindex/lualatex/xindex-cfg-uca.lua index c55ffde269..8af9967fa1 100644 --- a/indexing/xindex/lualatex/xindex-cfg-uca.lua +++ b/indexing/xindex/lualatex/xindex-cfg-uca.lua @@ -9,7 +9,7 @@ ----------------------------------------------------------------------- if not modules then modules = { } end modules ['xindex-cfg-lua'] = { - version = 0.51, + version = 0.53, comment = "configuration to xindex-cfg-uca.lua", author = "Herbert Voss", copyright = "Herbert Voss", diff --git a/indexing/xindex/lualatex/xindex-cfg.lua b/indexing/xindex/lualatex/xindex-cfg.lua index f713d0c246..ad8d186300 100644 --- a/indexing/xindex/lualatex/xindex-cfg.lua +++ b/indexing/xindex/lualatex/xindex-cfg.lua @@ -9,7 +9,7 @@ ----------------------------------------------------------------------- if not modules then modules = { } end modules ['xindex-cfg'] = { - version = 0.51, + version = 0.53, comment = "main configuration to xindex.lua", author = "Herbert Voss", copyright = "Herbert Voss", diff --git a/indexing/xindex/lualatex/xindex-danteedition.lua b/indexing/xindex/lualatex/xindex-danteedition.lua index 61fad4027a..d5beaaf03a 100644 --- a/indexing/xindex/lualatex/xindex-danteedition.lua +++ b/indexing/xindex/lualatex/xindex-danteedition.lua @@ -9,7 +9,7 @@ ----------------------------------------------------------------------- if not modules then modules = { } end modules ['xindex-cfg'] = { - version = 0.51, + version = 0.53, comment = "configuration file for the DANTE Edition", author = "Herbert Voss", copyright = "Herbert Voss", diff --git a/indexing/xindex/lualatex/xindex-dtk.lua b/indexing/xindex/lualatex/xindex-dtk.lua index b50cc1f10a..0f9668b499 100644 --- a/indexing/xindex/lualatex/xindex-dtk.lua +++ b/indexing/xindex/lualatex/xindex-dtk.lua @@ -9,7 +9,7 @@ ----------------------------------------------------------------------- if not modules then modules = { } end modules ['xindex-cfg'] = { - version = 0.51, + version = 0.53, comment = "DTK configuration to xindex.lua", author = "Herbert Voss", copyright = "Herbert Voss", diff --git a/indexing/xindex/lualatex/xindex-lib.lua b/indexing/xindex/lualatex/xindex-lib.lua index 86b103823b..17d1c96d28 100644 --- a/indexing/xindex/lualatex/xindex-lib.lua +++ b/indexing/xindex/lualatex/xindex-lib.lua @@ -9,7 +9,7 @@ ----------------------------------------------------------------------- if not modules then modules = { } end modules ['xindex-lib'] = { - version = 0.51, + version = 0.53, comment = "main library to xindex.lua", author = "Herbert Voss", copyright = "Herbert Voss", @@ -97,6 +97,10 @@ function NormalizedChars(strOrig) -- return normalized UTF string (ä -> a) wit return table.concat(str) end +function literalize(s) -- escaping characters ( ) . % + - * ? [ ] ^ $ with % + return s:gsub("[%(%)%.%%%+%-%*%?%[%]%^%$]", function(c) return "%" .. c end) +end + -- local strOrigTrue = strOrig -- strOrig = table.concat(str) -- c = string.upper(get_normalized_char(alphabet_upper,utf.sub(strOrig,1,1))) @@ -238,6 +242,7 @@ function checkParenthesis(Entries) -- search for |( ... |) entries end function replaceVerticalChar(v) + --if not v then return v,"" end if not v:match('|') then return v,"" else @@ -549,6 +554,12 @@ function GenerateSortKey(a) else a["SortKey"] = A:match'^%s*(.*)' -- strip only left spaces end + for _,v in pairs(escape_chars) do + V2 = NormalizedUpper(v[2]) + V3 = NormalizedUpper(v[3]) + a["SortKey"] = a["SortKey"]:gsub(V2, V3) + end + -- print("-a:"..a["SortKey"]) else A = NormalizedChars(getSortString(a["Entry"].." "..Apage..a["pages"][1]["special"]):gsub('!',' ')) -- replace! by empty if ignoreSpace then @@ -556,15 +567,12 @@ function GenerateSortKey(a) else a["SortKey"] = A:match'^%s*(.*)' -- strip only left spaces end + -- print("-a:"..a["SortKey"]) + for _,v in pairs(escape_chars) do + a["SortKey"] = a["SortKey"]:gsub(v[2], v[3]) + end end -- s:gsub("%s+", "") strip spaces - if findStr(a["SortKey"],"\\braceLeft") < 2 then a["SortKey"] = '{ '..Apage end - if findStr(a["SortKey"],"\\braceRight") < 2 then a["SortKey"] = '} '..Apage end - if findStr(a["SortKey"],"//escapedexcl//") < 2 then a["SortKey"] = '! '..Apage end - if findStr(a["SortKey"],"//escapedquote//") < 2 then a["SortKey"] = '" '..Apage end - if findStr(a["SortKey"],"//escapedat//") < 2 then a["SortKey"] = '@ '..Apage end - if findStr(a["SortKey"],"//escapedvert//") < 2 then a["SortKey"] = '| '..Apage end --- if findStr(a["SortKey"],"\\textbar") < 2 then a["SortKey"] = '| '..Apage end -- a["SortKey"] = a["SortKey"]:gsub("%s+", "") if not use_UCA then -- test if it is a symbol after 9 and before A or after Z if (a["SortKey"]:byte() > 57 and a["SortKey"]:byte() < 65) or @@ -573,7 +581,7 @@ function GenerateSortKey(a) a["SortKey"] = "/"..a["SortKey"] -- sort it after / end end - -- print("Sortkey: " .. a["SortKey"]) + --print("Sortkey: " .. a["SortKey"]) end function GenerateSortKeys(Index) @@ -591,7 +599,7 @@ function UTFCompare(a,b) else compare = A<B end - writeLog(1,"UTFCompare: A--B "..A.."--"..B.."A<B:"..tostring(compare).."\n",2) + writeLog(1,"UTFCompare: "..A.."<"..B.." : "..tostring(compare).."\n",2) return compare end @@ -786,18 +794,54 @@ function checkHyperpage(lines) if fix_hyperref then writeLog(1,"fix vertical bar with hyperref ... ",0) -- hyperref ignores the vertical bar in "| and also other escape chars + -- + -- \index{"|} -> \indexentry{"|hyperpage}{1} -> \textbar|hyperpage + -- \index{foo"|bar} -> \indexentry{foo"|hyperindexformat{\bar}}{1} -> foo\textbar bar|hyperpage end - local sub_str = esc_char..'|hyperpage' + local sub_str0 = esc_char..'|hyperpage' + local sub_str1 = esc_char..'|hyperindexformat' for i=1,#lines do + local l = lines[i] if fix_hyperref then - s = lines[i]:find(sub_str) - print(i,lines[i],s) - if s == nil then s = 0 end - if s == 2 then - lines[i] = lines[i]:gsub(sub_str, '\\textbar|hyperpage') -- "| -> \textbar + s0 = l:find(sub_str0) -- test for hyperpage + s1 = l:find(esc_char..sub_str0) + --print(i,l,s0,s1) + if s0 == nil then + s0 = 0 + s1 = 0 + end + if s1 == nil and s0 > 0 then -- no ""| + l = l:gsub(sub_str0, '\\textbar|hyperpage') -- "| -> \textbar + else + -- part 2 + s0 = l:find(sub_str1) + s1 = l:find(esc_char..sub_str1) + --print(i,l,s0,s1) + if s0 == nil then + s0 = 0 + s1 = 0 + elseif s1 == nil then + s1 = 0 + end + if s1 == 0 and s0 > 0 then + -- get foo and bar from {foo"|hyperindexformat{\bar}} + items = l:gmatch("%{(.-)%}") + var = {} + for item in items do + var[#var+1] = item + end + if s0 > 2 then + u1 = var[1]:split('"|')[1] -- foo + else + u1 = '' + end + v1 = var[1]:split("\\")[2] -- bar + l = '{'..u1..'\\textbar '..v1.."|hyperpage}{"..var[2].."}" + -- l = foo"|bar -> foo\textbar bar + end end end - lines[i] = string.gsub(lines[i],'|?hyperpage}{','}{') + lines[i] = string.gsub(l,'|?hyperpage}{','}{') end -- for writeLog(1,"done\n",0) return true, lines @@ -825,7 +869,9 @@ function itemOutput(last, v, hyperpage) str = " \\item "..Entry.."\n" end for i, str0 in ipairs(escape_chars) do -- undo the escape char setting - str = str:gsub(str0[2],str0[3]) + if i < 5 then + str = str:gsub(str0[2],str0[3]) + end end outFile:write(str); indLines=indLines+1 lastItems = {} @@ -858,7 +904,9 @@ function itemOutput(last, v, hyperpage) end end for i, str0 in ipairs(escape_chars) do -- undo the escape char setting - str = string.gsub(str,str0[2],str0[3]) + if i < 5 then + str = string.gsub(str,str0[2],str0[3]) + end end outFile:write(str); indLines=indLines+1 else diff --git a/indexing/xindex/lualatex/xindex-norsk.lua b/indexing/xindex/lualatex/xindex-norsk.lua index a1ba73c436..4c54f533b1 100644 --- a/indexing/xindex/lualatex/xindex-norsk.lua +++ b/indexing/xindex/lualatex/xindex-norsk.lua @@ -10,7 +10,7 @@ ----------------------------------------------------------------------- if not modules then modules = { } end modules ['xindex-no'] = { - version = 0.51, + version = 0.53, comment = "configuration to xindex.lua", author = "Herbert Voss", copyright = "Herbert Voss", diff --git a/indexing/xindex/lualatex/xindex-pretty.lua b/indexing/xindex/lualatex/xindex-pretty.lua index 087e2eb16b..6a1a5f7d66 100644 --- a/indexing/xindex/lualatex/xindex-pretty.lua +++ b/indexing/xindex/lualatex/xindex-pretty.lua @@ -7,7 +7,7 @@ ----------------------------------------------------------------------- if not modules then modules = { } end modules ['xindex-pretty'] = { - version = 0.51, + version = 0.53, comment = "dump a Lua table for debugging", author = "Steve Donovan", copyright = "Steve Donovan", diff --git a/indexing/xindex/lualatex/xindex-yannis.lua b/indexing/xindex/lualatex/xindex-yannis.lua index 6ea612d779..0299eed6d8 100644 --- a/indexing/xindex/lualatex/xindex-yannis.lua +++ b/indexing/xindex/lualatex/xindex-yannis.lua @@ -9,7 +9,7 @@ ----------------------------------------------------------------------- if not modules then modules = { } end modules ['xindex-yannis'] = { - version = 0.51, + version = 0.53, comment = "main configuration to xindex.lua", author = "Herbert Voss", copyright = "Herbert Voss", diff --git a/indexing/xindex/scripts/xindex.lua b/indexing/xindex/scripts/xindex.lua index dc539e193c..73aa9e2067 100755 --- a/indexing/xindex/scripts/xindex.lua +++ b/indexing/xindex/scripts/xindex.lua @@ -9,7 +9,7 @@ ----------------------------------------------------------------------- xindex = xindex or { } - local version = 0.51 + local version = 0.53 xindex.version = version --xindex.self = "xindex" @@ -43,21 +43,21 @@ local args = require ('xindex-lapp') [[ -q,--quiet -h,--help -v... Verbosity level; can be -v, -vv, -vvv + -V,--version + -a,--no_casesensitive + -b,--no_labels -c,--config (default cfg) -e,--escapechar (default ") -f,--fix_hyperref - -n,--noheadings - -a,--no_casesensitive - -b,--no_labels + -g,--no_pagenumber -i,--ignoreSpace - -o,--output (default "") -k,--checklang -l,--language (default en) - -g,--no_pagenumber + -n,--noheadings + -o,--output (default "") -p,--prefix (default L) - -u,--use_UCA -s,--use_stdin - -V,--version + -u,--use_UCA <files...> (default stdin) .idx file(s) ]] @@ -223,18 +223,18 @@ alphabet_lower_map = CreateCharListMap(alphabet_lower) alphabet_upper_map = CreateCharListMap(alphabet_upper) esc_char = args.escapechar +esc_char2 = esc_char..esc_char writeLog(2,"Escapechar = "..esc_char.."\n",1) escape_chars = { -- by default " is the escape char - {esc_char..'"', '//escapedquote//', '"' }, - {esc_char..'@', '//escapedat//', '@' }, - {esc_char..'|', '//escapedvert//', '|' }, - {esc_char..'!', '//escapedexcl//', '!' } --- {esc_char..'%(', '//escapedparenleft//', '(' }, -- ( must beescaped --- {esc_char..'%)', '//escapedparenright//',')' } -- ) " " + {esc_char2, '//escaped2//', esc_char }, + {esc_char..'@', '//escapedat//', '@' }, + {esc_char..'|', '//escapedvert//', '|' }, + {esc_char..'!', '//escapedexcl//', '!' }, + {'', '\\textbar', '|' }, + {'', '\\braceLeft', '{' }, + {'', '\\braceRight', '}' } } --- esc_char..'%( is not needed because it can only appear after | - outFile = io.open(outfilename,"w+") check_language = args["checklang"] |