# Configure tex4ht for package scrjura

I'm drafting agreements on the topic of renewable energies. Trouble is, clients sometimes need a word-version = my agreement in html. The package tex4ht does the job pretty well, unless I use the package scrjura, a part of the KOMA-Script-bundle. But scrjura makes writing my agreements a lot easier, I would not like to do without it. The package allows to print the agreement in accordance to German standards.

See this example:

\documentclass{article}
\usepackage[english]{babel}
\usepackage{scrjura, indentfirst}
%\usepackage{tex4ht}

\begin{document}
\begin{contract}
\Paragraph{title=Does it make sense?}

This first sentences usually talk about the sense of the whole
contract / agreement / whatever. Unlike many people think, it is not
forbidden to lawyers to write plain text.

But there are obstacles. We need some definitions.

\Paragraph{title=Share-purchase}

Let's assume we talk about a share-deal agreement. We'd have to name
the shares.

And the price.

\end{contract}

\end{document}


Ok, the output with pdflatex is:

Now let's add \usepackage{tex4ht}, save the file and compile with htlatex filename.tex. The result is a miss, but not by a mile:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html >
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="generator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)">
<meta name="originator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)">
<!-- html -->
<meta name="src" content="stackexchange-html.tex">
<meta name="date" content="2011-08-12 16:00:00">
>
<a
id="x1-2r1"></a>
<!--l. 7--><p class="noindent" ><span
class="cmsy-10x-x-120">§</span><span
class="cmssbx-10x-x-120">&#x00A0;1</span> <span
class="cmssbx-10x-x-120">Does it make sense?</span><a
id="Q1-1-1"></a><a
id="x1-3"></a>
<a
id="x1-4r1"></a><a
id="x1-5r1"></a>(1)&#x00A0;This first sentences usually talk about the sense of the whole contract /
agreement / whatever. Unlike many people think, it is not forbidden to lawyers to
write plain text.
<a
id="x1-6r2"></a><a
id="x1-7r1"></a>(2)&#x00A0;But there are obstacles. We need some definitions.
<a
id="x1-8r2"></a>
<span
class="cmsy-10x-x-120">§</span><span
class="cmssbx-10x-x-120">&#x00A0;2</span> <span
class="cmssbx-10x-x-120">Share-purchase</span><a
id="Q1-1-2"></a><a
id="x1-9"></a>
<a
id="x1-10r1"></a><a
id="x1-11r1"></a>(1)&#x00A0;Let&#8217;s assume we talk about a share-deal agreement. We&#8217;d have to name the
shares.
<a
id="x1-12r2"></a><a
id="x1-13r1"></a>(2)&#x00A0;And the price.

</body></html>


If you save this as a html-file and open it into your browser, you will notice that everything is ok, except that there are no paragraphs. The fat printed titles appear in the same line as the numbered "paragraphs", of which each one should have it's own, well, paragraph, as in the picture above.

Can anybody help me to write a config-file for tex4ht to get an output including proper paragraphs?

EDIT:

The command \Paragraph{title= ...} provides a headline to the following text. How can I inform tex4ht about this?

-

I don't understand code of scrjura, so this is just little hack:

\Preamble{html}
\begin{document}
\ConfigureEnv{contract}{\HCode{<div class="contract">}}{\HCode{</div>}}{}{}
\Css{.contract {white-space:pre-wrap;}}
\EndPreamble


save it for example as jura.cfg and call htlatex yourfile "jura". There is some error message, which I don't understand, but generated code is ok.

In the code, we are instructing tex4ht to insert at beginning and end of environment contracttag <div> with class contract and then we use css to print white spaces. More robust strategy would be to put hooks for some internal macros of scrjura, but I still don't understand configuring macros of tex4ht and I am getting some really weird errors, when I try to use them

edit

it seems that some operations aren't possible in config files. so we must develop .4ht file for scrjura. In file step4ht.pdf I have found most user friendly explanation of defining hooks for tex4ht.

If we have macro without arguments, we at first must define hooks, which will be put before and after its contents. Their structure is as follows:

\pend:def\bar{\a:bar} % before
\append:def\bar{\b:bar} % after


and then we will declare that we have two hooks for this macro:

\NewConfigure{bar}{2}


and define code, which will be put there

\Configure{bar}{\HCode{<br />}}{}


in this case, we vill put tag <br /> before contents of the macro.

I have found very difficult to understand definition of scrjura, mainly because I don't speak German. So with trial and error, I have found some macros, where I can put manual breaks. This is file scrjura.4ht

\typeout{[scrjura for tex4ht]}

\ConfigureEnv{contract}{\HCode{<div class="contract">}}{\HCode{</div>}}{}{}

\pend:def\parformat{\a:parformat}
\append:def\parformat{\b:parformat}
\NewConfigure{parformat}{2}
\Configure{parformat}{\HCode{<br /><span class="sentence" />}\EndP}{}

\pend:def\contract@paragraph@font{\a:contract@paragraph@font}
\apped:def\contract@paragraph@font{\b:contract@paragraph@font}
\NewConfigure{contract@paragraph@font}{2}
\Configure{contract@paragraph@font}{\HCode{<br /><span class="paragraph" />}}{}

\Css{.sentence{margin-left:2em;}}


Regarding error tex4ht reports on the first \Paragraph, if I insert blank line between \begin{contract} and \Paragraph{title=Does it make sense?}, this error disappear.

The result now looks this way:

It would be best, if we can put div with some class attribute on each paragraph and sentence, but I still don't know how

-
First of all, thank you for your help. It seems to be a complex issue. Strange enough, sometimes I get good output (titles of paragraphs in bold), and sometimes not. And as you mentioned, errors. However, that's a start. – Keks Dose Aug 17 '11 at 11:31
There is problem, that tex4ht is very complex and it's documentation is not the best, and with scrjura, this problem is the same + documentation is in German – michal.h21 Aug 17 '11 at 13:08
I does not work, unfortunately. In Word and OpenOffice there are no paragraphs, it looks like before: all in one line. – Keks Dose Aug 18 '11 at 9:15
Michal, thank you for your work, your edited solution looks promising! But what do I do with the file scrjura.4ht? Sorry for the stupid question. Regards, Alexander – Keks Dose Aug 18 '11 at 15:58
files with suffix .4ht are called when package of the same name is loaded. you must place it somewhere, where it can be found by LaTeX - in the current directory, or to your local texmf tree. see tex.stackexchange.com/questions/12701/… – michal.h21 Aug 18 '11 at 17:26