mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-18 01:08:40 +00:00
Treat svg-wrapping spans differently from DOM-wrapping spans. (#1239)
* Treat svg-wrapping spans differently from DOM-wrapping spans. In preparation for the conversion of buildHTML to @flow, separate the two different uses of domTree.span -- one to wrap a single SVG and one to wrap arbitrary DOM nodes. This separation is to help avoid type issues that pop up due to buildHTML methods accessing the .children field of spans as if they are DOM elements and not SVG ones. * Simplify the domTree DOM definitions based on separation of two span types.
This commit is contained in:
@@ -7,7 +7,7 @@ import Settings from "./Settings";
|
||||
import Style from "./Style";
|
||||
|
||||
import type ParseNode from "./ParseNode";
|
||||
import type domTree from "./domTree";
|
||||
import type {DomSpan} from "./domTree";
|
||||
|
||||
const optionsFromSettings = function(settings: Settings) {
|
||||
return new Options({
|
||||
@@ -20,7 +20,7 @@ export const buildTree = function(
|
||||
tree: ParseNode[],
|
||||
expression: string,
|
||||
settings: Settings,
|
||||
): domTree.span {
|
||||
): DomSpan {
|
||||
const options = optionsFromSettings(settings);
|
||||
// `buildHTML` sometimes messes with the parse tree (like turning bins ->
|
||||
// ords), so we build the MathML version first.
|
||||
@@ -42,7 +42,7 @@ export const buildHTMLTree = function(
|
||||
tree: ParseNode[],
|
||||
expression: string,
|
||||
settings: Settings,
|
||||
): domTree.span {
|
||||
): DomSpan {
|
||||
const options = optionsFromSettings(settings);
|
||||
const htmlNode = buildHTML(tree, options);
|
||||
const katexNode = buildCommon.makeSpan(["katex"], [htmlNode]);
|
||||
|
Reference in New Issue
Block a user