Skip to content

Commit 54a536b

Browse files
Daniel Tolbertazu
authored andcommitted
feat(plugin): add html style docs to snips (#47)
1 parent 7e598f0 commit 54a536b

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

src/marker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
*/
1414
"use strict";
1515
const logger = require("winston-color");
16-
const commentOpen = "(\/+\/+|#|%|\/\\*)";
17-
const commentClose = "(\\*\/)?";
16+
const commentOpen = "(\/+\/+|#|%|\/\\*|<\!--)";
17+
const commentClose = "(\\*\/|-->)?";
1818
const doxChar = "[\*!\/#]"; // doxygen documentation character
1919
const spaces = "[ \t]*"; // h spaces
2020
const spacesAny = "\\s*"; // h+v spaces

test/marker-test.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,24 @@ int main()
4747
`;
4848
// -------------------------------------------------------------------------------
4949

50+
51+
const htmlcode = `
52+
<html>
53+
<header><title>This is title</title></header>
54+
<body>
55+
<!--/ [marker0] -->
56+
Hello world
57+
<!--/ [marker1] -->
58+
Hola Mundo
59+
<!--! [marker1] -->
60+
<!--/ [marker2] -->
61+
Hallo Welt
62+
<!--! [marker2] -->
63+
<!--! [marker0] -->
64+
</body>
65+
</html>
66+
`;
67+
5068
// Expected results.
5169
const expectedMarker0 = ` int a;
5270
//! [marker1]
@@ -64,6 +82,18 @@ const expectedMarker5 = " int g;";
6482
const expectedMarker6 = " int h;";
6583
const expectedMarker7 = " int i;";
6684

85+
// Expected HTML results.
86+
const expectedHTMLMarker0 = ` Hello world
87+
<!--/ [marker1] -->
88+
Hola Mundo
89+
<!--! [marker1] -->
90+
<!--/ [marker2] -->
91+
Hallo Welt
92+
<!--! [marker2] -->`;
93+
94+
const expectedHTMLMarker1 = " Hola Mundo";
95+
96+
const expectedHTMLMarker2 = " Hallo Welt";
6797

6898
describe("marker", function () {
6999
describe("#hasMarker", function () {
@@ -115,6 +145,21 @@ describe("marker", function () {
115145
const result = markerSliceCode(cppcode, markerName);
116146
assert.equal(result, expectedMarker4);
117147
});
148+
it("should slice code between [marker0] with HTML comment <!-- -->", function () {
149+
const markerName = "marker0";
150+
const result = markerSliceCode(htmlcode, markerName);
151+
assert.equal(result, expectedHTMLMarker0);
152+
});
153+
it("should slice code between [marker1] with HTML comment <!-- -->", function () {
154+
const markerName = "marker1";
155+
const result = markerSliceCode(htmlcode, markerName);
156+
assert.equal(result, expectedHTMLMarker1);
157+
});
158+
it("should slice code between [marker2] with HTML comment <!-- -->", function () {
159+
const markerName = "marker2";
160+
const result = markerSliceCode(htmlcode, markerName);
161+
assert.equal(result, expectedHTMLMarker2);
162+
});
118163
});
119164
context("#comment-style", function () {
120165
it("should slice code between [marker 5]", function () {

0 commit comments

Comments
 (0)