Repository navigation
This release fixes fonts, font sizes and line spacing. Output is now much closer or identical to LaTeX when font declarations or size changes are combined with environments, lists, math and \verb.
⚠️ HTML output now includes a doctype
The standalone HTML written by the CLI now starts with <!DOCTYPE html>. Without a doctype, browsers render the page in quirks mode. In quirks mode, CSS class names are case-insensitive, so \large, \Large, and \LARGE all rendered in the same size, and line heights were calculated differently.
If you serialize htmlDocument() yourself, add the doctype too:
const html = '<!DOCTYPE html>' + generator.htmlDocument().documentElement.outerHTML;Fixes
Fonts, sizes and spacing
- Font family and shape now combine as they do in LaTeX (NFSS). For example,
\texttt{\textup{...}}used to come out in serif and now stays typewriter. The same applies to sans serif. - Font declarations now apply inside environments. In
{\small\bfseries \begin{itemize}...\end{itemize}}, the list content is now small and bold. This includes theabstractenvironment. - A space after an environment no longer keeps the environment's font.
- When a font command's argument contains block content (e.g. an environment inside
\textbf{...}), block elements are no longer wrapped in an inline element. Block and inline content are now wrapped separately. - Paragraph line spacing (
\baselineskip) now follows the font size in effect at the end of the paragraph, as in LaTeX. Only the spacing changes; the size of the earlier text stays the same. - List items, math and
\verbnow use the current font size. - Web component: the CSS no longer uses
remunits.remsizes are relative to the host page's<html>element, not to the component, so every LaTeX.js component on a page got the same text size. Each component now uses the font size set in its own LaTeX source. - Computer Modern Slanted: in Firefox, the already-slanted glyphs were slanted a second time. The
@font-facedescriptors had confused oblique with italic; this is fixed. - KaTeX font stacks now have generic
serif/sans-seriffallbacks.
Parsing
\labeland\refnow accept underscores, e.g.\label{sec:my_label}(#177, thanks @draarivpatel-ui).- A group that ends directly after an environment no longer starts an empty paragraph.
- The "continue" marker (no indent after an environment) is now applied only to paragraphs. Before, it went to whichever element was created first.
Documentation and website
- The usage examples no longer contain both
<meta charset>and<meta http-equiv="content-type">, which is invalid HTML (#145). - Opening https://latex.js.org/playground.html directly now works.
- Documented raw macro arguments (thanks @draarivpatel-ui).
- The website now uses VitePress 2.0 (alpha).
API changes for custom generators and macro authors
- New macro argument type
"r": raw text in{}, passed to the macro as a string without being parsed as LaTeX. Generator.macro(name, args, addAttributes = true)has a new optional third parameter. Passfalseto keep the current font attributes off the returned nodes. Environments use this.Generator.createVerbatim(text)is nowcreateVerbatim(t: string): TNode. It returns the complete\verbelement (typewriter font, current size). Before, it returned a bare text node that the parser wrapped.Generator.setTitle(title)has been replaced bymakeDocumentTitle(), which reads the title itself.- New attribute getters
fontFamily(),fontWeight(),fontShape()andtextDecoration(). The internal_inlineAttributes()moved fromGeneratortoHtmlGenerator. Length.min()now throws when called without arguments.
Dependencies
- Security updates for development dependencies:
minimatch11.0.9 andglob14.0.6. The runtime dependencies of the npm package are unchanged. - Removed the dev dependencies
vite-plugin-node-polyfillsandtsx.
Development and CI
- Tests are split into vitest projects (
unitandintegration). The integration shell scripts are now TypeScript tests and show up in the VS Code Testing view. - Screenshot tests always compare Chrome and Firefox. Screenshots are compressed with oxipng, and failed screenshots and HTML are archived in CI.
- CI is split into several jobs and runs in the same devcontainer image used for development.
- Sonar analysis now includes code coverage. Qlty replaces Code Climate.
.editorconfigand.gitattributesnow protect test fixtures that depend on exact whitespace and line endings.