1

I have a problem with setting \parskip=0pt, not in my .pdf, but in my .html

I want a new environment with \parskip=0pt, but make4ht -ul myfile.tex does not respect my deifnition.

There seems to be a trick with \obeylines, where the parskip is reduced in the .html, but I do not want this.

\documentclass[oneside,a4paper, 12pt]{article}
%\usepackage[french]{babel}
%\usepackage[style=french]{csquotes}%
\usepackage{alternative4ht}
\altusepackage{polyglossia}
\altusepackage{fontspec}
%\setdefaultlanguage{french}


%\def\obeylines{\catcode`\^^M\active \let ^^M\par }
%%%%%%%% DO NOT FORGET THE SPACES:
%\def\disobeylines{\catcode ‘\^^M=5 }

\newenvironment{dialogue}
{
%\obeylines
\parskip=0em
\relax
%\par
}{\par}


\newenvironment{dialogueobeylines}{\parskip=0em\relax
\obeylines
}
%\par


\setlength{\parindent}{0ex}
\setlength\parskip{1ex plus 0.5ex minus 0.5ex}

\begin{document}

Accidentally left the caps lock on and typed something, but can't be bothered to start again and retype it all?
QQQ.

Simply enter your text and choose the case you want to convert it to.\\

\textbf{begin of the dialogue. check the parskip}\\
\begin{dialogue}
Accidentally left the caps lock on and typed something, but can't be bothered to start again and retype it all?
QQQ

Simply enter your text and choose the case you want to convert it to.
\end{dialogue}
\textbf{end of the dialogue}\\

\textbf{begin of the dialogueOBEYLINES. check the parskip}\\
\begin{dialogueobeylines}
Accidentally left the caps lock on and typed something, but can't be bothered to start again and retype it all?
%QQQ
{}

Simply enter your text and choose the case you want to convert it to.
\end{dialogueobeylines}
\textbf{end of the dialogueOBEYLINES}\\

\end{document}
1

For such cases you need to enclose paragraphs inside the environment with some helper html element and then style them using CSS. You can easily add such element using \ConfigureEnv command. The definition can look like this (hello.cfg):

\Preamble{xhtml}
\def\ClosePar{\ifvmode\IgnorePar\fi\EndP}
\ConfigureEnv{dialogue}
 {\ClosePar\HCode{<div class="dialogue">}\par}
 {\ClosePar\EndP\HCode{</div>}}{}{}
\Css{.dialogue p.indent, .dialogue p.noindent{margin-bottom:0;margin-top:0;}}
\Css{.dialogue{margin-bottom:0.5em;margin-top:-1em;}}
\begin{document} 
\EndPreamble

This configuration inserts <div class="dialogue"> around the environment, it is then easily configured using CSS. Note that we must use .dialogue p.indent, .dialogue p.noindent to style the paragraphs.

The result: enter image description here

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.