How do you retain positioning information? #88
-
The act of parsing, and the stringifying html totally messes up the document (makes it impossible to use rehype for codemods) For example, https://jsbin.com/selazix/edit?html,output let transformed = await unified()
.use(rehypeParse)
.use(rehypeStringify)
.process(sourceFile);
let result = transformed.value;
console.log(result); before:
after:
casing isn't even maintained |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Prettier and babel formats markdown, HTML, JavaScript, etc. unified does the same. This is intentional. It’s how ASTs work. ESLint doesn’t change anything normally, because it doesn’t format things. |
Beta Was this translation helpful? Give feedback.
-
Hey @NullVoxPopuli! Sorry you ran into a spot of trouble. The handlebars like syntax ( |
Beta Was this translation helpful? Give feedback.
Hey @NullVoxPopuli! Sorry you ran into a spot of trouble.
This sounds a lot like remarkjs/remark#922
Here you are using an HTML parser, to parse an HTML-like (but not HTML) templating language.
The handlebars like syntax (
{{content-for "head"}}
) is throwing off the interpretation.pre-processing the text before handing off to rehype could work, or rehype could be customized to parse the handlebars-like-syntax.