MCPcopy Create free account
hub / github.com/TruthHun/BookStack / toMarkup

Function toMarkup

static/katex/katex.mjs:1023–1057  ·  view source on GitHub ↗
(tagName)

Source from the content-addressed store, hash-verified

1021
1022
1023const toMarkup = function toMarkup(tagName) {
1024 let markup = `<${tagName}`; // Add the class
1025
1026 if (this.classes.length) {
1027 markup += ` class="${utils.escape(createClass(this.classes))}"`;
1028 }
1029
1030 let styles = ""; // Add the styles, after hyphenation
1031
1032 for (const style in this.style) {
1033 if (this.style.hasOwnProperty(style)) {
1034 styles += `${utils.hyphenate(style)}:${this.style[style]};`;
1035 }
1036 }
1037
1038 if (styles) {
1039 markup += ` style="${utils.escape(styles)}"`;
1040 } // Add the attributes
1041
1042
1043 for (const attr in this.attributes) {
1044 if (this.attributes.hasOwnProperty(attr)) {
1045 markup += ` ${attr}="${utils.escape(this.attributes[attr])}"`;
1046 }
1047 }
1048
1049 markup += ">"; // Add the markup of the children, also as markup
1050
1051 for (let i = 0; i < this.children.length; i++) {
1052 markup += this.children[i].toMarkup();
1053 }
1054
1055 markup += `</${tagName}>`;
1056 return markup;
1057}; // Making the type below exact with all optional fields doesn't work due to
1058// - https://github.com/facebook/flow/issues/4582
1059// - https://github.com/facebook/flow/issues/5688
1060// However, since *all* fields are optional, $Shape<> works as suggested in 5688

Callers

nothing calls this directly

Calls 2

createClassFunction · 0.70
toMarkupMethod · 0.45

Tested by

no test coverage detected