-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate custom node handlers for block and inline #7083
Conversation
(Let me just start by saying I'm very impressed that you were willing and able to dig in this part of the code!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few stylistic requests:
Lua code is supposed to be snake_case
. We're slowly improving our codebase (which as you will certainly have experienced is wildly inconsistent). However, we're trying to not make matters worse with new commits. namedHandlers
-> handlers
is an improvement, but can you make byAstName
into by_ast_name
?
This allows storing different handlers for blocks and inlines for the same class name.
Thanks! I've renamed the field to |
This looks very good. There's one small renaming I would want to do: Thanks again. Looking to the future, since I seem to recall you want conditional spans. Tests: we don't have great infrastructure for testing our Lua codebase in isolation (because it all runs inside Pandoc). We do much better with end-to-end render tests, and those tend to cover basic features like this one. It's not ideal, but it's better than nothing. With that said, for document-level features, we will 100% want tests that cover expected behavior. You'll find a number of those test documents in our |
Good point for the Regarding conditional spans: I think this PR was all I needed for my projects: it's enough to get Thanks for the tips on tests. For the future of conditional nodes I was wondering if you eventually want custom nodes for all of them. Currently @cderv yes thanks for the reminder, it's closed now. |
Ok. This is great, I thought we would have needed additional code! In that case we should 100% add document-level tests with expected outputs. Would you be willing to add some?
Agreed. It's not even clear to me that we need |
Sure, I'll prepare some tests. |
Description
This addresses #6940 by storing custom block and inline handlers in seperate tables. This way it is possible for the same class name (
content-visible
) to have one handler for divs and another for spans.Currently this PR doesn't add a handler for Spans, so they don't get a custom node wrapper, but they still get a working
content-hidden
treatment, like code blocks. Without this PR, conditional spans cause an error.If desired, I can add custom nodes for inlines (to wrap conditional spans), and wrap conditional code blocks using the existing ConditionalBlock.
I'll be happy to add some tests and documentation if the general idea is approved, and after it's decided what to do about custom nodes for conditional spans and code blocks.
Checklist
I have (if applicable):