Skip to content

Commit d547b70

Browse files
author
Airan Shao
committed
Fix: unable to parse end of the document marker (...)
In Regexp, '^' and '$' by default match the beginning and end of the whole string rather than a single line. In Parser.parse(), each line is a separate string, so this is fine. But in Parser.cleanup(), the whole document is a single string. To allow '^' and '$' matching the beginning and end of line in this string, we need modifier 'm' to make RegExp work in multiline mode.
1 parent 97d39b6 commit d547b70

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Parser.coffee

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ class Parser
1919
PATTERN_DECIMAL: new Pattern '\\d+'
2020
PATTERN_INDENT_SPACES: new Pattern '^ +'
2121
PATTERN_TRAILING_LINES: new Pattern '(\n*)$'
22-
PATTERN_YAML_HEADER: new Pattern '^\\%YAML[: ][\\d\\.]+.*\n'
23-
PATTERN_LEADING_COMMENTS: new Pattern '^(\\#.*?\n)+'
24-
PATTERN_DOCUMENT_MARKER_START: new Pattern '^\\-\\-\\-.*?\n'
25-
PATTERN_DOCUMENT_MARKER_END: new Pattern '^\\.\\.\\.\\s*$'
22+
PATTERN_YAML_HEADER: new Pattern '^\\%YAML[: ][\\d\\.]+.*\n', 'm'
23+
PATTERN_LEADING_COMMENTS: new Pattern '^(\\#.*?\n)+', 'm'
24+
PATTERN_DOCUMENT_MARKER_START: new Pattern '^\\-\\-\\-.*?\n', 'm'
25+
PATTERN_DOCUMENT_MARKER_END: new Pattern '^\\.\\.\\.\\s*$', 'm'
2626
PATTERN_FOLDED_SCALAR_BY_INDENTATION: {}
2727

2828
# Context types

0 commit comments

Comments
 (0)