chirun-ncl / chirun

A Python package providing the command line interface for building flexible and accessible content with Chirun.
https://chirun.org.uk/
Other
29 stars 4 forks source link

\raisebox is ignored #136

Closed prowlett closed 8 months ago

prowlett commented 1 year ago

For example, doing this:

\documentclass{article}
\begin{document}
Don't \raisebox{-1ex}{drop} the ball.
\end{document}

looks like this in LaTeX:

"Don't drop the ball", with "drop" lower than the rest of the text.

but looks like this in the HTML version:

"Don't the ball"

i.e. the word "drop" is completely missing.

I presume this is because plastex doesn't know the command \raisebox.

An okay solution would be for the HTML version to simply output the contents of the second {}, ignoring the \raisebox{-1ex} bit but not eating its content, because at least the user gets to see the content. A good solution would do whatever \raisebox is asking for using CSS or something, but I can see that might be hard and I doubt it's a common issue.

My workaround is to do this in the preamble. What this does is interrupts the \raisebox command using \ifplastex from the chirun LaTeX package to work out whether this is the HTML version or not. If it's HTML, it outputs the content passes to \raisebox instead of trying to run \raisebox; if it's LaTeX, it runs the full \raisebox command as usual.

\usepackage{chirun}
\let\oldraisebox\raisebox
\renewcommand{\raisebox}[2]{\ifplastex #2\else\oldraisebox{#1}{#2}\fi}
christianp commented 1 year ago

Can you give some detail about what you wanted to use \raisebox for? What would you like it to do in HTML?

prowlett commented 1 year ago

If I recall correctly, I just had something I needed to align horizontally in the LaTeX PDF so I nudged it with a \raisebox. This caused it to vanish from the HTML, which I found alarming. It seems that if chirun doesn't understand a command it should either tell me it doesn't know what to do or ignore the command in a way that doesn't eat a block of content. I don't believe there is anything even in chirun -vv telling me that a command and the content it was acting on has been ignored. This is definitely a niche problem, but quietly omitting content isn't a great situation it seems to me.

My suggestion is that you add something like

\let\oldraisebox\raisebox
\renewcommand{\raisebox}[2]{\ifplastex #2\else\oldraisebox{#1}{#2}\fi}

to chirun.sty so that page content isn't quietly omitted if \raisebox is used.

One disadvantage is the hypothetical I propose above - that someone might actually want to use \raisebox to do something on the HTML page (though I don't know what), and my proposal would prevent them doing so, but no worse than the current situation.

Something else that has just occurred to me is that if plasTeX ever sorts out how it handles \raisebox this would conflict with that.

Another suggestion is that people can put the code above in the preamble of their .tex file if they have this problem, in which case it would be nice to tell them this - do you have a list of known issues and workarounds to which this could be added?

christianp commented 8 months ago

When plasTeX doesn't know about a command at all, it puts a warning in the output.

It looks like plasTeX had implemented empty versions of \raisebox and rule, so they wouldn't show an "unrecognised command" warning, but didn't produce any output. I can't see any reason for that. There's a lot of unfinished stuff in plasTeX, so maybe they just didn't get round to it.

I've added in proper rendering for \raisebox and \rule.

We do need to start a list of known issues in the documentation. From my perspective, I'm fixing everything I come across, so it will at first have to be quite generic advice about how to spot when packages or commands aren't implemented.