GooRoo / mkdocs-obsidian-bridge

An MkDocs plugin that helps exporting your Obsidian vault as an MkDocs site.
https://pypi.org/project/mkdocs-obsidian-bridge/
BSD 3-Clause "New" or "Revised" License
28 stars 2 forks source link

Links with accentuated character #10

Closed gilleschapron closed 11 months ago

gilleschapron commented 11 months ago

Thanks you for your fantastic work on this mkdocs plugin.

I'm using it to make my doc which is bilingual, english and french.

When I make a wikilink to a title in french that have some accentuated characters (é, à, apostrophe ' etc.), these characters are kept in the generated link, and then the link does not work.

I have also multiple warning because I'm using https://ultrabug.github.io/mkdocs-static-i18n/fr/getting-started/quick-start/ to simplify multiple language doc generation, and my files are stored in some subfolder "en" and "fr".

If you could add accentuated character conversion, it will be great (I'll will make a try myself).

Gilles

GooRoo commented 11 months ago

Hi @gilleschapron, Thanks for the feedback.

This was done intentionally. I'm actually also using my plugin for bilingual docs (Ukrainian + English) and it somehow didn't work for me otherwise.

Good news is that AFAIR it's possible to override this behavior in the config. Bad news is that I don't remember how exactly. Let me check, pls.

GooRoo commented 11 months ago

So, as I see in the code, I depend on the markdown_extensions.toc.slugify function. By default, it's the !!python/object/apply:markdown.extensions.toc.slugify_unicode and it should work fine.

However, if you redefine it to !!python/object/apply:pymdownx.slugs.slugify like it's recommended in Material for MkDocs examples, it probably would fail because of #3.

Maybe, you can try something like this in your mkdocs.yaml:

markdown_extensions:
  - toc:
      permalink: true
      slugify: !!python/object/apply:markdown.extensions.toc.slugify
gilleschapron commented 11 months ago

As it with your trick it does not work.

But following your link I found this:
https://facelessuser.github.io/pymdown-extensions/faq/#function-references-in-yaml

And with:

markdown_extensions:
  - markdown.extensions.toc:
      slugify: !!python/object/apply:pymdownx.slugs.slugify {kwds: {case: lower}}

it seems it works for me!

Thanks !