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

TOC generation does not work properly when document headers have parens #383

Open
fmenozzi opened this issue Sep 28, 2024 · 1 comment
Open

Comments

@fmenozzi
Copy link

Description

When calling :WikiTocGenerate on a document whose header has parens, the parens are not URL-encoded and thus conflict with the markdown link syntax []().

Minimal working example

Suppose you have a document like so:

# Title (with parens)

## Heading

## Another Heading

Calling :WikiTocGenerate will produce the following TOC:

Contents:
* [Title (with parens)](#Title (with parens))
    * [Heading](#Title (with parens)#Heading)
    * [Another Heading](#Title (with parens)#Another Heading)

# Title (with parens)

## Heading

## Another Heading

These links produced in the TOC will not work when using Enter to try and follow them.

I believe the solution would simply be to URL-encode ( and ) in header names when generating the TOC.

@lervag
Copy link
Owner

lervag commented Sep 30, 2024

Thanks. I agree that this example should preferably "just work". Right now, you will need to customize the url handler, see e.g. :help wiki-advanced-config-2 for an example of how to do it. The example is not precisely what you want here, though.

I'll look into it and see if I can find a simple, viable solution for the default behaviour. I think I should also add a builtin transformer and resolver that is more "in line" with standard Markdown expected behaviour.

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

No branches or pull requests

2 participants