Fix for triply or greater nested fragments and trailing nullLine markers

This commit is contained in:
Jay Traband 2015-08-10 20:41:59 -07:00
parent 826e3dade9
commit 713a428bb6
2 changed files with 28 additions and 3 deletions

View File

@ -17,10 +17,10 @@ module.exports = function regionExtractor() {
lines.forEach(function(line, ix) {
if (isCommentLine(line, commentPrefixes)) {
if (hasRegionTag(line)) {
if (doc) docStack.push(doc);
doc = {startIx: ix, regionName: getRegionName(line)};
lines[ix] = nullLine;
docs.push(doc);
docStack.push(doc);
} else if (hasEndRegionTag(line)) {
lines[ix] = nullLine;
doc.endIx = ix;
@ -38,8 +38,11 @@ module.exports = function regionExtractor() {
}
// eliminate all #docregion lines
var rx = new RegExp(nullLine + '\n', 'g');
doc.content = content.replace(rx, '');
var content = content.replace(rx, '');
if (content.substr(-3) === nullLine) {
content = content.substr(0, content.length-3);
}
doc.content = content;
});
return docs;
}

View File

@ -0,0 +1,22 @@
// #docregion
// #docregion import
import {Component, View, bootstrap} from 'angular2/angular2';
// #enddocregion
//#docregion class-w-annotations
@Component({
selector: 'my-app'
})
@View({
template: '<h1 id="output">Hello, Angular 2!</h1>'
})
//#docregion class
class MyAppComponent {
}
//#enddocregion
//#enddocregion
//#docregion bootstrap
bootstrap(MyAppComponent);
//#enddocregion
//#enddocregion