Skip to content

Commit 9682092

Browse files
committed
adds style tags to css
1 parent 5d5a0b1 commit 9682092

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

codepen-data.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var scriptRegExp = /<script\s([^>]+)>([\s\S]*?)<\/script>/i;
2+
var styleRegExp = /<style>([\s\S]*?)<\/style>/i;
23
var moduleTest = /type=["']module["']/;
34
var types = {
45
html: function htmlType(text){
@@ -10,12 +11,26 @@ var types = {
1011

1112
var HTML = text.replace(results[0],"").trim();
1213

13-
return {
14-
html: HTML,
15-
js: results[2],
16-
js_module: true,
17-
editors: "1011"
18-
};
14+
var styleResults = HTML.match(styleRegExp);
15+
if(styleResults) {
16+
HTML = HTML.replace(styleResults[0],"").trim();
17+
return {
18+
html: HTML,
19+
js: results[2],
20+
js_module: true,
21+
editors: "1011",
22+
css: styleResults[1].trim()
23+
};
24+
} else {
25+
return {
26+
html: HTML,
27+
js: results[2],
28+
js_module: true,
29+
editors: "1011"
30+
};
31+
}
32+
33+
1934
}
2035
}
2136
},

test-demo.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
import { Component } from "can";
1616
Component
1717
</script>
18+
<style>
19+
my-app {color: "green";}
20+
</style>
1821
```
1922
<div class='codepen'></div>
2023

test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ describe("bit-docs-html-codepen-link", function() {
6161
{ html: '<my-app></my-app>',
6262
js: 'import { Component } from "//unpkg.com/can@^5.0.0-pre.1/core.mjs";\nComponent',
6363
js_module: true,
64-
editors: '1011' },
64+
editors: '1011',
65+
css: 'my-app {color: "green";}'
66+
},
6567
{ js: 'import {DefineMap} from "//unpkg.com/can@^5.0.0-pre.1/core.mjs";\nconsole.log( myCounter.count ) //-> 1',
6668
js_module: true,
6769
editors: '0011' }

0 commit comments

Comments
 (0)