From d547b70f0c56b0c28f06dce6d77b5ff4a126fcfe Mon Sep 17 00:00:00 2001 From: Airan Shao Date: Sat, 11 Feb 2017 14:31:07 +0800 Subject: 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. --- src/Parser.coffee | 8 ++++---- 1 file 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 -- cgit v1.2.1