UNPKG

1.83 kBTypeScriptView Raw
1/**
2 * Copyright (C) 2016-2019 Michael Kourlas
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16/**
17 * The options used to create a new comment.
18 */
19export interface IXmlCommentOptions {
20 /**
21 * The content of the comment.
22 */
23 charData: string;
24 /**
25 * Whether to replace any invalid characters in the content of the comment
26 * with the Unicode replacement character. By default, this is disabled.
27 */
28 replaceInvalidCharsInCharData?: boolean;
29}
30/**
31 * Represents a comment.
32 *
33 * A comment is structured as follows, where `{content}` is the text of the
34 * comment:
35 *
36 * ```xml
37 * <!--{content}-->
38 * ```
39 */
40export default class XmlComment<Parent> {
41 private readonly _replaceInvalidCharsInCharData;
42 private readonly _parent;
43 private readonly _validation;
44 private _charData;
45 constructor(parent: Parent, validation: boolean, options: IXmlCommentOptions);
46 /**
47 * Gets the text of this comment.
48 */
49 get charData(): string;
50 /**
51 * Sets the text of this comment.
52 */
53 set charData(charData: string);
54 /**
55 * Returns an XML string representation of this comment.
56 */
57 toString(): string;
58 /**
59 * Returns the parent of this comment.
60 */
61 up(): Parent;
62}