Personalização de classes de linha única existentes na saída ODT do mk4ht oolatex
Como uma extensão a esta pergunta: Criação de novas classes de linha única na saída ODT do mk4ht oolatex
Tenho tentado usar essa abordagem para reatribuir o estilo atribuído em comandos existentes que já foram configurados. A orientação inicial fornecida nos comentários da questão vinculada sugerida a partir do \Configure{section}
comando encontrado emooffice.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}
Então comecei a brincar com esse bloco como ponto de partida. Mas não consegui compilar esse bloco, muito menos personalizá-lo com meus próprios nomes de estilo. Eu tentei muitas permutações e mudanças de escopo para detalhar cada aqui, mas em resumo, eu tentei:
- simplificando a
csname
linha para conter apenas o nome da seção desejada. - Eu removi o código TeX como o
\TitleMark
e\space
. - Também tentei substituir as
HCode
partes peloHCode
texto personalizado inspirado na resposta à pergunta relacionada. - Minha configuração parece sensível a espaços, então tenho brincado com isso e também
%
com terminações online.
Eu recebo mensagens de erro às vezes reclamando sobre o :h
e o >
caractere associado , mas em geral ele apenas relata o típicoMissing \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
O exemplo é compilado em relação a um arquivo de modelo ODT de amostra com o comando:
- como parte de um script de shell do Linux:
make4ht -u --config "myconfig.cfg" --format "odt+odttemplate" "$FILE" odttemplate="$BASEDIR/refTemplates/basic.odt"
- ou como parte de um arquivo bat no Windows:
"%MikTexPath%%htxCompiler%" --config "myconfig.cfg" --format "odt+odttemplate" "%%~nxA" odttemplate="./refTemplates/basic.odt"
Se eu perdi completamente o alvo, de que outra forma poderia alterar o mapeamento de estilos nos comandos existentes?
Respostas
Recebo erros com o seu mwe.cfg
principalmente porque: você usa não declarado \Configure{SectionTitleTest}
e por causa da falta do quinto argumento para \Configure{section}
.
Posso compilar seu arquivo com as seguintes correções:
\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{SectionTitleTest}{\myendpar\HCode{<text:p text:style-name="section-title">}}{\HCode{</text:p>}}
\NewConfigureOO{section-title}
\ConfigureOO{section-title}{<style:style style:name="section-title" style:family="paragraph" style:class="text">
<style:text-properties style:text-underline-style="solid"
style:text-underline-width="auto"
style:text-underline-color="font-color"
/>
</style:style>}
\Configure{section}%
{\IgnorePar\EndP \HCode{<!--start of section-->}}%
{\IgnorePar\EndP \HCode{<!--end of section-->}}%
{\HCode{<text:h
text:style-name="Heading 1"
text:outlinelevel="2" ><text:span
text:style-name="section" >}%
%\TitleMark\space%
\HCode{</text:span>}%
%\IgnoreIndent%
}{\HCode{</text:h>}}%
% \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}
% 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>}}%
\ShowPar%
}{\myendpar\egroup}{}{}%
\begin{document}
\EndPreamble
Outra correção que eu adicionei foi que eu removido \par
a partir \ConfigureEnv{quote}
, porque isso resultou em parágrafo vazio espúria que mostrou no documento.
Este é o documento renderizado:
