bugtex4ht - Bugs: bug #576, \HCode alternative that copies...

 
 
Show feedback again

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

bug #576: \HCode alternative that copies verbatim?

Submitted by:  Karl Berry <karl>
Submitted on:  Mon Aug 15 20:48:15 2022  
 
Category: NonePriority: 5 - Normal
Severity: 5 - NormalStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Closed

(Jump to the original submission Jump to the original submission)

Sun Aug 28 20:08:19 2022, comment #6:

Sure, just define the environment in this way in the document:

%%%%%%%%%%%%%%%%%%
\documentclass{article}
\NewDocumentEnvironment{foo}{+b}{}{}
\NewDocumentEnvironment{latexenv}{}{}{}
\long\def\FooCmd #1\EndFooCmd{}

\begin{document}

normal text

\begin{foo}
<p dir="auto">The following code shows the concept:</p>

<p dir="auto">This is another paragraph</p>
\end{foo}

normal text

\begin{latexenv}
$$E = mc^2$$ And this is \textit{latex}.
\end{latexenv}

\FooCmd
<p dir="auto">The following code shows the concept:</p>

<p dir="auto">This is another paragraph</p>
\EndFooCmd
\end{document}
%%%%%%%%%%%%%%%%%%%

And then redefine it to eat the argument in the configuration file:

%%%%%%%%%%%%%%%%
\Preamble{xhtml}
\ScriptEnv{foo}
{\ifvmode\IgnorePar\fi\EndP\NoFonts\hfill\break }
{\EndNoFonts }

\ScriptCommand{\FooCmd}
{\ifvmode\IgnorePar\fi\EndP\NoFonts\hfill\break }
{\EndNoFonts }
\RenewDocumentEnvironment{latexenv}{+b}{}{}
\begin{document}
\EndPreamble
%%%%%%%%%%%%%%%%

Michal Hoftich <michal_h21>
Project Member
Sat Aug 27 22:42:34 2022, comment #5:

Yet another related question: can there be a way to write normal LaTeX inside such an html-only environment? It can be inconvenient and perhaps impossible to end the html block, insert some TeX, and then restart the html.

That is, the ideal would be something like this:

The point of all this is to be able to write substantial math documents, with literal HTML parts for interactive features and other things that cannot be done in TeX, while still being able to write math in TeX.

wdyt? Thanks.

Karl Berry <karl>
Project Administrator
Fri Aug 26 19:32:11 2022, comment #4:

Ideally, you can define the \FooCmd and \EndFooCmd in the preamble, or in a custom package, and then redefine it in TeX4ht configuration file:

%%%%%%%%%%%%%%%%%%%%%%%
\documentclass{article}
\NewDocumentEnvironment{foo}{+b}{}{}
\long\def\FooCmd #1\EndFooCmd{}

\begin{document}

normal text

\begin{foo}
<p dir="auto">The following code shows the concept:</p>

<p dir="auto">This is another paragraph</p>
\end{foo}

normal text

\FooCmd
<p dir="auto">The following code shows the concept:</p>

<p dir="auto">This is another paragraph</p>
\EndFooCmd
\end{document}
%%%%%%%%%%%%%%%%%%

The configuration file could contain the TeX4ht commands from my previous post:

%%%%%%%%%%%%%%%%%%%%
\Preamble{xhtml}
\ScriptEnv{foo}
{\ifvmode\IgnorePar\fi\EndP\NoFonts\hfill\break }
{\EndNoFonts }

\ScriptCommand{\FooCmd}
{\ifvmode\IgnorePar\fi\EndP\NoFonts\hfill\break }
{\EndNoFonts }
\begin{document}
\EndPreamble
%%%%%%%%%%%%%%%%%

Michal Hoftich <michal_h21>
Project Member
Fri Aug 26 17:04:32 2022, comment #3:

Michal, related question: is there a nicer way than \ifx\HCode\undefined to test "are we running under tex4ht"? Clearly the \ScriptEnv construct, etc., need to be conditionalized ...
thanks.

Karl Berry <karl>
Project Administrator
Tue Aug 16 21:54:36 2022, comment #2:

way cool, thanks Michal.

Karl Berry <karl>
Project Administrator
Mon Aug 15 22:45:22 2022, comment #1:

Hi Karl, there are two ways how to support verbatim content, using \ScriptEnv or \ScriptCommand. See this example:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass{article}
\begin{document}
\ScriptEnv{foo}
{\ifvmode\IgnorePar\fi\EndP\NoFonts\hfill\break }
{\EndNoFonts }

\ScriptCommand{\FooCmd}
{\ifvmode\IgnorePar\fi\EndP\NoFonts\hfill\break }
{\EndNoFonts }

normal text

\begin{foo}
<p dir="auto">The following code shows the concept:</p>

<p dir="auto">This is another paragraph</p>
\end{foo}

normal text

\FooCmd
<p dir="auto">The following code shows the concept:</p>

<p dir="auto">This is another paragraph</p>
\EndFooCmd
\end{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Michal Hoftich <michal_h21>
Project Member
Mon Aug 15 20:48:15 2022, original submission:

Michal, or anyone, is there an alternative to \HCode that outputs its argument completely verbatim, ideally including line breaks?
It seems \HCode outputs a surrounding <p> and </p>.

It seems \HCode is inscrutably defined in the scripts, such as htlatex. At first glance, the definition makes no sense to me at all :).

Thanks.

Karl Berry <karl>
Project Administrator

 

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 michal_h21 (Posted a comment)
  • -unavailable- added by karl (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
    Tue Aug 16 21:54:46 2022karlOpen/ClosedOpen=>Closed
    Show feedback again

    Back to the top


    Powered by Savane 3.1-cleanup+gray