Open dddoyle1 opened 1 year ago
This looks like it's working on the live demo: https://mixmark-io.github.io/turndown/ The output is:
``` fruits = ["apple", "banana", "cherry"] for fruit in fruits: print(fruit) ```
Looks like this happens only when I pass the HTML element directly, whereas if I instead do
turndownService.turndown(element.outerHTML)
the element is converted as I expected. Is this intended behavior?
FWIW, I see that when I pass the element directly, the thing that makes it to fencedCodeBlock.filter
is a node with "\
...\" stripped away, ie a code node, which fails the filter criteria
The codeBlockStyle
option will do this for you. For example:
var turndownService = new TurndownService({ codeBlockStyle: 'fenced' })
turndownService.turndown('<pre><code class="language-js">console.log("hello world")</code></pre>')
I have a very simple element:
that I would like converted to a fenced code block via
TurndownService::turndown
I initialize the TurndownService with
However, turndown yields the following string when I pass my element:
I've verified by hand that the
fencedCodeBlock.filter
returns true when passed my element and thatfencedCodeBlock.replacement
returns the expected string sandwiched by the fence, but this behavior is not reproduced as expected when usingTurndownService::turndown