Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/markd/renderers/html_renderer.cr
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ module Markd
output(node.text)
end

def code_block(node : Node, entering : Bool, formatter : T?) : Nil forall T
{% if @top_level.has_constant?("Tartrazine") %}
def code_block(node : Node, entering : Bool, formatter : T? = nil) : Nil forall T
{% if @top_level.has_constant?("Tartrazine") && !formatter.nil? %}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: This condition is wrong. formatter is a runtime parameter, we cannot check its value in a macro expression. This blows as soon as @top_level.has_constant?("Tartrazine") returns true (but it goes unnoticed without because macro expressions evaluate lazily).

Apparently there is no test case covering the code path when Tartrazine is available?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition is wrong. formatter is a runtime parameter, we cannot check its value in a macro expression

I notice this, but, there is no error when I run spec, I will add it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

render_code_block_use_tartrazine(node, formatter)
{% else %}
render_code_block_use_code_tag(node)
Expand Down Expand Up @@ -340,7 +340,7 @@ module Markd
end
end

private def render_code_block_use_tartrazine(node : Node, formatter : Tartrazine::Formatter?)
private def render_code_block_use_tartrazine(node : Node, formatter : Tartrazine::Formatter)
languages = node.fence_language ? node.fence_language.split : nil
lang = code_block_language(languages)

Expand Down
Loading