# Renew itemize environment for customization in tex4ht

In a htlatex compiled document a standard enumerated list environment shows up as a <li class="itemize"> tag.

For the pdf version I have loaded the enumitem package to aid with list customizations, but I am pretty sure that this won't help much (I think this might be relevant because the following customizations don't have any effect).

• \setlist[itemize,]{label=$-$}
• \setlist[itemize]{itemsep=0mm}
• \renewcommand{\labelitemi}{$-$}

Since I just want a ~ space and a symbol like a hyphen because this is to be a plain text document, not an html document

I would like to either

1. Remove the introduced itemize tag and print out my manually produced formatting

2. Customize how the html file process the itemized output

So, I am not sure if either of these are possible but the respective possibilities might be to either:

1. Rebuild the itemize environment so the tex compiler can deal with the desired text, or
2. Reprogram the formatting display using css instructions in the custom config file that htlatex receives as a command line argument.

If I could get some direction as to which of these two approaches htlatex is designed to work with I will devise and post a MWE with the relevant attempt at redefining or customizing the list environment.

UPDATE

CFG file to try and accommodate list formatting modifications on the tex4ht compile side:

\Preamble{xhtml}
\ConfigureList{itemize}{\HCode{\Hnewline}}{\HCode{\Hnewline}}{\setbox0=\hbox\bgroup}{\egroup\HCode{\Hnewline}  - }
\begin{document}
\Css{\sections{}{color:black;}}
\Css{\sections{br}{display:none;}}
\Css{\sections{.titlemark}{color:green;}}
\Css{\sections{.titlemark:after}{content:" ";}}
\Css{body{background-color:white;}}
\Css{body{font-family: 'Lucida Console', sans-serif;}}
\EndPreamble


This config file puts me half way home, I get my plain tex list items, but I don't get my new lines as would be expected by the \HCode{\Hnewline} nor are these lines an accessible part of the file. Copying the text out and pasting it into notepad doesn't preserve these new lines.

Ideally as well there will be no line breaks between a paragraph and the start of a list (a new line yes, but not blank lines). I thought I could accomplish this by leaving arguments #2 and #3 blank, but I get a tag free collection of line breaks in the html source

class="newline" />last line of text before the list</p>

<br/>-&#x00A0;

