TeX - LaTeX Asked by Dave Jarvis on May 9, 2021

A document, having inline math statements, is being written in Markdown. The document is converted to XHTML for subsequent processing using ConTeXt.

The XHTML contains XML elements with inline TeX commands. The inline TeX commands are not interpreted by ConTeXt, resulting in output similar to the following:

Consider the following buffered XHTML snippet (e.g., generated from Markdown):

```
startbuffer[document]
<body>
<p>$N = R_{*} cdot f_{p} cdot n_{e} cdot f_{l} cdot f_{i} cdot f_{c} cdot L$</p>
</body>
stopbuffer
startxmlsetups xml:xhtml
xmlsetsetup{xmldocument}{*}{-}
xmlsetsetup{xmldocument}{body|p}{xml:*}
stopxmlsetups
startxmlsetups xml:body xmlflush{#1} stopxmlsetups
startxmlsetups xml:p
xmlflush{#1}par
stopxmlsetups
xmlregistersetup{xml:xhtml}
starttext
xmlprocessbuffer{xhtml}{document}{}
stoptext
```

It’s possible to produce documents that export new XHTML elements, such as:

```
<tex>$N = R_{*} cdot f_{p} cdot n_{e} cdot f_{l} cdot f_{i} cdot f_{c} cdot L$</tex>
```

Or even without the `$`

sigil:

```
<tex>N = R_{*} cdot f_{p} cdot n_{e} cdot f_{l} cdot f_{i} cdot f_{c} cdot L</tex>
```

However, TeX allows for both inline `$`

and block-level `$$`

syntax. These could be exported as `tex_inline`

and `tex_block`

elements, respectively, but that seems like duplication because ConTeXt already contains the parsing logic.

The problem is likely with the setups. Variations, such as those from the steps document, did not result in typeset math:

```
startbuffer[document]
<body>
<tex>$N = R_{*} cdot f_{p} cdot n_{e} cdot f_{l} cdot f_{i} cdot f_{c} cdot L$</tex>
</body>
stopbuffer
startxmlsetups xml:xhtml
xmlsetsetup{xmldocument}{*}{-}
xmlsetsetup{xmldocument}{body|p|tex}{xml:*}
stopxmlsetups
% ...
startxmlsetups xml:tex
mathematics{xmlflush{#1}}
stopxmlsetups
```

Even if it worked, this approach may prove problematic because users can insert (inline) TeX into any element: p, blockquotes, emphasis, strong, td, li, etc.

itex2MML and TeX4ht both convert TeX to MathML, but such a step should not be needed.

How would you embed inline/block-level TeX macros anywhere inside a well-formed XHTML document such that the macros will be typeset by ConTeXt?

(MathML is not a viable option for writing inside Markdown; conversion afterwards may be feasible.)

The following works:

```
% ...
<tex>$N = R_{*} cdot f_{p} cdot n_{e} cdot f_{l} cdot f_{i} cdot f_{c} cdot L$</tex>
% ...
startxmlsetups xml:tex
xmlflushcontext{#1}
stopxmlsetups
```

Using `$$`

also works.

Correct answer by Dave Jarvis on May 9, 2021

Get help from others!

Recent Answers

- haakon.io on Why fry rice before boiling?
- Jon Church on Why fry rice before boiling?
- Lex on Does Google Analytics track 404 page responses as valid page views?
- Peter Machado on Why fry rice before boiling?
- Joshua Engel on Why fry rice before boiling?

Recent Questions

- How can I transform graph image into a tikzpicture LaTeX code?
- How Do I Get The Ifruit App Off Of Gta 5 / Grand Theft Auto 5
- Iv’e designed a space elevator using a series of lasers. do you know anybody i could submit the designs too that could manufacture the concept and put it to use
- Need help finding a book. Female OP protagonist, magic
- Why is the WWF pending games (“Your turn”) area replaced w/ a column of “Bonus & Reward”gift boxes?

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP