Fix for extra chars with explicit #docplaster in css and html files. + additional test cases.
This commit is contained in:
parent
3b76748cb5
commit
58b8242a25
@ -30,8 +30,8 @@ describe('doc-shredder', function() {
|
|||||||
fileNames.forEach(function(fileName) {
|
fileNames.forEach(function(fileName) {
|
||||||
console.log('comparing: ' + fileName);
|
console.log('comparing: ' + fileName);
|
||||||
var origFileName = fileName.replace('.ovr.', '.');
|
var origFileName = fileName.replace('.ovr.', '.');
|
||||||
var origSource = fs.readFileSync(origFileName, 'utf8');
|
var origSource = fs.readFileSync(origFileName, 'utf8').replace(/\r\n/g, '\n');
|
||||||
var expectedSource = fs.readFileSync(fileName, 'utf8');
|
var expectedSource = fs.readFileSync(fileName, 'utf8').replace(/\r\n/g, '\n');
|
||||||
var diffs = JsDiff.diffLines(expectedSource, origSource);
|
var diffs = JsDiff.diffLines(expectedSource, origSource);
|
||||||
errs = [];
|
errs = [];
|
||||||
diffs.forEach(function(diff) {
|
diffs.forEach(function(diff) {
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
```
|
||||||
|
import {Component, View, bootstrap} from 'angular2/angular2';
|
||||||
|
```
|
@ -0,0 +1,6 @@
|
|||||||
|
```
|
||||||
|
import {Component, View, bootstrap} from 'angular2/angular2';
|
||||||
|
// indented comment
|
||||||
|
var x = 3;
|
||||||
|
// final comment
|
||||||
|
```
|
@ -0,0 +1,11 @@
|
|||||||
|
```
|
||||||
|
name: angular2-getting-started
|
||||||
|
version: 0.0.1
|
||||||
|
dependencies:
|
||||||
|
angular2: ^2.0.0-alpha.41
|
||||||
|
browser: ^0.10.0
|
||||||
|
transformers:
|
||||||
|
- angular2:
|
||||||
|
entry_points: web/main.dart
|
||||||
|
|
||||||
|
```
|
@ -0,0 +1,6 @@
|
|||||||
|
```
|
||||||
|
name: angular2-getting-started
|
||||||
|
# special plaster
|
||||||
|
angular2: ^2.0.0-alpha.41
|
||||||
|
browser: ^0.10.0
|
||||||
|
```
|
@ -0,0 +1,12 @@
|
|||||||
|
```
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<script src="https://code.angularjs.org/2.0.0-alpha.26/angular2.sfx.dev.js"></script>
|
||||||
|
<script src="main.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<my-app></my-app>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
```
|
@ -0,0 +1,7 @@
|
|||||||
|
```
|
||||||
|
<html>
|
||||||
|
<!-- special plaster -->
|
||||||
|
<body>
|
||||||
|
<my-app></my-app>
|
||||||
|
</body>
|
||||||
|
```
|
@ -0,0 +1,6 @@
|
|||||||
|
```
|
||||||
|
h2 { color: #444; font-weight: lighter; }
|
||||||
|
body { margin: 2em; }
|
||||||
|
/* plaster here */
|
||||||
|
body, input[text], button { color: #888; font-family: Cambria, Georgia; }
|
||||||
|
```
|
@ -0,0 +1,6 @@
|
|||||||
|
```
|
||||||
|
h2 { color: #444; font-weight: lighter; }
|
||||||
|
/* plaster here */
|
||||||
|
body, input[text], button { color: #888; font-family: Cambria, Georgia; }
|
||||||
|
button {padding: 0.2em; font-size: 14px}
|
||||||
|
```
|
@ -0,0 +1,26 @@
|
|||||||
|
// no docplaster
|
||||||
|
// #docplaster
|
||||||
|
// #docregion import,twoparts
|
||||||
|
import {Component, View, bootstrap} from 'angular2/angular2';
|
||||||
|
// #enddocregion twoparts, import
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'my-app'
|
||||||
|
})
|
||||||
|
@View({
|
||||||
|
template: '<h1 id="output">My first Angular 2 App</h1>'
|
||||||
|
})
|
||||||
|
class AppComponent {
|
||||||
|
}
|
||||||
|
|
||||||
|
// #docregion twoparts
|
||||||
|
// indented comment
|
||||||
|
var x = 3;
|
||||||
|
// #enddocregion
|
||||||
|
|
||||||
|
bootstrap(AppComponent);
|
||||||
|
// #docregion twoparts
|
||||||
|
// final comment
|
||||||
|
// #enddocregion twoparts
|
||||||
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
|||||||
|
# #docplaster special plaster
|
||||||
|
# #docregion foo, bar
|
||||||
|
name: angular2-getting-started
|
||||||
|
# #enddocregion foo
|
||||||
|
version: 0.0.1
|
||||||
|
dependencies:
|
||||||
|
# #docregion foo
|
||||||
|
angular2: ^2.0.0-alpha.41
|
||||||
|
browser: ^0.10.0
|
||||||
|
# #enddocregion foo
|
||||||
|
transformers:
|
||||||
|
- angular2:
|
||||||
|
entry_points: web/main.dart
|
@ -0,0 +1,15 @@
|
|||||||
|
<!-- #docplaster special plaster -->
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<!-- #docregion bar, foo -->
|
||||||
|
<html>
|
||||||
|
<!-- #enddocregion foo -->
|
||||||
|
<head>
|
||||||
|
<script src="https://code.angularjs.org/2.0.0-alpha.26/angular2.sfx.dev.js"></script>
|
||||||
|
<script src="main.js"></script>
|
||||||
|
</head>
|
||||||
|
<!-- #docregion foo -->
|
||||||
|
<body>
|
||||||
|
<my-app></my-app>
|
||||||
|
</body>
|
||||||
|
<!-- #enddocregion foo -->
|
||||||
|
</html>
|
10
public/doc-shredder/_test/test_source/multiregion/style.css
Normal file
10
public/doc-shredder/_test/test_source/multiregion/style.css
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
/* #docplaster plaster here */
|
||||||
|
/* #docregion foo, bar */
|
||||||
|
h2 { color: #444; font-weight: lighter; }
|
||||||
|
/* #enddocregion foo
|
||||||
|
body { margin: 2em; }
|
||||||
|
/* #enddocregion bar
|
||||||
|
/* #docregion foo, bar */
|
||||||
|
body, input[text], button { color: #888; font-family: Cambria, Georgia; }
|
||||||
|
/* #enddocregion bar
|
||||||
|
button {padding: 0.2em; font-size: 14px}
|
@ -218,6 +218,7 @@ function getDocPlaster(line) {
|
|||||||
var rx = /#docplaster\s*(\S.*)/;
|
var rx = /#docplaster\s*(\S.*)/;
|
||||||
try {
|
try {
|
||||||
var plaster = line.match(rx)[1];
|
var plaster = line.match(rx)[1];
|
||||||
|
plaster = plaster.replace("-->","").replace('\*\/',"");
|
||||||
return plaster.trim();
|
return plaster.trim();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user