Menyesuaikan kelas baris tunggal yang ada dalam keluaran ODT dari mk4ht oolatex
Sebagai perpanjangan dari pertanyaan ini: Membuat kelas baris tunggal baru dalam keluaran ODT dari mk4ht oolatex
Saya telah mencoba menggunakan pendekatan ini untuk menetapkan kembali gaya yang ditetapkan dalam perintah yang ada yang telah dikonfigurasi. Panduan awal yang diberikan dalam komentar dari pertanyaan terkait yang disarankan mulai dari \Configure{section}
perintah yang ditemukan diooffice.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}
Jadi saya mulai bermain-main dengan blok ini sebagai titik awal. Tapi saya tidak bisa mendapatkan blok ini untuk dikompilasi apalagi menyesuaikan dengan nama gaya saya sendiri. Saya sudah mencoba banyak permutasi dan perubahan ruang lingkup untuk detail masing-masing di sini, tetapi singkatnya, saya sudah mencoba:
- menyederhanakan
csname
baris agar hanya berisi nama bagian yang saya inginkan. - Saya telah menghapus kode TeX seperti
\TitleMark
dan\space
. - Saya juga mencoba mengganti
HCode
bagian denganHCode
teks yang disesuaikan yang terinspirasi dari jawaban atas pertanyaan terkait. - Pengaturan saya tampaknya sensitif terhadap spasi, jadi saya telah bermain-main dengan ini dan
%
ujung online juga.
Saya mendapat pesan kesalahan pada saat mengeluh tentang :h
dan >
karakter yang terkait , tetapi secara umum hanya melaporkan tipikalMissing \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
Contoh ini dikompilasi terhadap file template ODT sampel dengan perintah:
- sebagai bagian dari skrip shell linux:
make4ht -u --config "myconfig.cfg" --format "odt+odttemplate" "$FILE" odttemplate="$BASEDIR/refTemplates/basic.odt"
- atau sebagai bagian dari file bat di windows:
"%MikTexPath%%htxCompiler%" --config "myconfig.cfg" --format "odt+odttemplate" "%%~nxA" odttemplate="./refTemplates/basic.odt"
Jika saya benar-benar meleset dari sasaran, bagaimana lagi saya bisa mengubah pemetaan gaya dalam perintah yang ada?
Jawaban
Saya mendapatkan kesalahan dengan Anda mwe.cfg
terutama karena: Anda menggunakan tidak dideklarasikan \Configure{SectionTitleTest}
dan karena kehilangan argumen kelima untuk \Configure{section}
.
Saya dapat mengompilasi file Anda dengan perbaikan berikut:
\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
Perbaikan lain yang telah saya tambahkan adalah saya menghapus \par
dari \ConfigureEnv{quote}
, karena ini menghasilkan paragraf kosong palsu yang muncul di dokumen.
Ini adalah dokumen yang dirender:
