2

Following my recent question Customizing ODT output from mk4ht oolatex and a improved process alternative described here: Use ODT Template for make4ht (which makes use of direct formatting by using existing / created styles stored in a odt document/template) I'd like to ask what needs to be done on the tex/compilation side with make4ht to connect a style in the odt template to a custom command or environment in a latex file.

For example:

I create a style called test in a odt file called basic.odt.
enter image description here

I compile a tex file (see below for MWE) with "C:\texmfs\install\miktex\bin\make4ht.exe" -f odt+odttemplate "test.tex" "odttemplate=./refTemplates/basic.odt" which compiles my tex file with make4ht with a pointer to the template odt file.

MWE:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{xcolor}
\definecolor{specialtextcolor}{rgb}{0,0,1}

\newenvironment{test}
{\par\begin{color}{specialtextcolor}}
{\end{color}}


\begin{document}
    This is a normal paragraph.

    \section{Custom style access test}

    test text in the first level of section hierarchy 

    more text
    \medskip

    \begin{test}
        This is a test environment.
    \end{test}

    \medskip    

    more text

\end{document}

The main concern is that the output files don't reflect that they used the test style.

The first point to clarify:

  1. What does make4ht require to let the lua script take over and extract the required css formatting from the style in the template odt file? I was hoping to use these odt template files and move away from the Configure commands in the cfg files, which I never successfully modified to work for other styles (see quote example in Customizing ODT output from mk4ht oolatex... I couldn't even rename all instances in tex and cfg files from quote to cmdquote without compile errors).

  2. Since certain styles (like section) are accessible without any interface cfg manually created or customized I assume either

    a) no custom cfg files are needed and my test commands/environments are to minamalistic or b) these have already been pre-configured (like in a class or sty file)? If it is the latter where are these documented or stored so I can learn from these pre-existing examples?

EngBIRD
  • 3,985

1 Answers1

2

You must still configure the test environment to use the test style. And to make it more difficult, if you want to use the paragraph style, you must configure the paragraph handling for the environment. Try this configuration:

\Preamble{xhtml}
% to simplify the things
\def\myendpar{\ifvmode\IgnorePar\fi\EndP}

% configure the environment
\ConfigureEnv{test}
{\myendpar\bgroup%
% when you want to modify the paragraph style, you must redefine the paragraph configuration to 
% use the test style name
\Configure{HtmlPar}%
{\EndP \HCode{<text:p text:style-name="test">}}%
{\EndP \HCode{<text:p text:style-name="test">}}%
{\HCode{</text:p>}}{\HCode{</text:p>}}%
\par\ShowPar}
{\myendpar\egroup}{}{}

\begin{document}

\EndPreamble

As you can see, you must configure the HtmlPar configuration, to insert <text:p text:style-name="desired style name">. It cannot be inserted automatically. Normally, you would insert style for the test style using \NewConfigureOO and \ConfigureOO commands, but as you configure it in the template file, you don't need it in this case and I will not show that. Some information about usual styling for the ODT output can be found here.

The default styles used by tex4ht aren't unfortunately documented, you can only search for \ConfigureOO in the literate sources of the ODT output.

I've also updated the odttemplate extension to actually join the styles from the template and the generated file, because you would lose additional styles added by tex4ht if you used just basic ODT file created by LibreOffice.

This is a result from empty ODT file with declared test style:

enter image description here

michal.h21
  • 50,697
  • Thanks, I can't wait to try this out! I've cloned the make4ht project into my scripts folder, replacing the one miktex created but when I compile my tex file I just get a corrupted odt file, so I assume I just need to wait until the binary aspects of the package get updated with miktex. – EngBIRD Jan 23 '19 at 00:48
  • @EngBIRD ah, do you get any errors towards the end of compilation? Especially with Xtpipes? Or some zip error? – michal.h21 Jan 23 '19 at 08:01
  • @EngBIRD new version of make4ht should be available in few days in distributions. – michal.h21 Jan 23 '19 at 11:35
  • I do remember seeing a zip error go past, but I didn't think that was anything new... I seem to remember getting that message all the time in the past but with no ultimate consequence. I could just be remembering snippets from the console during debug efforts as I've been trying a lot of things in the last year or so with mk4ht and make4ht. – EngBIRD Jan 23 '19 at 12:43
  • @EngBIRD usually the corrupted ODT file means that there is a XML error, so something must be wrong with either styles or the main text – michal.h21 Jan 23 '19 at 12:50
  • I randomly brought my personal laptop to work today so I could actually compile and report back: 1) I see xtpipes go past, but nothing stands out as an error, it just runs on a .4oo file and .tmp file. 2) I get a zip error that says zip not recognized as an internal or external command Neither the zip error or any further messages about xtpipes are in the log file. – EngBIRD Jan 23 '19 at 12:59
  • @EngBIRD ah, this is the issue, as zip is necessary for the ODT file building. – michal.h21 Jan 23 '19 at 13:03
  • @EngBIRD do you have installed miktex-zip package? – michal.h21 Jan 23 '19 at 13:05
  • My miktex installation reports that I have miktex-zip-bin miktex-bzip2-bin-2.9 and miktex-zzip-bin-2.9 – EngBIRD Jan 23 '19 at 13:38
  • @EngBIRD so does miktex-zip command work? It should be detected by make4ht when normal zip is not present. What version of make4ht do you have? (make4ht -v) – michal.h21 Jan 23 '19 at 13:49
  • The results of miktex-zip -v is This is Zip 3.0 (July 5th 2008), by Info-ZIP.. The results of make4ht -v is make4ht version {{version}}. I'm guessing it may be necessary to alias zip to miktex-zip because zip returns 'zip' is not recognized as an internal or external command, operable program or batch file. – EngBIRD Jan 23 '19 at 16:01
  • @EngBIRD make4ht should use miktex-zip if it cannot find zip, so that's strange. anyway, simplest solution is to provide a zip command, as you said. – michal.h21 Jan 23 '19 at 17:39
  • Interestingly, now that I have the zip setup, I no longer get a odt file, and watching the compilation process, I see the line The process tried to write to a non existent pipe. I don't see any missing pipe packages, so I must have a problem as you initially suspected with xtpipes. – EngBIRD Jan 23 '19 at 18:45
  • @EngBIRD no, it seems more like it cannot run the zip command anyway. I don't have access to Windows so I cannot test it no Miktex myself. Maybe you should delete the development version of make4ht, as the version included in Miktex worked – michal.h21 Jan 23 '19 at 18:49
  • So, I've seemingly lost the ability to produce any odt files on windows, even bat files that used to produce odt files aren't anymore (this is even true after removing the link to the zip command, restarting, and confirming that zip on the command line fails as it used to). And on linux, I get an odt file, but it doesn't grab the new formatting from the template. I've tried every combination on the command line that I can think of, but I think in this last week I've exhausted all my ideas. Could you offer any suggestions to debug these new compile issues? Thanks! – EngBIRD Jan 31 '19 at 23:45
  • @EngBIRD have you deleted the development version of make4ht? I don't have an access to Miktex, it may be a good idea to contact Miktex issue tracker and if make4ht works correctly here – michal.h21 Feb 01 '19 at 08:04
  • I had removed the development version (fresh install of miktex). It was a problem with my zip alias/link. Somehow it was locking the files/not closing the processes so the odt file couldn't be moved or updated. I created a copy of miktex-zip.exe and renamed it to zip.exe and my odt files showed up again. Not 100% working though, now the odt's are corrupted and won't open, but that's a step in the right direction. The code above works fine on my arch linux distro when using the developer version of make4ht in the scripts folder, but not my debian based distro, it's pkgs are probably to obsolete – EngBIRD Feb 06 '19 at 03:40
  • @EngBIRD yes, Debian may use old versions, the Debian project expulsed TeX Live packages maintainer, I don't know if the updates are incorporated now – michal.h21 Feb 06 '19 at 07:51