Skip to main content

Allows the setting of the class attribute of `<a>` elements according to whether the link is external or internal to the Pelican-generated site.

Project description

travis_build_status

Link Class for Pelican

Description

This plugin allows the setting of the class attribute of <a> elements (generated in Markdown by [ext](link)) according to whether the link is external (i.e. starts with http:// or https://) or internal to the Pelican-generated site.

For now, this plugin only works with Markdown. It was tested with version 3.0.1 of the Python Markdown module. It may not work with previous versions.

Usage

User Settings

In order to avoid clashes with already-defined classes in the user CSS style sheets, it is possible to specify the name of the classes that will be used. They can be specified in the Pelican setting files with the LINKCLASS variable, which must be defined as a list of tuples, like this:

'LINKCLASS' = (('EXTERNAL_CLASS', 'name-of-the-class-for-external-links')
                'INTERNAL_CLASS', 'name-of-the-class-for-internal-links'))

The default values for EXTERNAL_CLASS and INTERNAL_CLASS are, respectively, 'external' and 'internal'.

Styling the hyperlinks

One of the possible uses of this plugins is for styling. Suppose that we have the following in your article written with Markdown:

This is an [internal](internal) link and this is an
[external](http://external.com) link.

If the default values of the configuration variables are used, then a possible CSS setting would be:

a.external:before {
    content: url('../images/external-link.png');
    margin-right: 0.2em;
}

(The file external-link.png is also distributed with this plugin. Just copy it to the appropriate place in your website source tree, for instance in theme/static/images/.)

Then, the result will look like the following:

figure

Note that this plugin also works with reference-style links, as in the following example:

This is an [internal][internal] link and this is an
[external][external] link.

 [internal]: internal
 [external]: http://external.com

Acknowledgments

Many thanks to Yuliya Bagriy for setting up the package for PyPI and Lucas Cimon for fixing the issues with pytest and the smooth integration into the Pelican repository as a sub-module.

Author

Copyright (C) 2015, 2017, 2019 Rafael Laboissiere (rafael@laboissiere.net)

Released under the GNU Affero Public License, version 3 or later. No warranties.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pelican-linkclass-1.0.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pelican_linkclass-1.0.0-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file pelican-linkclass-1.0.0.tar.gz.

File metadata

  • Download URL: pelican-linkclass-1.0.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4+

File hashes

Hashes for pelican-linkclass-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e186d17ff29303b2df18f315c6ce0c3411ab6d0be9ac17eac6f415b3724eeed3
MD5 aa2d3eadbf07bf0a7d4b35d782590d7e
BLAKE2b-256 97087f5c85bf0c3ba2160c83055da7e5d16291cf70ca593aeb696b7ca1c052d4

See more details on using hashes here.

File details

Details for the file pelican_linkclass-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pelican_linkclass-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4+

File hashes

Hashes for pelican_linkclass-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 952deb1196e96a432b0694800ee4baaca7f1961106f35d4ac3eb6c392cea0af5
MD5 f62269387bd41da0caf48b306574adaa
BLAKE2b-256 8647d426bb015681fe90d3d5a963cc7b796f3dc23441f106ca0392984b1243a1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page