File tree Expand file tree Collapse file tree 3 files changed +27
-27
lines changed Expand file tree Collapse file tree 3 files changed +27
-27
lines changed Original file line number Diff line number Diff line change 1
1
import text/Buffer
2
2
3
- String : cover from Char* {
4
- /* *
5
- Escape < > & " ' characters in the string.
6
- */
7
- escapeHTML : func -> This {
8
- // Allocate a buffer to hold the escaped string
9
- // as we build it. Give it some extra space since
10
- // each escaped char will increase length.
11
- // Hopefully this will help avoid re-sizes most of the time.
12
- escaped := Buffer new (this length () + 128 )
3
+ /* *
4
+ Escape < > & " ' characters in the string.
5
+ */
6
+ escapeHTML : func (text : String ) -> String {
7
+ // Allocate a buffer to hold the escaped string
8
+ // as we build it. Give it some extra space since
9
+ // each escaped char will increase length.
10
+ // Hopefully this will help avoid re-sizes most of the time.
11
+ escaped := Buffer new (text length () + 128 )
13
12
14
- for (c : Char in this ) {
15
- e : String = match c {
16
- case '<' => "<"
17
- case '>' => ">"
18
- case '&' => "&"
19
- case '"' => """
20
- case '\' ' => "'"
21
- case =>
22
- escaped append (c)
23
- continue
24
- "null"
25
- }
26
- escaped append (e)
13
+ for (c : Char in text) {
14
+ e : String = match c {
15
+ case '<' => "<"
16
+ case '>' => ">"
17
+ case '&' => "&"
18
+ case '"' => """
19
+ case '\' ' => "'"
20
+ case =>
21
+ escaped append (c)
22
+ continue
23
+ "null"
27
24
}
28
-
29
- return escaped toString ()
25
+ escaped append (e)
30
26
}
27
+
28
+ return escaped toString ()
31
29
}
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ VariableNode: class extends TNode {
53
53
variableText := variable emit ()
54
54
if (escape) {
55
55
// Escape any HTML in the text
56
- variableText = variableText escapeHTML ()
56
+ variableText = escapeHTML (variableText )
57
57
}
58
58
59
59
// Write variable text to output stream
Original file line number Diff line number Diff line change @@ -33,7 +33,9 @@ YAMLContext: class extends Context {
33
33
}
34
34
35
35
nodeToValue : static func (node : DocumentNode ) -> Value {
36
- match node class {
36
+ nodeType := node class
37
+
38
+ match nodeType {
37
39
case ScalarNode => scalarToValue (node as ScalarNode )
38
40
case SequenceNode => sequenceToListValue (node as SequenceNode )
39
41
case MappingNode => mappingToHashValue (node as MappingNode )
You can’t perform that action at this time.
0 commit comments