pelican-linkclass 2.1.2__tar.gz → 2.1.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pelican-linkclass might be problematic. Click here for more details.

@@ -1,14 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pelican-linkclass
3
- Version: 2.1.2
3
+ Version: 2.1.3
4
4
  Summary: Pelican plugin to set anchor tag's class attribute to differentiate between internal and external links
5
- Project-URL: Homepage, https://github.com/pelican-plugins/linkclass
6
- Project-URL: Issue Tracker, https://github.com/pelican-plugins/linkclass/issues
7
- Project-URL: Funding, https://donate.getpelican.com/
8
- Author-email: Rafael Laboissière <rafael@laboissiere.net>
5
+ Keywords: pelican plugin link class
6
+ Author-Email: Rafael Laboissière <rafael@laboissiere.net>
9
7
  License: AGPL-3.0
10
- License-File: LICENSE
11
- Keywords: link class,pelican,plugin
12
8
  Classifier: Development Status :: 5 - Production/Stable
13
9
  Classifier: Environment :: Console
14
10
  Classifier: Framework :: Pelican
@@ -21,13 +17,17 @@ Classifier: Programming Language :: Python :: 3.8
21
17
  Classifier: Programming Language :: Python :: 3.9
22
18
  Classifier: Programming Language :: Python :: 3.10
23
19
  Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
24
21
  Classifier: Topic :: Internet :: WWW/HTTP
25
22
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Project-URL: Homepage, https://github.com/pelican-plugins/linkclass
24
+ Project-URL: Issue tracker, https://github.com/pelican-plugins/linkclass/issues
25
+ Project-URL: Funding, https://donate.getpelican.com/
26
26
  Requires-Python: <4.0,>=3.8.1
27
27
  Requires-Dist: pelican>=4.5
28
28
  Requires-Dist: py3dns>=3.2
29
+ Requires-Dist: markdown>=3.4; extra == "markdown"
29
30
  Provides-Extra: markdown
30
- Requires-Dist: markdown>=3.4; extra == 'markdown'
31
31
  Description-Content-Type: text/markdown
32
32
 
33
33
  Link Class: A Plugin for Pelican
@@ -1,11 +1,16 @@
1
1
  [project]
2
2
  name = "pelican-linkclass"
3
- version = "2.1.2"
3
+ version = "2.1.3"
4
4
  description = "Pelican plugin to set anchor tag's class attribute to differentiate between internal and external links"
5
- authors = [{name = "Rafael Laboissière", email = "rafael@laboissiere.net"}]
6
- license = {text = "AGPL-3.0"}
5
+ authors = [
6
+ { name = "Rafael Laboissière", email = "rafael@laboissiere.net" },
7
+ ]
7
8
  readme = "README.md"
