Skip to content

Add prepend arg to toc extra (#397)#568

Merged
nicholasserra merged 2 commits intotrentm:masterfrom
Crozzers:prepend-toc
Feb 28, 2024
Merged

Add prepend arg to toc extra (#397)#568
nicholasserra merged 2 commits intotrentm:masterfrom
Crozzers:prepend-toc

Conversation

@Crozzers
Copy link
Contributor

This PR closes #397 by adding a flag that enables the TOC to be prepended to the output text.

markdown2.markdown(text, extras={'toc': {'prepend': True}})

This option is off by default to maintain backward compatibility

@nicholasserra
Copy link
Collaborator

Don't we do this somewhere else also? Maybe for some table extra. This is giving me deja vu

@Crozzers Crozzers mentioned this pull request Feb 21, 2024
@Crozzers
Copy link
Contributor Author

Can't think of anywhere else we do this. The only recent changes to TOC I can think of is with mixed header-ids where we sort the TOC by order of appearance. Only other place that toc is outputted seems to be in the CLI

if extras and "toc" in extras:
log.debug("toc_html: " +
str(html.toc_html.encode(sys.stdout.encoding or "utf-8", 'xmlcharrefreplace')))

@nicholasserra
Copy link
Collaborator

Yup, I'm remembering adding support to the CLI output here

#283

@nicholasserra
Copy link
Collaborator

Needs a rebase or merge in

@Crozzers
Copy link
Contributor Author

Rebased onto master

@nicholasserra nicholasserra merged commit 646e6d2 into trentm:master Feb 28, 2024
@nicholasserra
Copy link
Collaborator

Thanks!

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.

TOC not displayed when not in CLI

2 participants