You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: ignore callouts outside of quotes and checkboxes outside of lists
## Details
Previously `shortcut_links` would be rendered immediately if the
contents matched any configured callouts or checkboxes. This isn't
exactly harmful, but does mean, for instance, that a checkbox pattern at
the start of a block quote will have its icon rendered and a list with a
callout will have its icon rendered, which goes against the definition
of these concepts.
To fix this we now render both callouts and checkboxes through the main
`markdown` handler rather than as part of the inline logic. Callouts
while rendering block quotes, and checkboxes while rendering list items.
This is possible now that we store the nodes along with their
configurations inside the context.
Handling callouts is straightforward, we copy paste the logic that was
in the `shortcut` render for callouts into the `quote` render module and
apply the logic to the values stored inside the context if they exist.
Handling checkboxes is more complicated since we were already rendering
checkboxes in the `markdown` handler and handling part of the rendering
in the `bullet` render. Basically the logic ended up being split between
`shortcut`, `bullet`, & `checkbox` with shared logic stored in `base` to
produce consistent results, yuk.
To improve this state and solve the problem a new `list` render
implementation was added which gets used in place of where `bullet` is
currently. The implementation of it runs the checkbox render, if that
returns false (meaning no checkbox is present), then it runs the bullet
render. This means the checkbox render no longer runs on checkbox nodes
directly but instead on the parent list item, so the checkbox query is
removed from the `markdown` handler.
The `bullet` part of the rendering remains almost completely unchanged,
the only difference is all the checkbox handling like hiding marks is
removed and configuration can now happen more in the `setup` method.
The `checkbox` render is updated to handle running on a list item, which
means finding the node associated with the checkbox (if it exists). From
there hide the mark of the list, render the marker (which allows this
logic to be removed from base), and highlight the scope.
In addition to fixing this problem the logic is now all located in a
single place which should make adding features easier.
The fallback pattern of list could end up being useful for rendering
other things, but currently this is the only instance of diverging logic
when rendering the same exact thing, so leaving it as a one off for now.
Other changes:
- use generic `config` name throughout when getting a specific config
from `context`, rather than something specific like `latex`
- remove `self.config` from `Base` render fields, instead config must be
pulled via `self.context.config`, usually once in each implementation
- since the `config` name is no longer being used rename all instances
of `self.info` to `self.config`, which no stores the specific
configuration of what is being rendered
0 commit comments