Skip to content

Commit

Permalink
Revert "Fixes prettier#5"
Browse files Browse the repository at this point in the history
This reverts commit f230921. Reverting since, including a new expression on the tagPattern regex changes indexes used by `parse` function breaking some of the parsing. This was breaking the `leaf` tests only apparently. Needs more careful inclusion to not break some of the other use cases.
  • Loading branch information
rart committed Dec 16, 2019
1 parent c2e7ac4 commit 0767b74
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 16 deletions.
13 changes: 1 addition & 12 deletions src/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ const endTagPattern = `((\\/)${tagNamePattern}\\s*>)`;

const commentPattern = "(!--)([\\s\\S\\n]*?)-->";
const declPattern = "((\\?xml)(-model)?)(.+)\\?>";
const docTypePattern = "(!(doctype|DOCTYPE))";

const tagPattern = `<(${cDataPattern}|${startTagPattern}|${endTagPattern}|${commentPattern}|${declPattern}|${docTypePattern})([^<]*)`;
const tagPattern = `<(${cDataPattern}|${startTagPattern}|${endTagPattern}|${commentPattern}|${declPattern})([^<]*)`;

class XMLNode {
constructor(tagname, opts) {
Expand Down Expand Up @@ -73,16 +72,6 @@ const parse = (text, _parsers, _opts) => {
locEnd: tag.index + tag[0].trim().length
})
);
} else if ((tag[21] || "").toLowerCase() === "doctype") {
node.children.push(
new XMLNode(`!doctype`, {
parent: node,
value: tag[0].trim(),
attrs: tag[22].trim().replace(/>$/, ""),
locStart: tag.index,
locEnd: tag.index + tag[0].trim().length
})
);
} else if (tag[4] === "]]>") {
node.children.push(
new XMLNode("!cdata", {
Expand Down
2 changes: 1 addition & 1 deletion src/print.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const genericPrint = (path, opts, print) => {
return concat([join(hardline, path.map(print, "children")), hardline]);
}

if (tagname === "!comment" || tagname === "!doctype") {
if (tagname === "!comment") {
return group(concat([value]));
}

Expand Down
3 changes: 0 additions & 3 deletions test/doctype.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ describe("doctype", () => {
const content = here(`
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-model href="model.rnc" type="application/relax-ng-compact-sync-syntax" ?>
<!DOCTYPE foo PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://docbook.org/xml/4.5/docbookx.dtd">
<!DOCTYPE foo PUBLIC "-//OASIS//DTD DITA Task//EN" "foo.dtd">
<foo />
`);

Expand Down

0 comments on commit 0767b74

Please sign in to comment.