Last active
August 30, 2015 08:55
-
-
Save michal-h21/6104f70091e0f4fead36 to your computer and use it in GitHub Desktop.
LaTeX to TEI conversion. context: http://tex.stackexchange.com/q/263548/2891
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\renewcommand\SetSemanticMarkup[1]{\typeout{semantic markup}} | |
\Preamble{xhtml,tei} | |
\Configure{VERSION}{} | |
\Configure{DOCTYPE}{} | |
\Configure{HTML}{\HCode{<TEI xmlns="http://www.tei-c.org/ns/1.0">\Hnewline}}{\HCode{\Hnewline</TEI>}} | |
\ifdefined\ifmathml\else | |
\newif\ifmathml | |
\mathmlfalse | |
\fi | |
\csname :CheckOption\endcsname{mathml}\csname if:Option\endcsname\mathmltrue\fi | |
\begin{document} | |
\EndPreamble |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{article} | |
\title{hello world} | |
\author{Some Author} | |
\usepackage{semanticmarkup} | |
\SetSemanticMarkup { | |
\term = \textit, | |
\scare = \enquote, | |
\socalled = \enquote, | |
\q = \enquote, | |
} | |
\begin{document} | |
\maketitle | |
hi | |
\term{hi} | |
\scare{hi} | |
\socalled{hi} | |
\term{Musica ficta} is the practice of adding accidentals where they are not notated. | |
The teacher told us, \q{Always sing F-sharp before a cadence on G\@!} | |
\end{document} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<TEI xmlns="http://www.tei-c.org/ns/1.0"> | |
<teiHeader type="text" status="new"><fileDesc> <titleStmt> | |
<title>hello world</title> | |
<author>Some Author</author> | |
</titleStmt> | |
<publicationStmt> <p></p> </publicationStmt> | |
<sourceDesc><p>sample.xml from sample.tex (TeX4ht, 2015-08-29 00:47:00)</p></sourceDesc> | |
</fileDesc> | |
<revisionDesc><list type="simple"><item></item></list></revisionDesc> | |
</teiHeader><text><front> | |
hi | |
<!--l. 16--><div type="p"><p> <term>hi</term> | |
</p></div><!--l. 18--><div type="p"><p> <scare>“hi”</scare> | |
</p></div><!--l. 20--><div type="p"><p> <socalled>“hi”</socalled> | |
</p></div><!--l. 22--><div type="p"><p> <term>Musica ficta</term> is the practice of adding accidentals where they are not | |
notated. The teacher told us, <q>“Always sing F-sharp before a cadence on | |
G!”</q> | |
</p></div></front><body><p></p></body></text> | |
</TEI> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\ExplSyntaxOn | |
\seq_map_inline:Nn \teicommands { | |
\pend:defI#1{\HCode{<\cs_to_str:N#1>}} | |
\append:defI#1{\HCode{</\cs_to_str:N#1>}} | |
} | |
\ExplSyntaxOff |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\ProvidesPackage{semanticmarkup} | |
\RequirePackage{xparse} | |
\ExplSyntaxOn | |
\seq_new:N \teicommands | |
\NewDocumentCommand \SetSemanticMarkup { m } | |
{ | |
\clist_map_inline:nn { #1 } | |
{ | |
\SetEquivalent{ ##1 } | |
} | |
} | |
\NewDocumentCommand{\SetEquivalent}{ >{\SplitArgument{1}{=}} m } | |
{ | |
\cashner_set_equivalent:nn #1 | |
} | |
\cs_new_protected:Nn \cashner_set_equivalent:nn | |
{ | |
\seq_gput_right:Nn \teicommands {#1} | |
\cs_new_eq:NN #1 #2 | |
} | |
\ExplSyntaxOff | |
\usepackage{csquotes} | |
\endinput |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment