reshape / retext

plugin that adds the ability to transform the contents of any element
MIT License
8 stars 0 forks source link

Blacklist feature and highlighted code #10

Open tmpfs opened 7 years ago

tmpfs commented 7 years ago

Just a heads up that the blacklist feature doesn't always work.

Let's say I have a markdown document that I process and convert all code blocks to highlighted HTML markup using source-highlight then I have lots of <span> elements within the <pre><code> blocks, retext will operate on them which is not what I want.

I imagine the proper way to fix this would be to open counters/flags for the elements to determine whether we are inside a pre block and reset them when we exit the pre block. For the moment I have disabled this plugin because I want my code to be copied/pasted but would be willing to contribute to find a good solution for this.

jescalan commented 7 years ago

Hmm so does your markdown plugin read the markdown and then convert it into a reshape AST, or as a string? Converting to a reshape ast might solve the issue...

tmpfs commented 7 years ago

I preprocess the markdown documents and replace fenced code blocks that have language info strings with HTML elements (including the nested span elements) and then include these markdown documents, using include(src="document.md"). I have enabled HTML for markdown-it which makes everything work great except I have to disable retext or I get the curly quotes in my code blocks.

The problem as I understand it is the nested span elements otherwise the blacklist feature would work. I need the nested span elements to style the code.