[tex4ht] Problem with hyperref

Michal Hoftich michal.h21 at gmail.com
Fri Dec 22 17:52:05 CET 2017


Dear Guido,

you may also try the Markdown package, it enables direct Markdown
support in TeX and it works quite well with tex4ht. It also supports
mixing Markdown and LaTeX macros, so you can use all the Markdown
shortcuts for basic formatting and use LaTeX for more advanced stuff.

Back to your actual question:

Quoting Guido Milanese (2017-12-22 16:45:01)
> 
> <!--l. 65--><text:p text:style-name="First-line-indent">   <t4htlink 
>  href="#first-section" name="first-section">
>    </text:p> 
> 
> Changing to 
> 
> <!--l. 65--><text:p text:style-name="First-line-indent">   <t4htlink 
>  href="#first-section" name="first-section"></t4htlink>
>    </text:p> 
> 
> it's all right. The tag was indeed closed, but after 2 lines, not
> where I closed it. I removed the offending close_tag, moved as shown
> above and it's all right now.
> 
> I do not know if it's a bug or a mistake from my side.

It is definitely not a bug or a mistake on your side. The problem is
that the \hypertarget command inserts the opening link, which starts a
new paragraph. But the \section command closes this paragraph, which
leaved this opening link unclosed. After the end of section command, new
paragraph is started and the link is closed. This produces an invalid
XML structure, which causes the post-processing to fail.

You may try to use a following macro in a config file:

\def\hypertarget#1#2{\ifvmode\IgnorePar\EndP\fi\Link{}{#1}#2\ifvmode\IgnorePar\EndP\fi\EndLink}

This definition tries to insert the link outside of a paragraph, so the
XML is at least well-formed. It seems that the LibreOffice can open the
resulting file, so it seems to work somehow. This definition cannot be used 
for HTML, because the code it produces is non-valid. 

I also don't particularly like the \hypertarget use here. Why Pandoc
doesn't use only \label? 

> PS the reason why I'm going through LaTeX and not converting markdown
> --> ODT is that I like writing in markdown, but the final details of
> the project I'm currently working on need the "refinements" of LaTeX.

I think you may really like the Markdown package then.

Best regards,
Michal



More information about the tex4ht mailing list