Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doing something of LaTeX commands when generating HTML #165

Closed
jgm opened this issue Jun 10, 2011 · 9 comments
Closed

Doing something of LaTeX commands when generating HTML #165

jgm opened this issue Jun 10, 2011 · 9 comments

Comments

@jgm
Copy link
Owner

jgm commented Jun 10, 2011

I use Pandoc to generate both LaTeX and HTML. One
troublesome thing with this is that if one has
literal LaTeX commands in the markdown these just
vanish if one tries to generate HTML from the same
markdown. It would be much better if they were
turned into HTML spans with the LaTeX command name
as a class and the argument(s) as content.  Then
one could still make the text make sense, and do
something sensible with those spans, including
setting them to display: none, *if* that's the
sensible thing to do!  Thus

    \foo{bar}

would be HTML-ified as 

    <span class="foo">bar</span>

and

    \foo{bar}{baz}{biz}

would become

    <span class="foo">
      <span class="arg1">bar</span>
      <span class="arg2">baz</span>
      <span class="arg3">biz</span>
    </span>

which would increase once chances of making something
sensible of them with CSS.

Needless to say \begin{foo} and \end{foo} should be special
and become <div class="foo"> and </div> respectively (and 
arguments to the environment becoming additional classes).

As long as ones LaTeX commands are relatively
simple -- and I at least mostly use them for font
changes and the like -- this would be much better
than getting nothing!  Clearly it wouldn't make
much sense to generate HTML from markdown which
contains a lot of *complicated* LaTeX anyway.
However it might be a good idea to have a command
line switch with a filename as an optional
argument: if the switch is present LaTeX commands
will be turned into HTML spans and if the filename
is present it contains a list of LaTeX commands
which will just be deleted, alternatively ones
which will be turned into HTML spans.


Google Code Info:
Issue #: 198
Author: bpjonsson
Created On: 2010-01-07T16:48:50.000Z
Closed On: 
@ghost ghost assigned jgm Jun 10, 2011
@jgm
Copy link
Owner Author

jgm commented Jun 10, 2011

I wonder whether this would be a way to enable language tagging when converting from
LaTeX to HTML.

Google Code Info:
Author: google-c...@pragmata.tk
Created On: 2010-01-10T11:20:26.000Z

@jgm
Copy link
Owner Author

jgm commented Jun 10, 2011

I was just thinking about this too. Specifically I'd like to get label and ref tags and use javascript for cross referencing figs and math with numbering.

Google Code Info:
Author: mpastell
Created On: 2011-01-07T11:21:15.000Z

@jgm
Copy link
Owner Author

jgm commented Jun 10, 2011

Handling \ref and \label in a cross-platform way is very complicated.

If you just want automatic numbering of equations, with the ability to refer back, you should try the auto-numbered examples in pandoc's markdown:

(@myeqn) $e=mc^2$

As shown in ___, (@myeqn) is a refinement of ...

Google Code Info:
Author: fiddloso...@gmail.com
Created On: 2011-01-07T17:16:40.000Z

@jgm
Copy link
Owner Author

jgm commented Jun 10, 2011

Thanks for the quick comment. Numbered examples are nice, but not quite enough for what I need in all cases.

Would you still consider adding ref and label support to pandoc extended markdown syntax and reader? Latex and texinfo (http://www.gnu.org/software/hello/manual/texinfo/ref.html) can do this and in HTML you could use the ID tag for labels and refs would be fairly easy to handle with javascript.

Of course using labels would require the ability to specify the label for figures, tables, equations and code so I know this requires some changes.

Google Code Info:
Author: mpastell
Created On: 2011-01-10T10:24:12.000Z

@jgm
Copy link
Owner Author

jgm commented Jun 10, 2011

What would \ref{foo} and \label{foo} be rendered as in HTML?

In LaTeX you might have:

In figure~\ref{fig1} in section~\ref{sec1}, ...

To render this properly, pandoc would have to know that fig1 is a label for a figure, and sec1 for a section, and pandoc would have to keep track of numbering for both. In addition there's the problem that default HTML and LaTeX output in pandoc doesn't number sections.

Google Code Info:
Author: fiddloso...@gmail.com
Created On: 2011-01-10T16:10:09.000Z

@jgm
Copy link
Owner Author

jgm commented Jun 10, 2011

I think \ref{foo} could be rendered as <span class="ref">foo</a> as suggested
by bpjonsson above. And \label{foo} could become <div id="foo">. Then
pandoc would not need to handle the numbering and cross-refences and
they could be later processed e.g. with javascript to produce figure
numbers and references.

For figures Pandoc could use the title argument as label and ID as follows:

![Some caption](myfig.png)

In HTML:

<div class="figure">
     <img src="myfig.png" title="mylabel" alt="Some caption"/>
     <p class="caption" id="mylabel">Some caption</p>
</div>

And in Latex:

\begin{figure}[htb]
    \centering
    \includegraphics{myfig.png}
    \label{mylabel} 
    \caption{Some caption}
\end{figure}

I guess tables and equations would need some additional syntax to add
labels and table and fig captions need to have a different class in HTML.

I think I should be able to produce the required javascript and I'm
also willing to help out otherwise, but I'm just beginning with Haskell.

Google Code Info:
Author: mpastell
Created On: 2011-01-10T18:35:38.000Z

@mb21
Copy link
Collaborator

mb21 commented Feb 2, 2019

This seems mostly implemented now. Closing in favour of more specific issues, if remaining.

@mb21 mb21 closed this as completed Feb 2, 2019
@bpj
Copy link

bpj commented Mar 15, 2019

Hey @mb21 not so fast! What about -f latex+styles \myWhackyCommand{foo} ---> [foo]{custom-style="myWhackyCommand"} at least when there is just one argument? Is there a more specific issue for that? Feel free to list some of those issues then!

@mb21
Copy link
Collaborator

mb21 commented Mar 15, 2019

@jgm jgm mentioned this issue Jun 14, 2019
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants