This PR is the result of investigating a bug related to a custom markdown renderer with a preprocess method.
Background
I noticed that my preprocess method (a sub! on full_document) defined in a custom markdown renderer class was being applied twice in the generated index.html.
After some debugging I noticed that in write_docs, when markdown.render was called on page[:md] for the page I specified as the index (css.html), the preprocess transform was also applied to page["index.html"][:md].
I traced the issue back to line 49 in doc_parser.rb. @pages['index.html'] is a shallow copy of the specified index page, so changes to one with affect the other.
Solution
I propose setting @pages['index.html'] with a deep copy of the specified page hash. This change would prevent similar custom renderer related issues. Alternatively I could resolve my issue by deep copying full_document and editing it in my markdown renderer methods - I'm not familiar with the common practices around writing Redcarpet renderers, this could in fact be the better way forward.
This PR is the result of investigating a bug related to a custom markdown renderer with a preprocess method.
Background
I noticed that my preprocess method (a
sub!
onfull_document
) defined in a custom markdown renderer class was being applied twice in the generated index.html.After some debugging I noticed that in
write_docs
, whenmarkdown.render
was called onpage[:md]
for the page I specified as the index (css.html
), the preprocess transform was also applied topage["index.html"][:md]
.I traced the issue back to line 49 in
doc_parser.rb
.@pages['index.html']
is a shallow copy of the specified index page, so changes to one with affect the other.Solution
I propose setting
@pages['index.html']
with a deep copy of the specified page hash. This change would prevent similar custom renderer related issues. Alternatively I could resolve my issue by deep copyingfull_document
and editing it in my markdown renderer methods - I'm not familiar with the common practices around writing Redcarpet renderers, this could in fact be the better way forward.