Mk4ht oolatex'ten ODT çıktısında mevcut tek hat sınıflarını özelleştirme
Bu sorunun bir uzantısı olarak: mk4ht oolatex'ten ODT çıktısında yeni tek satırlı sınıflar oluşturma
Zaten yapılandırılmış olan mevcut komutlarda atanan stili yeniden atamak için bu yaklaşımı kullanmaya çalışıyorum. Bağlantılı sorunun yorumlarında sağlanan ilk kılavuz, içinde bulunan \Configure{section}
komuttan başlayarakooffice.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}
Bu yüzden bir başlangıç noktası olarak bu blokla oynamaya başladım. Ama kendi stil isimlerimle özelleştirmek şöyle dursun, bu bloğu derleyemedim. Burada her birini ayrıntılandırmak için birçok permütasyon ve kapsam değişikliği denedim, ancak kısaca denedim:
csname
satırı sadece istediğim bölüm adını içerecek şekilde basitleştiriyorum .- TeX kodunu
\TitleMark
ve gibi kaldırdım\space
. - Ayrıca
HCode
bölümleriHCode
, ilgili sorunun cevabından esinlenerek özelleştirilmiş metinle değiştirmeyi denedim . - Kurulumum boşluklara karşı hassas görünüyor, bu yüzden bununla ve
%
satır sonlarıyla da uğraşıyorum.
Zaman zaman :h
ve ilişkili >
karakter hakkında şikayet eden hata mesajları alıyorum , ancak genel olarak yalnızca tipikMissing \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
Örnek, aşağıdaki komutla örnek bir ODT şablon dosyasına göre derlenmiştir:
- bir linux kabuk betiğinin parçası olarak:
make4ht -u --config "myconfig.cfg" --format "odt+odttemplate" "$FILE" odttemplate="$BASEDIR/refTemplates/basic.odt"
- veya Windows'ta bir yarasa dosyasının parçası olarak:
"%MikTexPath%%htxCompiler%" --config "myconfig.cfg" --format "odt+odttemplate" "%%~nxA" odttemplate="./refTemplates/basic.odt"
İşareti tamamen kaçırdıysam, mevcut komutlarda stillerin eşlemesini başka nasıl değiştirebilirim?
Yanıtlar
mwe.cfg
Başlıca: bildirilmemiş kullanmanız \Configure{SectionTitleTest}
ve için beşinci argümanı kaçırmanız nedeniyle hatalar alıyorum \Configure{section}
.
Dosyanızı aşağıdaki düzeltmelerle derleyebilirim:
\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
Ben ekledim Başka düzeltme kaldırdım olmasıydı \par
gelen \ConfigureEnv{quote}
bu belgede gösterdiği sahte boş paragrafta sonuçlandı, çünkü.
Bu işlenmiş belgedir:
