bugtex4ht - Bugs: bug #435, tex4ht: Creates invalid html...

 
 
Show feedback again

You are not allowed to post comments on this tracker with your current authentification level.

bug #435: tex4ht: Creates invalid html document when using \AtBeginDocument

Submitted by:  Hilmar Preusse <hpreusse>
Submitted on:  Fri Aug 9 14:43:31 2019  
 
Category: NonePriority: 5 - Normal
Severity: 3 - MinorStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Closed

Mon Aug 19 01:05:29 2019, comment #2:

no more to do, it seems. closing.

Karl Berry <karl>
Project Administrator
Wed Aug 14 08:06:40 2019, comment #1:

The `\AtBeginDocument` command is usually used to redefine macros and initialize stuff. This use works. What is the issue in this case is that it includes a text in the document. As tex4ht outputs the HTML header at this moment as well, it happens that the text goes before HTML.

I don't think we can fix that easily, as we want the code usually executed in `\AtBeginDocument` to be executed before any output is written. In this particular case, I would advice to edit the document:

-----------
\documentclass[english]{minimal}
\usepackage[utf8]{inputenc}

\newcommand\outputatbegin[1]{#1}

\makeatletter
\AtBeginDocument{\outputatbegin{\@title}}
\makeatother
\title{Minimal example}
\begin{document}
Test body.
\end{document}
------------

The `\outputbegin` command can then be redefined for tex4ht in a custom config file:

-------------
\Preamble{xhtml}
\renewcommand\outputatbegin[1]{\Configure{@BODY}{#1}}
\begin{document}
\EndPreamble
-------------

The redefinition uses the `\Configure{@BODY}` command that will output the text after the `<body>` tag.

Michal Hoftich <michal_h21>
Project Member
Fri Aug 9 14:43:31 2019, original submission:

https://bugs.debian.org/550381

htlatex produces invalid html document if the source contains
\AtBeginDocument directive. Minimal example comes here. The title is printed right at the top of the HTML code, i.e. even before the "<!DOCTYPE html" statement.

\documentclass[english]{minimal}
\usepackage[utf8]{inputenc}

\makeatletter
\AtBeginDocument{\@title}
\makeatother

\title{Minimal example}

\begin{document}
Test body.
\end{document}

Hilmar Preusse <hpreusse>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by karl (Posted a comment)
  • -unavailable- added by michal_h21 (Posted a comment)
  • -unavailable- added by hpreusse (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    1 latest change follows.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon Aug 19 01:05:29 2019karlOpen/ClosedOpen=>Closed
    Show feedback again

    Back to the top


    Powered by Savane 3.1-cleanup+gray