3

I'm trying to convert a tex file to an xml.

In particular I'll be interested in understanding if it is possible to generate a TEI xml file (http://www.tei-c.org/index.xml) to be published online from a tex one.

Is there any info out there on how to proceed? Could you highlight a simple example on how to do this?

Thanks in advance,

Lucia

NickD
  • 5,937
  • 1
  • 21
  • 38

2 Answers2

0

First: This is not the magic spell to solve the question, but, as the question is very broad, my answer hopefully describes a reasonable strategy to tackle the issues at hand.

I see one problem: While LaTex is used to create a visual representation of a text, TEI is exactly the opposite. It just describes and encodes things that can be identified in a text, mostly independent from a representation. Because of that, the only reasonable way from LaTex to TEI is to create a representation of the LaTex output in a XML-close format (e.g. HTML) and then to convert that output in TEI. So you need a two-step procedure.

I think that one of the tools listed here will help you to generate a nice HTML output, probably LaTeXML comes very close to what you need. After that, you will need to translate this HTML output into TEI. If HTML elements are sufficient for you, a more or less simple transformation could already do the job, but this depends on requirements you did not specify.

There is, by the way, another question here that touches your question, maybe it is of interest.

friedemann_bach
  • 1,418
  • 14
  • 29
0

You can use pandoc (https://pandoc.org/). Given a LaTex document (let's call it data.txt) like this

\documentclass{article}
\begin{document}
  Hello World!
\end{document}

you may use pandoc like this

pandoc data.txt -f latex -t tei -o latexexample.xml

to generate XML consistent with TEI XML:

<p>Hello World!</p>
Thomas Hansen
  • 775
  • 1
  • 6
  • 17