[tex4ht-commits] [SCM] tex4ht updated: r1661 - trunk/lit

Michal Hoftich INVALID.NOREPLY at gnu.org.ua
Fri Mar 28 12:08:46 CET 2025


Author: michal_h21
Date: 2025-03-28 11:08:46 +0000 (Fri, 28 Mar 2025)
New Revision: 1661

Modified:
   trunk/lit/ChangeLog
   trunk/lit/tex4ht-ooffice.tex
Log:
fixed support for internal odt indexing

Modified: trunk/lit/ChangeLog
===================================================================
--- trunk/lit/ChangeLog	2025-03-27 14:58:07 UTC (rev 1660)
+++ trunk/lit/ChangeLog	2025-03-28 11:08:46 UTC (rev 1661)
@@ -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/lit/tex4ht-ooffice.tex
===================================================================
--- trunk/lit/tex4ht-ooffice.tex	2025-03-27 14:58:07 UTC (rev 1660)
+++ trunk/lit/tex4ht-ooffice.tex	2025-03-28 11:08:46 UTC (rev 1661)
@@ -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



More information about the tex4ht-commits mailing list.