Skip to content

Conversation

@hendrikp
Copy link
Contributor

@hendrikp hendrikp commented Mar 4, 2023

This fixes/adds the compatibility to supply custom anchor id, and class through the markdown text (through attr_list extension).

  • I also fixed the readme in regard how generic caption (Listings) are html rendered.
  • generic captions had a html-syntax errors previously in closing tag (contained class=listing statically)
    • this is fixed now

In regard to usage please see updated readme + unit tests.

Goal is to be able to be able to specify permalink / anchorid's to the resulting captions/elements in general through the attr_list extension. If no markdown attr_list specified the caption extension will still fallback to the previous id generation method.

hendrikp added 7 commits March 4, 2023 21:22
…ion extension (don't overwrite id supplied from attr_list, and if present extend class)
…on id, classes to table content element (otherwise lost).

this is not needed for image caption as, the attr_list for images is part of the image itself (this is not possible for tables by default)
…tag, this produced wrong html syntax (class in closing tag), and prevented applying a custom class)
@kyzyl
Copy link

kyzyl commented May 9, 2023

Hi! Is this PR waiting on something? I was just considering adding something like this myself.

This is a great plugin, and this functionality would be very helpful to allow for automatic in-text cross referencing. I'm sure many people would appreciate it.

@hendrikp
Copy link
Contributor Author

hm idk either, im using it from my branch for now - feel free todo the same. (install in pip through git source)

https://github.com/hendrikp/caption/tree/new-config-options-match-skip

@kyzyl
Copy link

kyzyl commented May 10, 2023

Yep, me too. Thanks :) I hacked in some javascript to do automatic cross-referencing as well. It just replaces the <ref>{#fig-blah}</ref> tokens in text with the appropriate auto-numbered "Figure 1" etc. that is associated with the referenced ID. Can also add links to the IDs as well so readers can just jump straight to it. This way it works essentially the same as in LaTeX.

Of course this would probably be better done in the actual plugin source rather than hacking the DOM after the fact, but I didn't want to figure out how it works for now.

@hendrikp
Copy link
Contributor Author

hendrikp commented May 3, 2025

this is i think a more streamlined solution then #14 as its using the existing attrlist feature

@flywire flywire merged commit 1cfe3ab into flywire:major-refactor May 3, 2025
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