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

Function createCommentsReader

static/word2md/mammoth.browser.js:1409–1434  ·  view source on GitHub ↗
(bodyReader)

Source from the content-addressed store, hash-verified

1407var Result = require("../results").Result;
1408
1409function createCommentsReader(bodyReader) {
1410 function readCommentsXml(element) {
1411 return Result.combine(element.getElementsByTagName("w:comment")
1412 .map(readCommentElement));
1413 }
1414
1415 function readCommentElement(element) {
1416 var id = element.attributes["w:id"];
1417
1418 function readOptionalAttribute(name) {
1419 return (element.attributes[name] || "").trim() || null;
1420 }
1421
1422 return bodyReader.readXmlElements(element.children)
1423 .map(function(body) {
1424 return documents.comment({
1425 commentId: id,
1426 body: body,
1427 authorName: readOptionalAttribute("w:author"),
1428 authorInitials: readOptionalAttribute("w:initials")
1429 });
1430 });
1431 }
1432
1433 return readCommentsXml;
1434}
1435
1436exports.createCommentsReader = createCommentsReader;
1437

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected