From 649bab8ff8f41ce5be38973f7bfbf8886ae70acb Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Tue, 21 Feb 2017 10:17:08 +0000 Subject: [PATCH] fix(aio): handle html docregions that do not end on the same line --- .../services/region-matchers/html.js | 6 +++--- .../services/region-matchers/html.spec.js | 14 +++++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/aio/transforms/examples-package/services/region-matchers/html.js b/aio/transforms/examples-package/services/region-matchers/html.js index 9305f2162f..4528c10750 100644 --- a/aio/transforms/examples-package/services/region-matchers/html.js +++ b/aio/transforms/examples-package/services/region-matchers/html.js @@ -1,7 +1,7 @@ // These kind of comments are used in HTML module.exports = { - regionStartMatcher: /^\s*\s*$/, - regionEndMatcher: /^\s*\s*$/, - plasterMatcher: /^\s*\s*$/, + regionStartMatcher: /^\s*)?\s*$/, + regionEndMatcher: /^\s*\s*$/, + plasterMatcher: /^\s*\s*$/, createPlasterComment: plaster => `` }; diff --git a/aio/transforms/examples-package/services/region-matchers/html.spec.js b/aio/transforms/examples-package/services/region-matchers/html.spec.js index 7a3cbf006b..9764b16a73 100644 --- a/aio/transforms/examples-package/services/region-matchers/html.spec.js +++ b/aio/transforms/examples-package/services/region-matchers/html.spec.js @@ -6,7 +6,7 @@ describe('html region-matcher', () => { matches = matcher.regionStartMatcher.exec(''); expect(matches).not.toBeNull(); - expect(matches[1]).toEqual('A b c '); + expect(matches[1]).toEqual('A b c'); matches = matcher.regionStartMatcher.exec(''); expect(matches).not.toBeNull(); @@ -22,7 +22,7 @@ describe('html region-matcher', () => { matches = matcher.regionEndMatcher.exec(''); expect(matches).not.toBeNull(); - expect(matches[1]).toEqual('A b c '); + expect(matches[1]).toEqual('A b c'); matches = matcher.regionEndMatcher.exec(''); expect(matches).not.toBeNull(); @@ -33,12 +33,20 @@ describe('html region-matcher', () => { expect(matches[1]).toEqual(''); }); + it('should handle annotations that do not close the comment on the same line', () => { + let matches; + + matches = matcher.regionStartMatcher.exec(''); expect(matches).not.toBeNull(); - expect(matches[1]).toEqual('A b c '); + expect(matches[1]).toEqual('A b c'); matches = matcher.plasterMatcher.exec(''); expect(matches).not.toBeNull();