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

Function convertRun

static/word2md/mammoth.browser.js:237–277  ·  view source on GitHub ↗
(run, messages, options)

Source from the content-addressed store, hash-verified

235 }
236
237 function convertRun(run, messages, options) {
238 var nodes = function() {
239 return convertElements(run.children, messages, options);
240 };
241 var paths = [];
242 if (run.isSmallCaps) {
243 paths.push(findHtmlPathForRunProperty("smallCaps"));
244 }
245 if (run.isStrikethrough) {
246 paths.push(findHtmlPathForRunProperty("strikethrough", "s"));
247 }
248 if (run.isUnderline) {
249 paths.push(findHtmlPathForRunProperty("underline"));
250 }
251 if (run.verticalAlignment === documents.verticalAlignment.subscript) {
252 paths.push(htmlPaths.element("sub", {}, {fresh: false}));
253 }
254 if (run.verticalAlignment === documents.verticalAlignment.superscript) {
255 paths.push(htmlPaths.element("sup", {}, {fresh: false}));
256 }
257 if (run.isItalic) {
258 paths.push(findHtmlPathForRunProperty("italic", "em"));
259 }
260 if (run.isBold) {
261 paths.push(findHtmlPathForRunProperty("bold", "strong"));
262 }
263 var stylePath = htmlPaths.empty;
264 var style = findStyle(run);
265 if (style) {
266 stylePath = style.to;
267 } else if (run.styleId) {
268 messages.push(unrecognisedStyleWarning("run", run));
269 }
270 paths.push(stylePath);
271
272 paths.forEach(function(path) {
273 nodes = path.wrap.bind(path, nodes);
274 });
275
276 return nodes();
277 }
278
279 function findHtmlPathForRunProperty(elementType, defaultTagName) {
280 var path = findHtmlPath({type: elementType});

Callers

nothing calls this directly

Calls 4

findStyleFunction · 0.70
unrecognisedStyleWarningFunction · 0.70
nodesFunction · 0.70

Tested by

no test coverage detected