Skip to content

Commit be3133c

Browse files
kemsakuraiazu
authored andcommitted
fix(plugin): Style tags should be mapped to code blocks (#7)
1 parent 77ba0c3 commit be3133c

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/html-to-ast.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function removeUnusedProperties(node) {
2121
function mapNodeType(node, parent) {
2222
if (parent) {
2323
let parentNode = parent.parent.node;
24-
if (parentNode.tagName === "script") {
24+
if (parentNode.tagName === "script" || parentNode.tagName === "style") {
2525
return "CodeBlock";
2626
}
2727
}

test/HTMLProcessor-test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ describe("HTMLProcessor-test", function () {
1919
assert.equal(code.type, "CodeBlock");
2020
});
2121
});
22+
it("style should CodeBlock", function () {
23+
const result = parse(`<style> hr{border:0}body{margin:0} </style>`);
24+
const script = result.children[0];
25+
script.children.forEach(code => {
26+
assert.equal(code.type, "CodeBlock");
27+
});
28+
});
2229
it("<p> should Paragraph", function () {
2330
const result = parse(`<p>test</p>`);
2431
const pTag = result.children[0];

test/ast-test-case/entities-in-literals/index.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
"properties": {},
128128
"children": [
129129
{
130-
"type": "Str",
130+
"type": "CodeBlock",
131131
"value": "\nhtml > body {\n color: red;\n}\n",
132132
"loc": {
133133
"start": {

0 commit comments

Comments
 (0)