theskumar / autolink-references-mkdocs-plugin Goto Github PK
View Code? Open in Web Editor NEWmkdocs plugin to provides GitHub like autolink references in Mkdocs.
License: MIT License
mkdocs plugin to provides GitHub like autolink references in Mkdocs.
License: MIT License
Assuming the following initial markdown:
Lorem ipsum dolor sit amet, consetetur PROJ-1234 sadipscing elitr
My expectation is, that the plugin automatically transforms the above text to something like:
Lorem ipsum dolor sit amet, consetetur [PROJ-1234](https://jira.mycorp.com/browse/PROJ-1234) sadipscing elitr
But instead everything after the issue reference in the line is deleted:
Lorem ipsum dolor sit amet, consetetur [PROJ-1234](https://jira.mycorp.com/browse/PROJ-1234)
As far as I can tell, the currently constructed regex is for example:
[\[]?PROJ-([0-9]+)[\]]?(\(?.*\)?)
I think that the part of the regex that should match the round brackets and the original markdown link is wrong as it matches not only the round braces and the link but instead everything in the same line after the reference. See here for an explanation.
My suggestion is to change it to
\[?PROJ-([0-9]+)\]?(\([^)]*\))?
as this will match only the reference and optionally the surrounding markdown link. See here for an explanation.
Andreas Tetzner <[email protected]> on behalf of Daimler TSS GmbH. Provider Information.
attr_list
extensions is used by multiple mkdocs themes, and possibly incompatible with this plugin
Let's say we want to link to header anchors:
- autolink_references:
autolinks:
- reference_prefix: F-
target_url: /features#F-<num>
And those anchors we want to add manually with attr_list
extension:
## Feature 1 { #F-001 .class-feature }
Lorem ipsum ...
## Feature 2 { #F-002 .class-feature }
Lorem ipsum ...
This plugin will break the attr_list
tag by changing it to something like:
## Feature 2 { #[F-002](/features#F-002) .class-feature }
And as a result:
attr_list
will not be recognized and will be injected into the content creating ugly "Feature 2 { F-002 " header#feature-
and therefore, auto-links will not workPlease, add a feature to skip attr_list
tags when attr_list
is enabled.
Link to attr_list
extension and syntax: https://python-markdown.github.io/extensions/attr_list/
Thanks for your work and this plugin, very useful.
mkdocs.yml
:
autolink_references:
autolinks:
- reference_prefix: '#'
target_url: "https://github.com/USER/PROJECT/issues/<num>"
which it's quite intuitive that this turns on a lot of conflicts.
So the questions are:
<user>/<project>#<num>
docs/news/
directory, where I mention the issues only in the application' release posts: autolink_references:
autolinks:
- sources:
- "docs/PROJECT1/news/"
- "docs/PROJECT1/changes.md"
target_url: "https://github.com/USER/PROJECT1/issues/<num>"
reference_prefix: '#'
- sources:
- "docs/PROJECT2/news/"
- "docs/PROJECT2/changes.md"
target_url: "https://github.com/USER/PROJECT2/issues/<num>"
reference_prefix: '#'
The plugin incorrectly transforms reference-style links.
For example this input
[TEST-123][some-id]
[some-id]: https://jira.com/some-org/TEST-123
Gets transformed to this
[TEST-123](https://jira.com/some-org/TEST-123)[some-id]
[some-id]: https://jira.com/some-org/[TEST-123](https://jira.com/some-org/TEST-123)
Which renders as
I was able to reproduce the behavior in Regexr here: https://regexr.com/6jtik
You can see the incorrect matching in this screenshot:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.