Skip to content

atomicparade/pelican_domain_annotations

Repository files navigation

pelican_domain_annotations

This is a Pelican plug-in that annotates external links with their domains.

Articles and pages are processed after they've been converted to HTML, so this plug-in will work with both Markdown and reStructedText content.

What will be annotated

External domains will be annotated if they're not included in the link text:

Link Output
`Cool link <https://example.com/>`__ Cool link (example.com)

Domains for protocols other than HTTP(S) will be annotated, too. (Note: GitHub does not generate FTP or Gemini links.)

`FTP link <ftp://example.com/example>`__ FTP link (example.com)
`Gemini link <gemini://example.com/example>`__ Gemini link (example.com)

What will not be annotated

External domains will not be annotated if they're included in the link text:

https://example.com/ https://example.com/
`example.com <https://example.com/>`__ example.com
`https://example.com/ <https://example.com/>`__ https://example.com/

This includes the case where the link text omits part of the URL after the domain:

https://example.com/example https://example.com/example
`example.com/example <https://example.com/example>`__ example.com/example
`example.com <https://example.com/example>`__ example.com
`https://example.com/ <https://example.com/example>`__ https://example.com/

If the link text doesn't include "www." but otherwise matches the link, don't annotate the domain, either:

`example.com <https://www.example.com/>`__ example.com
`example.com/example <https://www.example.com/example>`__ example.com/example
`https://example.com <https://www.example.com/>`__ https://example.com
`https://example.com/example <https://www.example.com/example>`__ https://example.com/example

Relative links will not be annotated:

`</>`__ /
`</example.html>`__ /example.html
`Home </>`__ Home
`Example page <example.html>`__ Example page