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