diff options
author | Airan Shao <shaoairan@gmail.com> | 2017-02-11 14:31:07 +0800 |
---|---|---|
committer | Airan Shao <shaoairan@gmail.com> | 2017-02-11 14:31:07 +0800 |
commit | d547b70f0c56b0c28f06dce6d77b5ff4a126fcfe (patch) | |
tree | 5e01cc9b5603ded6035136a9a2c3546f4e502f68 | |
parent | 97d39b6c2bf533d33538205a399638b63f6baa66 (diff) | |
download | yamljs-d547b70f0c56b0c28f06dce6d77b5ff4a126fcfe.tar.gz |
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.
-rw-r--r-- | src/Parser.coffee | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Parser.coffee b/src/Parser.coffee index c0299d9..d196b27 100644 --- a/src/Parser.coffee +++ b/src/Parser.coffee @@ -19,10 +19,10 @@ class Parser PATTERN_DECIMAL: new Pattern '\\d+' PATTERN_INDENT_SPACES: new Pattern '^ +' PATTERN_TRAILING_LINES: new Pattern '(\n*)$' - PATTERN_YAML_HEADER: new Pattern '^\\%YAML[: ][\\d\\.]+.*\n' - PATTERN_LEADING_COMMENTS: new Pattern '^(\\#.*?\n)+' - PATTERN_DOCUMENT_MARKER_START: new Pattern '^\\-\\-\\-.*?\n' - PATTERN_DOCUMENT_MARKER_END: new Pattern '^\\.\\.\\.\\s*$' + PATTERN_YAML_HEADER: new Pattern '^\\%YAML[: ][\\d\\.]+.*\n', 'm' + PATTERN_LEADING_COMMENTS: new Pattern '^(\\#.*?\n)+', 'm' + PATTERN_DOCUMENT_MARKER_START: new Pattern '^\\-\\-\\-.*?\n', 'm' + PATTERN_DOCUMENT_MARKER_END: new Pattern '^\\.\\.\\.\\s*$', 'm' PATTERN_FOLDED_SCALAR_BY_INDENTATION: {} # Context types |