Skip to content

Add a wiki-links extra for [[Page Name]] links - #720

Open
ChrisJr404 wants to merge 1 commit into
trentm:masterfrom
ChrisJr404:wiki-links-extra
Open

Add a wiki-links extra for [[Page Name]] links#720
ChrisJr404 wants to merge 1 commit into
trentm:masterfrom
ChrisJr404:wiki-links-extra

Conversation

@ChrisJr404

Copy link
Copy Markdown

This adds an opt-in wiki-links extra so that [[Page Name]] turns into a link to another page, which is the feature asked for in #221. It is modelled on the wikilinks extension from Python-Markdown, so the target URL and CSS class are configurable: base_url, end_url and html_class cover the common cases, and there is an optional build_url callable if you want full control over the href. For example:

markdown("[[Foo Bar]]", extras={"wiki-links": {"base_url": "/", "end_url": ".html", "html_class": "localLink"}})
# -> <a href="/Foo_Bar.html" class="localLink">Foo Bar</a>

Like the other extras it is off by default, so existing output is unchanged. The generated anchor is hashed the same way link-patterns does it, which keeps the later stages from mangling labels or URLs that contain underscores. Inline code and fenced blocks are left alone because they are already hashed by the time the extra runs.

I added two tm-cases (a default one and one exercising the options) and a CHANGES entry. make testone and make testredos both pass locally.

Adds an opt-in wiki-links extra that turns [[Page Name]] into a link to
another page, modelled on the wikilinks extension from Python-Markdown.
The generated URL and CSS class are configurable through the base_url,
end_url and html_class options, plus an optional build_url callable for
full control over the href. The extra is off by default and the anchor is
hashed so later stages leave labels and URLs containing underscores alone.

Addresses trentm#221.
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.

1 participant