1 | ;
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.DocNodeTransforms = void 0;
|
4 | var TrimSpacesTransform_1 = require("./TrimSpacesTransform");
|
5 | /**
|
6 | * Helper functions that transform DocNode trees.
|
7 | */
|
8 | var DocNodeTransforms = /** @class */ (function () {
|
9 | function DocNodeTransforms() {
|
10 | }
|
11 | /**
|
12 | * trimSpacesInParagraphNodes() collapses extra spacing characters from plain text nodes.
|
13 | *
|
14 | * @remarks
|
15 | * This is useful when emitting HTML, where any number of spaces are equivalent
|
16 | * to a single space. It's also useful when emitting Markdown, where spaces
|
17 | * can be misinterpreted as an indented code block.
|
18 | *
|
19 | * For example, we might transform this:
|
20 | *
|
21 | * ```
|
22 | * nodes: [
|
23 | * { kind: PlainText, text: " Here are some " },
|
24 | * { kind: SoftBreak }
|
25 | * { kind: PlainText, text: " words" },
|
26 | * { kind: SoftBreak }
|
27 | * { kind: InlineTag, text: "{\@inheritDoc}" },
|
28 | * { kind: PlainText, text: "to process." },
|
29 | * { kind: PlainText, text: " " },
|
30 | * { kind: PlainText, text: " " }
|
31 | * ]
|
32 | * ```
|
33 | *
|
34 | * ...to this:
|
35 | *
|
36 | * ```
|
37 | * nodes: [
|
38 | * { kind: PlainText, text: "Here are some " },
|
39 | * { kind: PlainText, text: "words " },
|
40 | * { kind: InlineTag, text: "{\@inheritDoc}" },
|
41 | * { kind: PlainText, text: "to process." }
|
42 | * ]
|
43 | * ```
|
44 | *
|
45 | * Note that in this example, `"words "` is not merged with the preceding node because
|
46 | * its DocPlainText.excerpt cannot span multiple lines.
|
47 | *
|
48 | * @param docParagraph - a DocParagraph containing nodes to be transformed
|
49 | * @returns The transformed child nodes.
|
50 | */
|
51 | DocNodeTransforms.trimSpacesInParagraph = function (docParagraph) {
|
52 | return TrimSpacesTransform_1.TrimSpacesTransform.transform(docParagraph);
|
53 | };
|
54 | return DocNodeTransforms;
|
55 | }());
|
56 | exports.DocNodeTransforms = DocNodeTransforms;
|
57 | //# sourceMappingURL=DocNodeTransforms.js.map |
\ | No newline at end of file |