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

Support custom labels in TOC. #700

Merged
merged 3 commits into from
Sep 5, 2018
Merged

Support custom labels in TOC. #700

merged 3 commits into from
Sep 5, 2018

Conversation

waylan
Copy link
Member

@waylan waylan commented Aug 17, 2018

When the Table of Contents Extension is used in conjunction with the Attribute Lists Extension and a data-toc-label attribute is defined on a header, the content of the data-toc-label attribute is now used as the content of the Table of Contents item for that header.

@facelessuser
Copy link
Collaborator

Interesting workaround for sane tocs with complex headers.

@waylan
Copy link
Member Author

waylan commented Aug 17, 2018

Yeah, I've had the idea bouncing around for a while, but was thinking of using the title attribute. I wasn't crazy about it though as there is a legitimate use for titles and they are potentially visible to end users (and screen readers). Today it occurred to me that we could use a data-* attribute. And then I had it working with only one line of code. Writing the documentation was the hardest part.

We should probably still properly fix #660, although this would serve as a workaround in the meantime. Note sure if there is anything else we could do for #699 though.

@waylan
Copy link
Member Author

waylan commented Aug 17, 2018

The last commit (94b9c31) just added a another (unrelated) feature to TOC:

A new toc_tokens attribute has been added to the Markdown class, which contains the raw tokens used to build the Table of Contents. Users can use this to build their own custom Table of Contents rather than needing to parse the HTML available on the toc attribute of the Markdown class.

Contains the raw tokens used to build the Table of Contents. Users can 
use this to build their own custom Table of Contents rather than needing 
to parse the HTML available on the `toc` attribute of the Markdown 
class.
@waylan waylan merged commit f51125d into Python-Markdown:master Sep 5, 2018
@waylan waylan deleted the toc branch September 5, 2018 19:54
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.

None yet

2 participants