1

I am new to TeX4HT, I tried to write a .cfg for quote environment, i have used the below tex coding

\documentclass{book}
\begin{document}
\begin{quote}
Sample para 1

Sample para 2
\end{quote}
\end{document}

and the cfg coding is

\ConfigureEnv{quote}
             {\ifvmode \IgnorePar\fi \EndP\HCode{<div class="disp-quote">}}
             {\ifvmode \IgnorePar\fi \EndP\HCode{</div>}}
             {}
             {}

I am getting the output like below

<div class="disp-quote">
     <div class="quote">
     <!--l. 4--><p class="noindent" >Sample para 1
     </p><!--l. 6--><p class="noindent" >Sample para 2</p></div>
</div>

In the output html file '<div>' tag is opened for two times

"<div class="disp-quote">" - this is I defined in the cfg file
"<div class="quote">"  - this one is coming from the html4.4ht

also i am getting <!--l. 4--> and <!--l. 6--> in the each and every para starting in the output html file

I compile the file with the following arguments

htlatex sample "sample.cfg,xhtml"

Please suggest How to suppress the repeating <div> tag and the comment Instructions <!--l. 4--> ?

3

The original configuration for quote environment is:

\ConfigureEnv{quote}
    {}{}
    {\IgnorePar\EndP
 \HCode{<div class="\getClass{quote}">}\afterGetClass{quote}}
    {\IgnorePar\EndP\HCode{</div>}\ShowPar\ShowIndent}
 \Css{.quote  {margin-bottom:0.25em; margin-top:0.25em;
               margin-left:1em; margin-right:1em; text-align:justify;}}
 \NewConfigure{quoteClass}{2}
 \Configure{quoteClass}{quote}{}

quote environment is based on \list, so it is a little bit special. You can see that tags are inserted in fourth and fifth argument of \ConfigureEnv instead of the second and third. When you provide your own configuration, you leave these arguments empty, but in that case the original configuration is used, and this results in double tag insertion.

You can either change your configuration to replace the original insertions:

\ConfigureEnv{quote}
         {}
         {}
         {\ifvmode \IgnorePar\fi \EndP\HCode{<div class="disp-quote">}}
         {\ifvmode \IgnorePar\fi \EndP\HCode{</div>}}

or you can use the fact that quote has configurable class name, using \Configure{quoteClass}{quote class name}{code to be inserted aftertag}:

\Configure{quoteClass}{disp-quote}{}

The line numbers are inserted by the paragraph configuration, you can get rid of it using this configuration:

\Configure{HtmlPar}
 {\EndP\HCode{<p class="noindent">}}
 {\EndP\HCode{<p class="\ifdim\parindent=0pt no\fi indent">}}
 {\HCode{</p>}}
 {\HCode{</p>}}

We have different configurations for paragraphs with and without indent, the \ifdim\parindent=0pt no\fi part is for inserting noindent class if the paragraph is marked as indented, but \parindent is zero, because it is the situation inside the quote environment.

The meaning of some of the paragraph handling commands is following:

\IgnorePar     Asks to ignore the next paragraph
\ShowPar       Asks to take into account the following paragraphs

\IgnoreIndent  asks to ignore indentation in the next paragraph
\ShowIndent    asks to check indentation in the following paragraphs

\SaveEndP      Saves the content of \EndP, and sets it to empty content
\RecallEndP

This results in the following code:

 <div class="disp-quote">
 <p class="noindent">Sample para 1
 </p><p class="noindent">Sample para 2</p></div>
  • what is the use of \getClass, \afterGetClass, \ShowPar and \ShowIndent – Venkatesan Ramachandiran Jan 6 '17 at 8:47
  • @venkatesanRamachandiran I've added description of the paragraph commands to the answer. \getClass{name} and \afterGetClass{name} inserts information from \Configure{'name'Class}. – michal.h21 Jan 6 '17 at 9:24
  • closing </p> tag is not printing in the first para of the environment, how to arrest/get the closing tag of </p>? – Venkatesan Ramachandiran Feb 7 '17 at 5:30
  • @VenkatesanRamachandiran there is missing \EndP command in the configuration for \HtmlPar. Please see the updated answer. – michal.h21 Feb 7 '17 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.