As an extension to this question: Creating new single line classes in ODT output from mk4ht oolatex
I've been attempting to use this approach to reassign the style assigned in existing commands that have already been configured. The initial guidance provided in the comments of the linked question suggested starting from the \Configure{section} command found in ooffice.4ht
\Configure{section}
{\IgnorePar\EndP \HCode{<!--start of section-->}}
{\IgnorePar\EndP \HCode{<!--end of section-->}}
{\HCode{<text:h
text:style-name="\csname a:Heading-2\if@rl-rtl\fi
\endcsname"
\text:outlinelevel="2" ><text:span
text:style-name="section" >}\TitleMark\space
\HCode{</text:span>}\IgnoreIndent}
{\HCode{</text:h>\Hnewline}\par\ShowPar}
So I started playing around with this block as a starting point. But I've been unable to get this block to compile let alone customize with my own style names. I've tried to many permutations and scope changes to detail each here, but in short, I've tried:
- simplifying the
csnameline to only contain my desired section name. - I've removed TeX code like the
\TitleMarkand\space. - I've also tried replacing the
HCodeportions with the customizedHCodetext inspired from the answer to the related question. - My setup seems sensitive to spaces so I've been playing around with this and
%on line endings as well.
I get error messages at times complaining about the :h and the associated > character, but in general it only reports the typical Missing \begin{document} in myconfig.cfg
MWE:
test.tex
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\definecolor{specialtextcolor}{rgb}{0,0,1}
\newenvironment{test}
{\par\begin{color}{specialtextcolor}}
{\end{color}}
\usepackage[parfill]{parskip}
\usepackage{longtable}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\begin{document}
This is a normal paragraph.
\section{Custom style access test}
test text in the first level of section hierarchy
more text
\begin{test}
This is a test environment.
\end{test}
more text
This is a blockquote environment
\begin{quote}
This is a test quote environment.
\end{quote}
\end{document}
myconfig.cfg
\Preamble{xhtml}
% to simplify the things
\def\myendpar{\ifvmode\IgnorePar\fi\EndP}
% configure the single line commands in Tex against their corresponding style in the template
\Configure{section}%
{\IgnorePar\EndP \HCode{<!--start of section-->}}%
{\IgnorePar\EndP \HCode{<!--end of section-->}}%
{\HCode{<text:h
text:style-name="Heading-2">
text:outlinelevel="2" ><text:span
text:style-name="section" >}%
%\TitleMark\space%
\HCode{</text:span>}%
%\IgnoreIndent%
}%
{\HCode{</text:h>\Hnewline}\par\ShowPar}%
% configure the environments in Tex against their corresponding style in the template
\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}{}{}%
\ConfigureEnv{quote}%
{%
\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="quote">}}%
{\EndP \HCode{<text:p text:style-name="quote">}}%
{\HCode{</text:p>}}%
{\HCode{</text:p>}}%
\par\ShowPar%
}{\myendpar\egroup}{}{}%
\begin{document}
\EndPreamble
The example is compiled against a sample ODT template file with the command:
- as part of a linux shell script:
make4ht -u --config "myconfig.cfg" --format "odt+odttemplate" "$FILE" odttemplate="$BASEDIR/refTemplates/basic.odt" - or as part of a bat file on windows:
"%MikTexPath%%htxCompiler%" --config "myconfig.cfg" --format "odt+odttemplate" "%%~nxA" odttemplate="./refTemplates/basic.odt"
If I've completely missed the mark, how else could I change the mapping of styles in existing commands?

\Configure{SectionTitleTest}do? It isn't defined anywhere and it gives you the compilation error. There are also other issues that I will investigate, but this one can be fixed just by removing of this line. – michal.h21 Aug 17 '20 at 19:17section-titlestyle in\Configure{section}? – michal.h21 Aug 17 '20 at 19:31\Configure{section}block it compiles fine. – EngBIRD Aug 17 '20 at 19:38