UNPKG

3.39 kBJavaScriptView Raw
1var __extends = (this && this.__extends) || (function () {
2 var extendStatics = function (d, b) {
3 extendStatics = Object.setPrototypeOf ||
4 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6 return extendStatics(d, b);
7 };
8 return function (d, b) {
9 extendStatics(d, b);
10 function __() { this.constructor = d; }
11 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12 };
13})();
14import { DocNodeKind, DocNode } from './DocNode';
15import { DocExcerpt, ExcerptKind } from './DocExcerpt';
16/**
17 * The style of escaping to be used with DocEscapedText.
18 */
19export var EscapeStyle;
20(function (EscapeStyle) {
21 /**
22 * Use a backslash symbol to escape the character.
23 */
24 EscapeStyle[EscapeStyle["CommonMarkBackslash"] = 0] = "CommonMarkBackslash";
25})(EscapeStyle || (EscapeStyle = {}));
26/**
27 * Represents a text character that should be escaped as a TSDoc symbol.
28 * @remarks
29 * Note that renders will normally apply appropriate escaping when rendering
30 * DocPlainText in a format such as HTML or TSDoc. The DocEscapedText node
31 * forces a specific escaping that may not be the default.
32 */
33var DocEscapedText = /** @class */ (function (_super) {
34 __extends(DocEscapedText, _super);
35 /**
36 * Don't call this directly. Instead use {@link TSDocParser}
37 * @internal
38 */
39 function DocEscapedText(parameters) {
40 var _this = _super.call(this, parameters) || this;
41 _this._escapeStyle = parameters.escapeStyle;
42 _this._encodedTextExcerpt = new DocExcerpt({
43 configuration: _this.configuration,
44 excerptKind: ExcerptKind.EscapedText,
45 content: parameters.encodedTextExcerpt
46 });
47 _this._decodedText = parameters.decodedText;
48 return _this;
49 }
50 Object.defineProperty(DocEscapedText.prototype, "kind", {
51 /** @override */
52 get: function () {
53 return DocNodeKind.EscapedText;
54 },
55 enumerable: false,
56 configurable: true
57 });
58 Object.defineProperty(DocEscapedText.prototype, "escapeStyle", {
59 /**
60 * The style of escaping to be performed.
61 */
62 get: function () {
63 return this._escapeStyle;
64 },
65 enumerable: false,
66 configurable: true
67 });
68 Object.defineProperty(DocEscapedText.prototype, "encodedText", {
69 /**
70 * The text sequence including escapes.
71 */
72 get: function () {
73 if (this._encodedText === undefined) {
74 this._encodedText = this._encodedTextExcerpt.content.toString();
75 }
76 return this._encodedText;
77 },
78 enumerable: false,
79 configurable: true
80 });
81 Object.defineProperty(DocEscapedText.prototype, "decodedText", {
82 /**
83 * The text without escaping.
84 */
85 get: function () {
86 return this._decodedText;
87 },
88 enumerable: false,
89 configurable: true
90 });
91 /** @override */
92 DocEscapedText.prototype.onGetChildNodes = function () {
93 return [this._encodedTextExcerpt];
94 };
95 return DocEscapedText;
96}(DocNode));
97export { DocEscapedText };
98//# sourceMappingURL=DocEscapedText.js.map
\No newline at end of file