Dear tex4ht list members, I would like to produce an ODT document from my XeLaTeX document (using MacTeX 2016).
The necessary code to include Unicode characters (including in Greek and Arabic script) was kindly provided by CV Radhakrishnan and Michal Hoftich back in February 2013. But I am running into a new difficulty: converting a document that defines LaTeX macros that have Unicode characters in them. (The reason I want this is to enable me to use macros within a Right-to-Left script, Arabic. Mixing up RTL and LTR scripts in a text editor, especially when punctuation -- or braces {} -- is involved, tends to make the source file unreadable.) I am attaching a MWE in two files: 1. `main.tex`: standalone file that includes macro definition 2. `utf2ent.pl`: the Perl script devised by CVR to keep Unicode in the new document The script I run to compile this is: # CVR's script to preserve Unicode characters perl utf2ent.pl main.tex > main-ent.tex # tex4ht mk4ht oolatex main-ent "xhtml, charset=utf-8" -utf8 If I get rid of the macro, it works perfectly. But with the macro it produces an ODT file that won't open. Best wishes, Alex
main.tex
Description: TeX document
#!/usr/bin/perl use strict; use warnings; for my $file ( @ARGV ){ open my $fh, '<:utf8', $file or die "cannot open file $file: $!"; while( <$fh> ){ s/([\x7f-\x{ffffff}])/'\\entity{'.ord($1).'}'/ge; print; } }