Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@amermathsoc/texml-to-html
Advanced tools
A NodeJS library for converting AMS-style JATS XML to HTML
Converting texml-generated JATS/BITS-like XML to HTML.
For a first test run, try an example, e.g.,
$ npm i @amermathsoc/texml-to-html
$ node node_modules/@amermathsoc/texml-to-html/examples/cli.js node_modules/@amermathsoc/texml-to-html/text/article.xml > htmlOutput.html
import fs from "fs";
import path from "path";
import xml2html from "@amermathsoc/texml-to-html";
const article = xml2html(
fs.readFileSync(path.resolve(process.argv[2])).toString()
).window.document;
console.log(article.toString());
Our general strategy for elements and attributes is to follow allow-lists and discard everything else.
We primarily we are recursing through the input DOM, building the output DOM. Rarely, we deviate from this approach for practical reasons (e.g., for metadata extraction).
Some elements in texml's XML output have the same name (and purpose) as in HTML. We preserve them in the output:
The following custom tag names are preserved:
\cite
)Some attributes in texml's XML output have the same name (and purpose) in HTML.
As per our general strategy, we only preserve some attributes on some elements.
data-*
attributesBeyond HTML element and attributes, texml-to-html stores data in custom data-*
attributes. The following lists should help as a guide to understand the this structural information.
:warning: This list can easily fall out of date. It should be automated.
data-*
attribute values and origintoc-entry@specific-use
[expected: section, chapter, etc.]data-*
attributesWhile the vast majority of data attributes originate in texml-to-html, we have a few cases where downstream tooling introduces custom attributes. We list the attribute names, the related tools and purpose:
role
valuesThe following ARIA-DPUB role attribute values are used:
data-*
mappingsThe following provide a list from the reverse point of view.
\textrm{...}
(if inside text
)$\mathsc{...}$
(if inside text)\texttt{...}
(if inside text)\xhref[@ref-type]{#@rid}{...}
(if inside disp/inline-formula)$...$
$
Publication metadata (both journal/series and article/book metadata) is primarily stored in a JSON blob in a script
tag in the frontmatter (for articles) and titlepage (for books) sections respectively.
Section metadata (contributor metadata and pre-generated byline) is stored similarly as a json blob inside the data-ams-contributors
attribute.
The relevant components in texml-to-html
(i.e., article-metadata-json.js
, book-meta-json.js
, sec-meta.js
) should provide a (hopefully easy enough) overview how the XML metadata is mapped and stored. The snapshots in the test
folder should also be helpful, alongside any (example) article's JSON blob.
The following are commonly found metadata items:
For journal articles:
<article-meta>
<contrib-group>
etc (cf. "contributors" below)<self-uri>
<title-group>
etc<pub-date>
etc<notes>
<kwd-group>
<compound-kwd>
etc)<kwd>
)<related-article>
etc (correction/erratum forward/backward)<custom-meta-group>
(communicated by, NOTI categories, NOTI titlepic)<funding-group>
/ <funding-statement>
<permissions>
<copyright-statement>
<history>
etc<article-id>
etc<abstract>
etc<volume>
, <issue>
<journal-meta>
<journal-id>
<journal-title-group>
etc<issn>
etc<publisher>
<self-uri>
etcFor books:
<collection-meta>
<publisher>
etc<title-group>
<volume-in-collection>
<volume-number>
<custom-meta-group>
(for subseries)
<book-meta>
<book-id>
etc<book-title-group>
etc<book-volume-number>
<publisher>
<contrib-group>
etc (cf. "contributors" below)<self-uri>
<title-group>
etc<pub-date>
etc<notes>
<issn>
<isbn>
<permissions>
<front-matter>
<toc>
etc<notes>
<preface>
<front-matter-part>
Note. There is some overlap with other sections of this document. Ensure that updates are consistent across the document.
For math mode, texml creates MathJax-optimized TeX strings that may contain XML markup; for content not supported by MathJax it falls back to SVG creation. This mix requires extra processing.
Math mode output may contain xref elements. This gets turned into something like \xhref[@ref-type]{#@rid}{...}
; the custom xhref
MathJax macro works in both (MathJax's) text and math mode.
In the case where math mode contains text mode, texml creates text elements possibly containing text XML markup. We turn this into MathJax-compatible TeX strings.
text
only appears inside tex-math; it is converted to \\text{...}
italic
creates \textit{}
bold
creates \textbf{}
roman
creats \textrm{...}
sc
creates $\mathsc{...}$
monospace
creates \texttt{...}
ext-link
creates \href{}{}
as(which works in both text and math mode)In the case where math mode is nested (math mode inside text mode inside math mode), we have to adjust our processing to create MathJax-compatible TeX strings.
$...$
Note. Since the markup and attributes are heavily scoped, we do not reproduce the attributes in other sections.
Texml creates pseudo-namespaced elements for algorithm layout (e.g., from algorithmicx pacakge).
We convert the markup to HTML custom elements with attributes. Further processing happens downstream to enable adequate styling.
FAQs
A NodeJS library for converting AMS-style JATS XML to HTML
We found that @amermathsoc/texml-to-html demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.