texlive[74783] Master/texmf-dist: internal odt indexing, tex4ht r1661
commits+karl at tug.org
commits+karl at tug.org
Fri Mar 28 23:24:18 CET 2025
Revision: 74783
https://tug.org/svn/texlive?view=revision&revision=74783
Author: karl
Date: 2025-03-28 23:24:18 +0100 (Fri, 28 Mar 2025)
Log Message:
-----------
internal odt indexing, tex4ht r1661
Revision Links:
--------------
https://tug.org/svn/texlive?view=revision&revision=1661
Modified Paths:
--------------
trunk/Master/texmf-dist/source/generic/tex4ht/ChangeLog
trunk/Master/texmf-dist/source/generic/tex4ht/tex4ht-ooffice.tex
trunk/Master/texmf-dist/tex/generic/tex4ht/ooffice.4ht
Modified: trunk/Master/texmf-dist/source/generic/tex4ht/ChangeLog
===================================================================
--- trunk/Master/texmf-dist/source/generic/tex4ht/ChangeLog 2025-03-28 21:33:54 UTC (rev 74782)
+++ trunk/Master/texmf-dist/source/generic/tex4ht/ChangeLog 2025-03-28 22:24:18 UTC (rev 74783)
@@ -1,3 +1,9 @@
+2025-03-28 Michal Hoftich <michal.h21 at gmail.com>
+
+ * tex4ht-ooffice.tex (ooffice.4ht): fixed support for internal ODT
+ indexing
+ https://github.com/michal-h21/make4ht/issues/170
+
2025-03-27 Michal Hoftich <michal.h21 at gmail.com>
* tex4ht-4ht.tex (tuenc-xetex-input.4ht): load additional CJK
Modified: trunk/Master/texmf-dist/source/generic/tex4ht/tex4ht-ooffice.tex
===================================================================
--- trunk/Master/texmf-dist/source/generic/tex4ht/tex4ht-ooffice.tex 2025-03-28 21:33:54 UTC (rev 74782)
+++ trunk/Master/texmf-dist/source/generic/tex4ht/tex4ht-ooffice.tex 2025-03-28 22:24:18 UTC (rev 74783)
@@ -1,4 +1,4 @@
-% $Id: tex4ht-ooffice.tex 1659 2025-03-26 11:36:32Z michal_h21 $
+% $Id: tex4ht-ooffice.tex 1661 2025-03-28 11:08:46Z michal_h21 $
% compile 3 times: latex tex4ht-ooffice
% htlatex tex4ht-ooffice "xhtml,4,sections+"
%
@@ -7131,8 +7131,84 @@
%%%%%%%%%%%%%
+We need to parse the index entries to get the correct attributes that will be saved in the ODT file.
\<configure ooffice latex\><<<
+\ExplSyntaxOn
+\tl_new:N \l_parsed_index_part_a_tl
+\tl_new:N \l_parsed_index_part_b_tl
+\tl_new:N \l_parsed_index_part_c_tl
+\tl_new:N \l_parsed_index_part_d_tl
+
+% support for internal ODT indexing. each \index command will insert
+% marker to the contents of the document, which can be displayed using
+% LibreOffice's index feature
+
+% parse \index parts aaa!bbb!ccc|ddd into different token lists,
+% because we need to put them to different attributes
+\def\parse:index:parts#1{
+ \regex_extract_once:nnN { ^([^!^|^@]*)!?([^!^|^@]*)!?([^\|^@]*)[\|@]?(.*)$ } { #1 } \l_tmpa_seq
+ \tl_set:Nx \l_parsed_index_part_a_tl { \seq_item:Nn \l_tmpa_seq {2} }
+ \tl_set:Nx \l_parsed_index_part_b_tl { \seq_item:Nn \l_tmpa_seq {3} }
+ \tl_set:Nx \l_parsed_index_part_c_tl { \seq_item:Nn \l_tmpa_seq {4} }
+ }
+
+
+\def\:indexmark#1{%
+ \parse:index:parts{#1}%
+ \a:indexmark%
+ % we need to assign index keys to correct attributes.
+ % which attributes to use depends on number of index levels,
+ % so we need to use different attributes for each number
+ \tl_if_empty:NTF \l_parsed_index_part_c_tl{
+ \tl_if_empty:NTF \l_parsed_index_part_b_tl{
+ % only one level
+ % spaces between words were missing sometimes, so I am using \HCode
+ \HCode{\tl_use:N \l_parsed_index_part_a_tl}
+ }{% two levels
+ \HCode{\tl_use:N \l_parsed_index_part_b_tl} \c:indexmark \HCode{\tl_use:N \l_parsed_index_part_a_tl}}
+ }
+ {% three levels
+ \HCode{\tl_use:N \l_parsed_index_part_c_tl} \d:indexmark \HCode{\tl_use:N \l_parsed_index_part_b_tl} \c:indexmark\HCode{\tl_use:N \l_parsed_index_part_a_tl }}%
+ \b:indexmark%
+}
+\ExplSyntaxOff
+>>>
+
+Configure wrindex to save the index entries to the ODT file.
+
+\<configure ooffice latex\><<<
+|<wrindex one param|>
+>>>
+
+\<wrindex one param\><<<
+\pend:defI\@wrindex{{%
+ \:indexmark{##1}
+}}
+>>>
+
+Some packages, like Imakeidx use two parameters for @wrindex. We need to support that
+\<wrindex two params\><<<
+\pend:defII\@wrindex{{%
+ \:indexmark{##2}
+}}
+>>>
+
+Configure packages that use two parameters for @wrindex. There will be probably more that will need to get configured.
+
+\<configure ooffice imakeidx\><<<
+|<wrindex two params|>
+>>>
+
+\<configure ooffice index\><<<
+|<wrindex two params|>
+>>>
+
+
+The following code was supposed to write index entries using internal
+ODT markup, but it doesn't work.
+
+\<configure ooffice latex do not use \><<<
\catcode`\!=13
\HAssign\indexmark:N = 0
\immediate\openin15=\jobname.4ix
Modified: trunk/Master/texmf-dist/tex/generic/tex4ht/ooffice.4ht
===================================================================
--- trunk/Master/texmf-dist/tex/generic/tex4ht/ooffice.4ht 2025-03-28 21:33:54 UTC (rev 74782)
+++ trunk/Master/texmf-dist/tex/generic/tex4ht/ooffice.4ht 2025-03-28 22:24:18 UTC (rev 74783)
@@ -1,4 +1,4 @@
-% ooffice.4ht (2025-03-26-13:14), generated from tex4ht-ooffice.tex
+% ooffice.4ht (2025-03-28-14:40), generated from tex4ht-ooffice.tex
% Copyright 2009-2025 TeX Users Group
% Copyright 2001-2009 Maarten Wisse, James Naughton, Eitan M. Gurari
%
@@ -17,7 +17,7 @@
%
% If you modify this program, changing the
% version identification would be appreciated.
-\immediate\write-1{version 2025-03-26-13:14}
+\immediate\write-1{version 2025-03-28-14:40}
\exit:ifnot{Preamble,%
algorithmicx,%
@@ -2252,31 +2252,49 @@
{\PushStack\Col:Marg\AllColMargins}
{\PopStack\Col:Marg\AllColMargins}
{}{}
-\catcode`\!=13
-\HAssign\indexmark:N = 0
-\immediate\openin15=\jobname.4ix
-\ifeof15 \else
- \Configure{wrindex}
- {{\special{t4ht@(}\catcode`\\=0 \catcode`\{=1
- \catcode`\}=2 \catcode`\ =10 \catcode`\!=13
- \def!{\c:indexmark\def!{\d:indexmark\def!{\string!}}}%
- \gHAdvance\indexmark:N by 1
- \def\indexmark##1##2{%
- \ifnum \indexmark:N=##2 \special{t4ht@)}\a:indexmark
- ##1\b:indexmark\special{t4ht@(}\fi}%
- \hbox{\input \jobname.4ix \special{t4ht@)}}%
- }}
-\fi
-\catcode`\!=12
-\NewConfigure{indexmark}{4}
-\Configure{indexmark}
- {\HCode{<text:alphabetical-index-mark\Hnewline
- text:id="dx\last:haddr"
- text:string-value="}%
- \NoFonts}
- {\EndNoFonts \HCode{" />}}
- {\HCode{" text:key1="}}
- {\HCode{" text:key2="}}
+\ExplSyntaxOn
+\tl_new:N \l_parsed_index_part_a_tl
+\tl_new:N \l_parsed_index_part_b_tl
+\tl_new:N \l_parsed_index_part_c_tl
+\tl_new:N \l_parsed_index_part_d_tl
+
+% support for internal ODT indexing. each \index command will insert
+% marker to the contents of the document, which can be displayed using
+% LibreOffice's index feature
+
+% parse \index parts aaa!bbb!ccc into different token lists,
+% because we need to put them to different attributes
+\def\parse:index:parts#1{
+ \regex_extract_once:nnN { ^([^!^\let \prOteCt \relax \Protect \csname acp:c\endcsname {4}@]*)!?([^!^\let \prOteCt \relax \Protect \csname acp:c\endcsname {4}@]*)!?([^\\let \prOteCt \relax \Protect \csname acp:c\endcsname {4}@]*)[\]?(.*)$ } { #1 } \l_tmpa_seq
+ \tl_set:Nx \l_parsed_index_part_a_tl { \seq_item:Nn \l_tmpa_seq {2} }
+ \tl_set:Nx \l_parsed_index_part_b_tl { \seq_item:Nn \l_tmpa_seq {3} }
+ \tl_set:Nx \l_parsed_index_part_c_tl { \seq_item:Nn \l_tmpa_seq {4} }
+ }
+
+
+\def\:indexmark#1{%
+ \parse:index:parts{#1}%
+ \a:indexmark%
+ % we need to assign index keys to correct attributes.
+ % which attributes to use depends on number of index levels,
+ % so we need to use different attributes for each number
+ \tl_if_empty:NTF \l_parsed_index_part_c_tl{
+ \tl_if_empty:NTF \l_parsed_index_part_b_tl{
+ % only one level
+ % spaces between words were missing sometimes, so I am using \HCode
+ \HCode{\tl_use:N \l_parsed_index_part_a_tl}
+ }{% two levels
+ \HCode{\tl_use:N \l_parsed_index_part_b_tl} \c:indexmark \HCode{\tl_use:N \l_parsed_index_part_a_tl}}
+ }
+ {% three levels
+ \HCode{\tl_use:N \l_parsed_index_part_c_tl} \d:indexmark \HCode{\tl_use:N \l_parsed_index_part_b_tl} \c:indexmark\HCode{\tl_use:N \l_parsed_index_part_a_tl }}%
+ \b:indexmark%
+}
+\ExplSyntaxOff
+\pend:defI\@wrindex{{%
+ \:indexmark{##1}
+}}
+
\pend:def\index{\leavevmode}
\NewConfigureOO{Index Heading}
\ConfigureOO{Index Heading}{\Hnewline
More information about the tex-live-commits
mailing list.