8
- keywords = ["pelican", "plugin", "link class"]
9
+ keywords = [
10
+ "pelican",
11
+ "plugin",
12
+ "link class",
13
+ ]
9
14
  classifiers = [
10
15
  "Development Status :: 5 - Production/Stable",
11
16
  "Environment :: Console",
@@ -19,6 +24,7 @@ classifiers = [
19
24
  "Programming Language :: Python :: 3.9",
20
25
  "Programming Language :: Python :: 3.10",
21
26
  "Programming Language :: Python :: 3.11",
27
+ "Programming Language :: Python :: 3.12",
22
28
  "Topic :: Internet :: WWW/HTTP",
23
29
  "Topic :: Software Development :: Libraries :: Python Modules",
24
30
  ]
@@ -28,13 +34,18 @@ dependencies = [
28
34
  "py3dns>=3.2",
29
35
  ]
30
36
 
37
+ [project.license]
38
+ text = "AGPL-3.0"
39
+
31
40
  [project.urls]
32
41
  Homepage = "https://github.com/pelican-plugins/linkclass"
33
42
  "Issue Tracker" = "https://github.com/pelican-plugins/linkclass/issues"
34
43
  Funding = "https://donate.getpelican.com/"
35
44
 
36
45
  [project.optional-dependencies]
37
- markdown = ["markdown>=3.4"]
46
+ markdown = [
47
+ "markdown>=3.4",
48
+ ]
38
49
 
39
50
  [tool.pdm.dev-dependencies]
40
51
  lint = [
@@ -57,42 +68,45 @@ append-github-contributor = true
57
68
 
58
69
  [tool.ruff]
59
70
  select = [
60
- "B", # flake8-bugbear
61
- "BLE", # flake8-blind-except
62
- "C4", # flake8-comprehensions
63
- "D", # pydocstyle
64
- "E", # pycodestyle
65
- "F", # pyflakes
66
- "I", # isort
67
- "ICN", # flake8-import-conventions
68
- "ISC", # flake8-implicit-str-concat
69
- "PGH", # pygrep-hooks
70
- "PL", # pylint
71
- "RET", # flake8-return
72
- "RUF", # ruff-specific rules
73
- "SIM", # flake8-simplify
74
- "T10", # flake8-debugger
75
- "T20", # flake8-print
76
- "TID", # flake8-tidy-imports
77
- "TRY", # tryceratops
78
- "UP", # pyupgrade
79
- "W", # pycodestyle
80
- "YTT", # flake8-2020
71
+ "B",
72
+ "BLE",
73
+ "C4",
74
+ "D",
75
+ "E",
76
+ "F",
77
+ "I",
78
+ "ICN",
79
+ "ISC",
80
+ "PGH",
81
+ "PL",
82
+ "RET",
83
+ "RUF",
84
+ "SIM",
85
+ "T10",
86
+ "T20",
87
+ "TID",
88
+ "TRY",
89
+ "UP",
90
+ "W",
91
+ "YTT",
81
92
  ]
82
-
83
93
  ignore = [
84
- "D100", # missing docstring in public module
85
- "D102", # missing docstring in public method
86
- "D104", # missing docstring in public package
94
+ "D100",
95
+ "D102",
96
+ "D104",
97
+ "D203",
98
+ "D213",
87
99
  ]
88
100
 
89
- target-version = "py38"
90
-
91
101
  [tool.ruff.isort]
92
102
  combine-as-imports = true
93
103
  force-sort-within-sections = true
94
- known-first-party = ["pelican"]
104
+ known-first-party = [
105
+ "pelican",
106
+ ]
95
107
 
96
108
  [build-system]
97
- requires = ["hatchling"]
98
- build-backend = "hatchling.build"
109
+ requires = [
110
+ "pdm-backend",
111
+ ]
112
+ build-backend = "pdm.backend"
@@ -1,15 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- charset = utf-8
5
- end_of_line = lf
6
- indent_size = 4
7
- indent_style = space
8
- insert_final_newline = true
9
- trim_trailing_whitespace = true
10
-
11
- [*.py]
12
- max_line_length = 88
13
-
14
- [*.yml]
15
- indent_size = 2
@@ -1,5 +0,0 @@
1
- ---
2
-
3
- github: justinmayer
4
- custom: https://donate.getpelican.com
5
- liberapay: pelican
@@ -1,97 +0,0 @@
1
- name: build
2
-
3
- on: [push, pull_request]
4
-
5
- env:
6
- PYTEST_ADDOPTS: "--color=yes"
7
-
8
- jobs:
9
- test:
10
- name: Test - ${{ matrix.python-version }}
11
- runs-on: ubuntu-latest
12
- strategy:
13
- matrix:
14
- python-version: ["3.8", "3.9", "3.10", "3.11"]
15
-
16
- steps:
17
- - uses: actions/checkout@v3
18
-
19
- - name: Set up Python ${{ matrix.python-version }} & PDM
20
- uses: pdm-project/setup-pdm@v3
21
- with:
22
- python-version: ${{ matrix.python-version }}
23
- cache: true
24
- cache-dependency-path: ./pyproject.toml
25
-
26
- - name: Install dependencies
27
- run: pdm install
28
-
29
- - name: Run tests
30
- run: pdm run invoke tests
31
-
32
- lint:
33
- name: Lint
34
- runs-on: ubuntu-latest
35
-
36
- steps:
37
- - uses: actions/checkout@v3
38
-
39
- - name: Validate links in Markdown files
40
- uses: JustinBeckwith/linkinator-action@v1
41
- with:
42
- retry: true
43
- linksToSkip: "https://pypi.org/project/pelican-linkclass/"
44
-
45
- - name: Set up Python & PDM
46
- uses: pdm-project/setup-pdm@v3
47
- with:
48
- python-version: "3.10"
49
- cache: true
50
- cache-dependency-path: ./pyproject.toml
51
-
52
- - name: Install dependencies
53
- run: pdm install
54
-
55
- - name: Run linters
56
- run: pdm run invoke lint --diff
57
-
58
- deploy:
59
- name: Deploy
60
- environment: Deployment
61
- needs: [test, lint]
62
- runs-on: ubuntu-latest
63
- if: github.ref=='refs/heads/main' && github.event_name!='pull_request'
64
-
65
- permissions:
66
- contents: write
67
- id-token: write
68
-
69
- steps:
70
- - uses: actions/checkout@v3
71
- with:
72
- token: ${{ secrets.GH_TOKEN }}
73
-
74
- - name: Set up Python
75
- uses: actions/setup-python@v4
76
- with:
77
- python-version: "3.10"
78
-
79
- - name: Check release
80
- id: check_release
81
- run: |
82
- python -m pip install autopub[github]
83
- autopub check
84
-
85
- - name: Publish
86
- if: ${{ steps.check_release.outputs.autopub_release=='true' }}
87
- env:
88
- GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
89
- run: |
90
- autopub prepare
91
- autopub commit
92
- autopub build
93
- autopub githubrelease
94
-
95
- - name: Upload package to PyPI
96
- if: ${{ steps.check_release.outputs.autopub_release=='true' }}
97
- uses: pypa/gh-action-pypi-publish@release/v1
@@ -1,6 +0,0 @@
1
- *.pyc
2
- __pycache__/
3
- /dist/
4
- /*.egg-info
5
- /build/
6
- pdm.lock
@@ -1,31 +0,0 @@
1
- ---
2
- ci:
3
- autoupdate_schedule: quarterly
4
-
5
- # See https://pre-commit.com/hooks.html for info on hooks
6
- repos:
7
- - repo: https://github.com/pre-commit/pre-commit-hooks
8
- rev: v4.5.0
9
- hooks:
10
- - id: check-added-large-files
11
- - id: check-ast
12
- - id: check-case-conflict
13
- - id: check-docstring-first
14
- - id: check-merge-conflict
15
- - id: check-toml
16
- - id: check-yaml
17
- - id: debug-statements
18
- - id: detect-private-key
19
- - id: end-of-file-fixer
20
- - id: forbid-new-submodules
21
- - id: trailing-whitespace
22
-
23
- - repo: https://github.com/psf/black
24
- rev: 23.10.1
25
- hooks:
26
- - id: black
27
-
28
- - repo: https://github.com/astral-sh/ruff-pre-commit
29
- rev: v0.1.3
30
- hooks:
31
- - id: ruff
@@ -1,53 +0,0 @@
1
- CHANGELOG
2
- =========
3
-
4
- 2.1.2 - 2023-10-31
5
- ------------------
6
-
7
- Fix project name
8
-
9
- 2.1.1 - 2023-10-31
10
- ------------------
11
-
12
- Maintenance release:
13
-
14
- - Migrate to the new tooling standards
15
- - Improve code quality
16
-
17
- 2.1.0 - 2023-04-13
18
- ------------------
19
-
20
- The tuples in the LINKCLASS configuration variable have only two elements now. This makes the code consistent with the plugin documentation (README.md file) and resolves issue #34.
21
-
22
- 2.0.4 - 2022-10-01
23
- ------------------
24
-
25
- Update list of years in Copyright notices
26
-
27
- 2.0.3 - 2022-07-15
28
- ------------------
29
-
30
- In `test_linkclass.py`, use `io` instead of `six` to import `StringIO`.
31
-
32
- 2.0.2 - 2021-12-17
33
- ------------------
34
-
35
- Upgrade code to Python 3.6+ (thanks to Justin Mayer)
36
-
37
- 2.0.1 - 2021-11-04
38
- ------------------
39
-
40
- Maintenance release: Use .format() instead of % operator to format strings
41
-
42
- 2.0.0 - 2021-02-17
43
- ------------------
44
-
45
- Convert to namespace plugin for use with Pelican 4.5 and above
46
-
47
- [Justin Mayer](https://github.com/justinmayer) [PR #11](https://github.com/pelican-plugins/linkclass/pull/11/)
48
-
49
-
50
- 1.0.0 - 2019-09-29
51
- ------------------
52
-
53
- Initial release to PyPI
@@ -1,9 +0,0 @@
1
- Contributing
2
- ============
3
-
4
- Contributions are welcome and much appreciated. Every little bit helps. You can contribute by improving the documentation, adding missing features, and fixing bugs. You can also help out by reviewing and commenting on [existing issues][].
5
-
6
- To start contributing to this plugin, review the [Contributing to Pelican][] documentation, beginning with the **Contributing Code** section.
7
-
8
- [existing issues]: https://github.com/pelican-plugins/linkclass/issues
9
- [Contributing to Pelican]: https://docs.getpelican.com/en/latest/contribute.html
@@ -1,3 +0,0 @@
1
- Release type: patch
2
-
3
- Fix project name
Binary file
@@ -1 +0,0 @@
1
- from .linkclass import * # NOQA: F403
@@ -1,51 +0,0 @@
1
- """Link Class Plugin for Pelican."""
2
-
3
- # Copyright (C) 2015, 2019, 2023 Rafael Laboissière
4
- #
5
- # This program is free software: you can redistribute it and/or modify it
6
- # under the terms of the GNU General Affero Public License as published by
7
- # the Free Software Foundation, either version 3 of the License, or (at
8
- # your option) any later version.
9
- #
10
- # This program is distributed in the hope that it will be useful, but
11
- # WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # Affero General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU Affero General Public License
16
- # along with this program. If not, see http://www.gnu.org/licenses/.
17
-
18
-
19
- from pelican import signals
20
-
21
- from .mdx_linkclass import LC_CONFIG, LinkClassExtension
22
-
23
-
24
- def addLinkClass(gen):
25
- """Add LinkClass connector."""
26
- if not gen.settings.get("MARKDOWN"):
27
- from pelican.settings import DEFAULT_CONFIG
28
-
29
- gen.settings["MARKDOWN"] = DEFAULT_CONFIG["MARKDOWN"]
30
-
31
- if gen.settings.get("LINKCLASS"):
32
- for param, default in gen.settings.get("LINKCLASS"):
33
- LC_CONFIG[param] = default
34
-
35
- if LinkClassExtension not in gen.settings["MARKDOWN"]:
36
- config = {}
37
- for key, value in LC_CONFIG.items():
38
- config[key] = value
39
- for key, value in gen.settings.items():
40
- if key in LC_CONFIG:
41
- config[key] = value
42
- lcobj = LinkClassExtension(config)
43
- try:
44
- gen.settings["MARKDOWN"]["extensions"].append(lcobj)
45
- except KeyError:
46
- gen.settings["MARKDOWN"]["extensions"] = [lcobj]
47
-
48
-
49
- def register():
50
- """Register the Link Class plugin with Pelican."""
51
- signals.initialized.connect(addLinkClass)
@@ -1,105 +0,0 @@
1
- """Markdown extension for the Link Class plugin for Pelican."""
2
-
3
- # Copyright (C) 2015, 2017, 2019, 2023 Rafael Laboissière
4
- #
5
- # This program is free software: you can redistribute it and/or modify it
6
- # under the terms of the GNU General Affero Public License as published by
7
- # the Free Software Foundation, either version 3 of the License, or (at
8
- # your option) any later version.
9
- #
10
- # This program is distributed in the hope that it will be useful, but
11
- # WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # Affero General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU Affero General Public License
16
- # along with this program. If not, see http://www.gnu.org/licenses/.
17
-
18
-
19
- import re
20
-
21
- from markdown.extensions import Extension
22
- from markdown.inlinepatterns import (
23
- LINK_RE,
24
- REFERENCE_RE,
25
- LinkInlineProcessor,
26
- ReferenceInlineProcessor,
27
- )
28
-
29
- LC_CONFIG = {"INTERNAL_CLASS": "internal", "EXTERNAL_CLASS": "external"}
30
- LC_HELP = {
31
- "INTERNAL_CLASS": "Name of the CSS class for internal links",
32
- "EXTERNAL_CLASS": "Name of the CSS class for external links",
33
- }
34
-
35
-
36
- def add_class(elm, config):
37
- """Utlity function for adding the appropriate class attribute."""
38
- try:
39
- m = re.match("^https?://", elm.get("href"))
40
- elm.set("class", m and config["EXTERNAL_CLASS"] or config["INTERNAL_CLASS"])
41
- except AttributeError:
42
- pass
43
- return elm
44
-
45
-
46
- class LinkClassExtension(Extension):
47
- """Markdown extension for the Link Class plugin."""
48
-
49
- def __init__(self, config):
50
- """Initialize the class object."""
51
- for key, value in LC_CONFIG.items():
52
- self.config[key] = [value, LC_HELP[key]]
53
- super().__init__(**config)
54
-
55
- def extendMarkdown(self, md):
56
- """Register the Markdown extension."""
57
- # LinkClass instances is added to the list of inline pattern
58
- # processors, with higher priority than the processor defined for the
59
- # "link" and the "reference" objects, such that the normal behavior is
60
- # overridden.
61
- LinkClassPattern = LinkClass(LINK_RE, self.getConfigs())
62
- LinkClassPattern.md = md
63
- md.inlinePatterns.register(LinkClassPattern, "linkclass", 200)
64
- ReferenceClassPattern = ReferenceClass(REFERENCE_RE, self.getConfigs())
65
- ReferenceClassPattern.md = md
66
- md.inlinePatterns.register(ReferenceClassPattern, "referenceclass", 200)
67
-
68
-
69
- class LinkClass(LinkInlineProcessor):
70
- """Markdown inline pattern processor for adding class attribute to inline-style hyperlinks.""" # NOQA: E501
71
-
72
- def __init__(self, pattern, config):
73
- """Initialize the Markdwon inline pattern processor."""
74
- super().__init__(pattern)
75
- # Store the configuration dict
76
- self.config = config
77
-
78
- def handleMatch(self, m, data):
79
- """Add the class attribute to the generated <a> element."""
80
- # Build the <a> element using the parent class
81
- elm, start, end = super().handleMatch(m, data)
82
- # Return the <a> element with added class
83
- return add_class(elm, self.config), start, end
84
-
85
-
86
- class ReferenceClass(ReferenceInlineProcessor):
87
- """Markdown inline pattern processor for adding class attribute to inline-style references.""" # NOQA: E501
88
-
89
- def __init__(self, pattern, config):
90
- """Initialize the Markdwon inline pattern processor."""
91
- super().__init__(pattern)
92
- # Store the configuration dict
93
- self.config = config
94
-
95
- def handleMatch(self, m, data):
96
- """Add the class attribute to the generated <a> element."""
97
- # Build the <a> element using the parent class
98
- elm, start, end = super().handleMatch(m, data)
99
- # Return the <a> element with added class
100
- return add_class(elm, self.config), start, end
101
-
102
-
103
- def makeExtension(config=None):
104
- """Register the MarkDown extension."""
105
- return LinkClassExtension(config=config)
@@ -1,211 +0,0 @@
1
- """Unit testing suite for the Link Class Plugin."""
2
-
3
- # Copyright (C) 2015, 2017, 2019, 2021-2023 Rafael Laboissière <rafael@laboissiere.net> # noqa: E501
4
- #
5
- # This program is free software: you can redistribute it and/or modify it
6
- # under the terms of the GNU General Affero Public License as published by
7
- # the Free Software Foundation, either version 3 of the License, or (at
8
- # your option) any later version.
9
- #
10
- # This program is distributed in the hope that it will be useful, but
11
- # WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # Affero General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU Affero General Public License
16
- # along with this program. If not, see http://www.gnu.org/licenses/.
17
-
18
- # For running this test in a standalone-way, run:
19
- # (cd .. ; python3 -Wd -m unittest discover)
20
-
21
- from io import StringIO
22
- import os
23
- import re
24
- from shutil import rmtree
25
- import sys
26
- from tempfile import mkdtemp
27
- import unittest
28
-
29
- from pelican import Pelican
30
- from pelican.settings import read_settings
31
-
32
- from . import linkclass
33
-
34
- INTERNAL_CLASS = "internal"
35
- EXTERNAL_CLASS = "external"
36
-
37
- INTERNAL_INLINE_TEXT = "internal inline text"
38
- INTERNAL_INLINE_LINK = "internal inline link"
39
-
40
- INTERNAL_REFERENCE_TEXT = "internal reference text"
41
- INTERNAL_REFERENCE_LABEL = "internal reference label"
42
- INTERNAL_REFERENCE_LINK = "internal-reference-link"
43
-
44
- EXTERNAL_INLINE_TEXT_HTTP = "external inline text http"
45
- EXTERNAL_INLINE_LINK_HTTP = "https://inline.org"
46
-
47
- EXTERNAL_REFERENCE_TEXT_HTTP = "external reference text http"
48
- EXTERNAL_REFERENCE_LABEL_HTTP = "external reference label http"
49
- EXTERNAL_REFERENCE_LINK_HTTP = "https://reference.org"
50
-
51
- EXTERNAL_INLINE_TEXT_HTTPS = "external inline text https"
52
- EXTERNAL_INLINE_LINK_HTTPS = "https://inline.org"
53
-
54
- EXTERNAL_REFERENCE_TEXT_HTTPS = "external reference text https"
55
- EXTERNAL_REFERENCE_LABEL_HTTPS = "external reference label https"
56
- EXTERNAL_REFERENCE_LINK_HTTPS = "https://reference.org"
57
-
58
- LINK_PATTERN = '<a class="{}" href="{}">{}</a>'
59
-
60
- TEST_FILE_STEM = "test"
61
- TEST_DIR_PREFIX = "pelicantests."
62
-
63
-
64
- class TestLinkClass(unittest.TestCase):
65
- """Class for testing the <a> output elements generated by the Link Class plugin."""
66
-
67
- def setUp(self, override=None):
68
- self.output_path = mkdtemp(prefix=TEST_DIR_PREFIX)
69
- self.content_path = mkdtemp(prefix=TEST_DIR_PREFIX)
70
- settings = {
71
- "PATH": self.content_path,
72
- "OUTPUT_PATH": self.output_path,
73
- "PLUGINS": [linkclass],
74
- "CACHE_CONTENT": False,
75
- "SITEURL": "http://example.org",
76
- "TIMEZONE": "UTC",
77
- "LINKCLASS": (
78
- ("INTERNAL_CLASS", INTERNAL_CLASS),
79
- ("EXTERNAL_CLASS", EXTERNAL_CLASS),
80
- ),
81
- }
82
- if override:
83
- settings.update(override)
84
-
85
- # Generate the test Markdown source file
86
- with open(
87
- os.path.join(self.content_path, f"{TEST_FILE_STEM}.md"),
88
- "w",
89
- ) as fid:
90
- fid.write(
91
- """Title: Test
92
- Date: 1970-01-01
93
-
94
- This is an [{}]({}), inline-style link.
95
- This is an [{}]({}), inline-style link (with http URL).
96
- This is an [{}]({}), inline-style link (with https URL).
97
-
98
- This is an [{}][{}], reference-style link.
99
- This is an [{}][{}], reference-style link (with http URL).
100
- This is an [{}][{}], reference-style link (with https URL).
101
-
102
- [{}]: {}
103
- [{}]: {}
104
- [{}]: {}
105
-
106
- """.format(
107
- INTERNAL_INLINE_TEXT,
108
- INTERNAL_INLINE_LINK,
109
- EXTERNAL_INLINE_TEXT_HTTP,
110
- EXTERNAL_INLINE_LINK_HTTP,
111
- EXTERNAL_INLINE_TEXT_HTTPS,
112
- EXTERNAL_INLINE_LINK_HTTP,
113
- INTERNAL_REFERENCE_TEXT,
114
- INTERNAL_REFERENCE_LABEL,
115
- EXTERNAL_REFERENCE_TEXT_HTTP,
116
- EXTERNAL_REFERENCE_LABEL_HTTP,
117
- EXTERNAL_REFERENCE_TEXT_HTTPS,
118
- EXTERNAL_REFERENCE_LABEL_HTTPS,
119
- INTERNAL_REFERENCE_LABEL,
120
- INTERNAL_REFERENCE_LINK,
121
- EXTERNAL_REFERENCE_LABEL_HTTP,
122
- EXTERNAL_REFERENCE_LINK_HTTP,
123
- EXTERNAL_REFERENCE_LABEL_HTTPS,
124
- EXTERNAL_REFERENCE_LINK_HTTPS,
125
- )
126
- )
127
-
128
- # Run the Pelican instance
129
- self.settings = read_settings(override=settings)
130
- pelican = Pelican(settings=self.settings)
131
- saved_stdout = sys.stdout
132
- sys.stdout = StringIO()
133
- pelican.run()
134
- sys.stdout = saved_stdout
135
-
136
- def tearDown(self):
137
- """Remove the temporary directories."""
138
- rmtree(self.output_path)
139
- rmtree(self.content_path)
140
-
141
- def search(self, string):
142
- """Search for a string in the article output."""
143
- with open(
144
- os.path.join(self.output_path, f"{TEST_FILE_STEM}.html"),
145
- ) as fid:
146
- found = False
147
- for line in fid.readlines():
148
- if re.search(string, line):
149
- found = True
150
- break
151
- return found
152
-
153
- def test_internal_inline(self):
154
- """Test for the internal inline link."""
155
- assert self.search(
156
- LINK_PATTERN.format(
157
- INTERNAL_CLASS,
158
- INTERNAL_INLINE_LINK,
159
- INTERNAL_INLINE_TEXT,
160
- )
161
- )
162
-
163
- def test_external_inline_http(self):
164
- """Test for the external http inline link."""
165
- assert self.search(
166
- LINK_PATTERN.format(
167
- EXTERNAL_CLASS,
168
- EXTERNAL_INLINE_LINK_HTTP,
169
- EXTERNAL_INLINE_TEXT_HTTP,
170
- )
171
- )
172
-
173
- def test_external_inline_https(self):
174
- """Test for the external https inline link."""
175
- assert self.search(
176
- LINK_PATTERN.format(
177
- EXTERNAL_CLASS,
178
- EXTERNAL_INLINE_LINK_HTTPS,
179
- EXTERNAL_INLINE_TEXT_HTTPS,
180
- )
181
- )
182
-
183
- def test_internal_reference(self):
184
- """Test for the internal reference link."""
185
- assert self.search(
186
- LINK_PATTERN.format(
187
- INTERNAL_CLASS,
188
- INTERNAL_REFERENCE_LINK,
189
- INTERNAL_REFERENCE_TEXT,
190
- )
191
- )
192
-
193
- def test_external_reference_http(self):
194
- """Test for the external http reference link."""
195
- assert self.search(
196
- LINK_PATTERN.format(
197
- EXTERNAL_CLASS,
198
- EXTERNAL_REFERENCE_LINK_HTTP,
199
- EXTERNAL_REFERENCE_TEXT_HTTPS,
200
- )
201
- )
202
-
203
- def test_external_reference_https(self):
204
- """Test for the external https reference link."""
205
- assert self.search(
206
- LINK_PATTERN.format(
207
- EXTERNAL_CLASS,
208
- EXTERNAL_REFERENCE_LINK_HTTPS,
209
- EXTERNAL_REFERENCE_TEXT_HTTPS,
210
- )
211
- )