• Did you intend that one aspect of your question seems to concern the turning of an ordered list into an unordered one? Or does li class="itemize" not have that implication? – cfr Jan 3 '16 at 3:07
• @cfr If I had to hazard a guess, I believe the html tag that gives you the itemize formatting isn't order dependent because it's just a tag/prefix that is present before each item not just the beginning of the environment - that one looks like <ul class="itemize1"> (I didn't mention this one because I didn't think I would need to adapt it. I would either ignore it because the prefix and symbol were customized in the css file, or I wouldn't have this because I only simulate the appearance of an automatically formatted list in a new environment handled by the compiler.) – EngBIRD Jan 3 '16 at 4:18
• So it isn't the environment which shows up that way but the individual items? – cfr Jan 3 '16 at 15:01
• @cfr yes and no I think. The environment may handle wrapping and indents while the items may handle the symbols and subsequent spaces. – EngBIRD Jan 3 '16 at 15:31

Lists are configured using \ConfigureList{listname}{start tag}{end tag}{item label start}{item label end}. Sample configuration might look like this:

\ConfigureList{itemize}{\HCode{<br />\Hnewline}}{\HCode{<br />\Hnewline}}{\DeleteMark}{\HCode{<br />\Hnewline} -}


\HCode{<br />\Hnewline} inserts line break, the interesting part is {\DeleteMark}{\HCode{\Hnewline} -} - it discards the bullet item, breaks line and print -.

Fot complete config file, we may use my example configuration for Wiki markup:

\Preamble{xhtml}

\ConfigureList{itemize}{\HCode{<br />\Hnewline}}{\HCode{<br />\Hnewline}}{\DeleteMark}{\HCode{<br />\Hnewline} -}

% remove html structure
\Configure{HTML}{}{}
\Configure{BODY}{}{}
\Configure{DOCTYPE}{}
\Configure{TITLE}{}{}
\Configure{VERSION}{}

\newcommand\starttag[1]{\NoFonts\HCode{#1}}
\newcommand\stoptag[1]{\NoFonts\HCode{#1}}
\newcommand\ConfigureInlinetag[2]{%
\Configure{#1}{\starttag{#2}}{\stoptag{#2}}%
}

\ConfigureInlinetag{textit}{''}
\ConfigureInlinetag{textbf}{'''}

\newcommand\ConfigureSection[2]{%
\Configure{#1}{}{}{\starttag{#2}}{\stoptag{#2\Hnewline}}%
}

\ConfigureSection{section}{==}
\ConfigureSection{likesection}{==}
\ConfigureSection{subsection}{===}
\ConfigureSection{likesubsection}{===}

% remove section id
\def\gobbleone#1#2{}

% remove <p> elements
\Configure{HtmlPar}{}{}{\HCode{\Hnewline}}{\HCode{\Hnewline}}

% \DeclareFieldFormat[article]{entrytype}{Cite journal}
% \DeclareFieldFormat*{titlecite}{{title=#1}}%
% \DeclareFieldFormat*{yearcite}{{year={#1}}}%
% \DeclareNameFormat*{labelname}{\ifthenelse{\value{listcount}=1}{#1}{}}
% \DeclareCiteCommand{\cite}%
%   {\printnames{labelname}\HCode{<ref>}\{\{}%
%   {%
%   \printfield{entrytype}
%   \setunit{|}%
%   \printtext{author=}%
%   \printnames{author}%
%   \setunit{|}%
%   \printfield[titlecite]{title}%
%   \setunit{|}%
%   \printfield[yearcite]{year}%
%   }%
%   {}%
%   {\}\}\HCode{</ref>}}%

\begin{document}

\EndPreamble


A sample file:

\documentclass{article}

\begin{document}
\section{hello}

\begin{itemize}

\item first item

\item second \textit{item}

\item some longer snippet of text. We hope that it may break the line
somewhere. So it should be longer than it is currently. How about this? It might be enough.

\end{itemize}

\end{document}


is converted to:

   ==hello==

-first item

-second ''item''

-some  longer  snippet  of  text.  We  hope  that  it  may  break  the  line

there is lot of white space but I guess it shouldn't be problem. You can remove some \Hnewlines if you want.
• Thanks, but I'm a very puzzled. I have been trying to get this work for the last couple days, because when I run your cfg and tex files as above I get a single line of text in the html document. In debugging further I noticed that I loose my line breaks when I include \Configure{HtmlPar}{}{}{\HCode{\Hnewline}}{\HCode{\Hnewline}}. I get my initial line break when the only addition to my config file is \ConfigureList{itemize}{\HCode{\Hnewline}}{\HCode{\Hnewline}}{\setbox0=\hbox\bgroup}{\egroup\HCode{\Hnewline} -} but no breaks inbetween items of the same list. I will update my question. – EngBIRD Jan 6 '16 at 1:48
• @EngBIRD you can remove the \Configure{HtmlPar} and try to add \Css{body{white-space:pre-line;}} instead – michal.h21 Jan 6 '16 at 8:14
• @EngBIRD new lines are generally inserted with \Hnewline macros in configurations. ) – michal.h21 Jan 7 '16 at 23:20
• I think I have figured out the crux of my problem: Using information you posted michal-h21.github.io/src4ht/tex4ht-infose2.html#x7-40002.2, my latest cfg customization uses this line \ConfigureList{itemize}{}{}{\HCode{\Hnewline}~~-~\DeleteMark}{} but argument #4 doesn't insert a line break. Is there a box or unbreakable paragraph that I have stumbled upon? Would this supersede a functional HTML or JS line break command? – EngBIRD Jan 10 '16 at 5:46