Skip to content
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

callout list handling could be better #722

Open
gdamore opened this issue Jul 12, 2020 · 3 comments
Open

callout list handling could be better #722

gdamore opened this issue Jul 12, 2020 · 3 comments

Comments

@gdamore
Copy link
Collaborator

gdamore commented Jul 12, 2020

While working on #721 I noticed that the handling for callout lists is a bit dodgy, and differs in some ways from asciidoctor -- in particular the use of CSS to separate callouts is good, but when these appear in a source block comment, the comment itself is not detected.

What asciidoctor does is look for certain comment patterns, and when finding those as the sole comment, replaces the entire comment with the callout reference.

asciidoctor does this using a naive regular expression.

We think a clever approach might be to replace the callout reference with a special unicode token, that we can then come back and replace with appropriate text. We can also benefit from the lexer that is part of Chroma, and let it do the work to identify this for us. Essentially we'd replace the comment with the inlined callout item.

We also think we can do something nicer than asciidoctor here. Asciidoctor uses either font icons or images -- but this is kind silly -- unicode has nice circled variants for most numbers, and we can simply translate them, leaving elegant markup behind us, and eliminating the dependency upon font icons, svg, or anything like that.

@gdamore
Copy link
Collaborator Author

gdamore commented Jul 13, 2020

Actually, it might be easier to just let this get treated in a similar way -- handle it naively at parser time. We will probably want to recognize each of the ways that asciidoctor does.

@xcoulon
Copy link
Member

xcoulon commented Jul 13, 2020

One thing to keep in mind is that Asciidoctor renders the callouts in such a way that a reader can copy/paste an entire block of code without the callout references even if they appear on the HTML document (see https://asciidoctor.org/docs/user-manual/#copy-and-paste-friendly-callouts). Or maybe that's what you meant by "n particular the use of CSS to separate callouts is good"?

@gdamore
Copy link
Collaborator Author

gdamore commented Jul 13, 2020

Yep, it's handled via CSS and the user-select property -- at least in theory.

They also use CSS to render the surrounding circle, but note that their code has limitations around the number of callouts (or at least digits in the callout number) and does not work well when using non-consecutively numbered callouts. (None of this is documented btw.)

I actually think we could use the dingbat items in unicode, like this: ➊ to get the same effect (for at least up to 10 callouts), and we could still use the CSS styles to keep them from being selectable.

@xcoulon xcoulon added this to the backlog milestone Oct 4, 2020
@xcoulon xcoulon modified the milestones: backlog, v0.8.0 Mar 27, 2022
@xcoulon xcoulon modified the milestones: v0.8.0, backlog May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants