Skip to content

Make formatter in Markd#render optional - #101

Merged
icyleaf merged 1 commit into
icyleaf:masterfrom
zw963:master
Aug 25, 2026
Merged

Make formatter in Markd#render optional#101
icyleaf merged 1 commit into
icyleaf:masterfrom
zw963:master

Conversation

@zw963

@zw963 zw963 commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

@icyleaf
icyleaf merged commit 76d44c8 into icyleaf:master Aug 25, 2026
4 of 5 checks passed
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.

zw963 added a commit to zw963/markd that referenced this pull request Aug 27, 2026
zw963 added a commit to zw963/markd that referenced this pull request Aug 27, 2026
zw963 added a commit to zw963/markd that referenced this pull request Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants