pelican-linkclass 2.1.2__py3-none-any.whl → 2.1.4__py3-none-any.whl
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.
- pelican/plugins/linkclass/test_linkclass.py +212 -0
- {pelican_linkclass-2.1.2.dist-info → pelican_linkclass-2.1.4.dist-info}/METADATA +8 -8
- pelican_linkclass-2.1.4.dist-info/RECORD +8 -0
- {pelican_linkclass-2.1.2.dist-info → pelican_linkclass-2.1.4.dist-info}/WHEEL +1 -1
- pelican_linkclass-2.1.2.dist-info/RECORD +0 -8
- tasks.py +0 -99
- {pelican_linkclass-2.1.2.dist-info → pelican_linkclass-2.1.4.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,212 @@
|
|
|
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
|
+
template = """Title: Test
|
|
91
|
+
Date: 1970-01-01
|
|
92
|
+
|
|
93
|
+
This is an [{}]({}), inline-style link.
|
|
94
|
+
This is an [{}]({}), inline-style link (with http URL).
|
|
95
|
+
This is an [{}]({}), inline-style link (with https URL).
|
|
96
|
+
|
|
97
|
+
This is an [{}][{}], reference-style link.
|
|
98
|
+
This is an [{}][{}], reference-style link (with http URL).
|
|
99
|
+
This is an [{}][{}], reference-style link (with https URL).
|
|
100
|
+
|
|
101
|
+
[{}]: {}
|
|
102
|
+
[{}]: {}
|
|
103
|
+
[{}]: {}
|
|
104
|
+
|
|
105
|
+
"""
|
|
106
|
+
fid.write(
|
|
107
|
+
template.format(
|
|
108
|
+
INTERNAL_INLINE_TEXT,
|
|
109
|
+
INTERNAL_INLINE_LINK,
|
|
110
|
+
EXTERNAL_INLINE_TEXT_HTTP,
|
|
111
|
+
EXTERNAL_INLINE_LINK_HTTP,
|
|
112
|
+
EXTERNAL_INLINE_TEXT_HTTPS,
|
|
113
|
+
EXTERNAL_INLINE_LINK_HTTP,
|
|
114
|
+
INTERNAL_REFERENCE_TEXT,
|
|
115
|
+
INTERNAL_REFERENCE_LABEL,
|
|
116
|
+
EXTERNAL_REFERENCE_TEXT_HTTP,
|
|
117
|
+
EXTERNAL_REFERENCE_LABEL_HTTP,
|
|
118
|
+
EXTERNAL_REFERENCE_TEXT_HTTPS,
|
|
119
|
+
EXTERNAL_REFERENCE_LABEL_HTTPS,
|
|
120
|
+
INTERNAL_REFERENCE_LABEL,
|
|
121
|
+
INTERNAL_REFERENCE_LINK,
|
|
122
|
+
EXTERNAL_REFERENCE_LABEL_HTTP,
|
|
123
|
+
EXTERNAL_REFERENCE_LINK_HTTP,
|
|
124
|
+
EXTERNAL_REFERENCE_LABEL_HTTPS,
|
|
125
|
+
EXTERNAL_REFERENCE_LINK_HTTPS,
|
|
126
|
+
)
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
# Run the Pelican instance
|
|
130
|
+
self.settings = read_settings(override=settings)
|
|
131
|
+
pelican = Pelican(settings=self.settings)
|
|
132
|
+
saved_stdout = sys.stdout
|
|
133
|
+
sys.stdout = StringIO()
|
|
134
|
+
pelican.run()
|
|
135
|
+
sys.stdout = saved_stdout
|
|
136
|
+
|
|
137
|
+
def tearDown(self):
|
|
138
|
+
"""Remove the temporary directories."""
|
|
139
|
+
rmtree(self.output_path)
|
|
140
|
+
rmtree(self.content_path)
|
|
141
|
+
|
|
142
|
+
def search(self, string):
|
|
143
|
+
"""Search for a string in the article output."""
|
|
144
|
+
with open(
|
|
145
|
+
os.path.join(self.output_path, f"{TEST_FILE_STEM}.html"),
|
|
146
|
+
) as fid:
|
|
147
|
+
found = False
|
|
148
|
+
for line in fid.readlines():
|
|
149
|
+
if re.search(string, line):
|
|
150
|
+
found = True
|
|
151
|
+
break
|
|
152
|
+
return found
|
|
153
|
+
|
|
154
|
+
def test_internal_inline(self):
|
|
155
|
+
"""Test for the internal inline link."""
|
|
156
|
+
assert self.search(
|
|
157
|
+
LINK_PATTERN.format(
|
|
158
|
+
INTERNAL_CLASS,
|
|
159
|
+
INTERNAL_INLINE_LINK,
|
|
160
|
+
INTERNAL_INLINE_TEXT,
|
|
161
|
+
)
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
def test_external_inline_http(self):
|
|
165
|
+
"""Test for the external http inline link."""
|
|
166
|
+
assert self.search(
|
|
167
|
+
LINK_PATTERN.format(
|
|
168
|
+
EXTERNAL_CLASS,
|
|
169
|
+
EXTERNAL_INLINE_LINK_HTTP,
|
|
170
|
+
EXTERNAL_INLINE_TEXT_HTTP,
|
|
171
|
+
)
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
def test_external_inline_https(self):
|
|
175
|
+
"""Test for the external https inline link."""
|
|
176
|
+
assert self.search(
|
|
177
|
+
LINK_PATTERN.format(
|
|
178
|
+
EXTERNAL_CLASS,
|
|
179
|
+
EXTERNAL_INLINE_LINK_HTTPS,
|
|
180
|
+
EXTERNAL_INLINE_TEXT_HTTPS,
|
|
181
|
+
)
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
def test_internal_reference(self):
|
|
185
|
+
"""Test for the internal reference link."""
|
|
186
|
+
assert self.search(
|
|
187
|
+
LINK_PATTERN.format(
|
|
188
|
+
INTERNAL_CLASS,
|
|
189
|
+
INTERNAL_REFERENCE_LINK,
|
|
190
|
+
INTERNAL_REFERENCE_TEXT,
|
|
191
|
+
)
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
def test_external_reference_http(self):
|
|
195
|
+
"""Test for the external http reference link."""
|
|
196
|
+
assert self.search(
|
|
197
|
+
LINK_PATTERN.format(
|
|
198
|
+
EXTERNAL_CLASS,
|
|
199
|
+
EXTERNAL_REFERENCE_LINK_HTTP,
|
|
200
|
+
EXTERNAL_REFERENCE_TEXT_HTTPS,
|
|
201
|
+
)
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
def test_external_reference_https(self):
|
|
205
|
+
"""Test for the external https reference link."""
|
|
206
|
+
assert self.search(
|
|
207
|
+
LINK_PATTERN.format(
|
|
208
|
+
EXTERNAL_CLASS,
|
|
209
|
+
EXTERNAL_REFERENCE_LINK_HTTPS,
|
|
210
|
+
EXTERNAL_REFERENCE_TEXT_HTTPS,
|
|
211
|
+
)
|
|
212
|
+
)
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pelican-linkclass
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.4
|
|
4
4
|
Summary: Pelican plugin to set anchor tag's class attribute to differentiate between internal and external links
|
|
5
|
-
|
|
6
|
-
|
|
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: =?utf-8?q?Rafael_Laboissi=C3=A8re?= <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
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
pelican/plugins/linkclass/__init__.py,sha256=re7EWl6N43Ej9nzpMFA7ajrG5TBjlQAQmoYRK27mo28,39
|
|
2
|
+
pelican/plugins/linkclass/linkclass.py,sha256=CtfkYJhNq9_g4hy40gvhfIk8f-CvI4QBLrhyHEbfVRg,1790
|
|
3
|
+
pelican/plugins/linkclass/mdx_linkclass.py,sha256=bISYENA4fq1z-ZY5z0TH6qCA5HRbsc4M4oZTd1yIZ0Q,3978
|
|
4
|
+
pelican/plugins/linkclass/test_linkclass.py,sha256=WssY-P0Ita2oQW5DObaof7JSCZZjypnbLwIK9NK9XsM,7013
|
|
5
|
+
pelican_linkclass-2.1.4.dist-info/METADATA,sha256=QQIpZAwZhsojyWTrWVbtQY2_D0YJx0d4FkTPLHDnlhw,5384
|
|
6
|
+
pelican_linkclass-2.1.4.dist-info/WHEEL,sha256=gZRWN_1fGFDwBnXrZ9N3dgvbKlKgo5AUcDIMajlGpKM,90
|
|
7
|
+
pelican_linkclass-2.1.4.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
|
8
|
+
pelican_linkclass-2.1.4.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
tasks.py,sha256=R4_NgphMhr2hskgNHL1nh9MACePHIqcwjEnDz6gAaJ4,3167
|
|
2
|
-
pelican/plugins/linkclass/__init__.py,sha256=re7EWl6N43Ej9nzpMFA7ajrG5TBjlQAQmoYRK27mo28,39
|
|
3
|
-
pelican/plugins/linkclass/linkclass.py,sha256=CtfkYJhNq9_g4hy40gvhfIk8f-CvI4QBLrhyHEbfVRg,1790
|
|
4
|
-
pelican/plugins/linkclass/mdx_linkclass.py,sha256=bISYENA4fq1z-ZY5z0TH6qCA5HRbsc4M4oZTd1yIZ0Q,3978
|
|
5
|
-
pelican_linkclass-2.1.2.dist-info/METADATA,sha256=qgC6-tyaD0e6D7eO6BQrOEnzWI-VuAlYQz1phl0VVg8,5339
|
|
6
|
-
pelican_linkclass-2.1.2.dist-info/WHEEL,sha256=9QBuHhg6FNW7lppboF2vKVbCGTVzsFykgRQjjlajrhA,87
|
|
7
|
-
pelican_linkclass-2.1.2.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
|
8
|
-
pelican_linkclass-2.1.2.dist-info/RECORD,,
|
tasks.py
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
from inspect import cleandoc
|
|
2
|
-
import logging
|
|
3
|
-
import os
|
|
4
|
-
from pathlib import Path
|
|
5
|
-
from shutil import which
|
|
6
|
-
|
|
7
|
-
from invoke import task
|
|
8
|
-
|
|
9
|
-
logger = logging.getLogger(__name__)
|
|
10
|
-
|
|
11
|
-
PKG_NAME = "linkclass"
|
|
12
|
-
PKG_PATH = Path(f"pelican/plugins/{PKG_NAME}")
|
|
13
|
-
|
|
14
|
-
ACTIVE_VENV = os.environ.get("VIRTUAL_ENV", None)
|
|
15
|
-
VENV_HOME = Path(os.environ.get("WORKON_HOME", "~/.local/share/virtualenvs"))
|
|
16
|
-
VENV_PATH = Path(ACTIVE_VENV) if ACTIVE_VENV else (VENV_HOME.expanduser() / PKG_NAME)
|
|
17
|
-
VENV = str(VENV_PATH.expanduser())
|
|
18
|
-
BIN_DIR = "bin" if os.name != "nt" else "Scripts"
|
|
19
|
-
VENV_BIN = Path(VENV) / Path(BIN_DIR)
|
|
20
|
-
|
|
21
|
-
TOOLS = ("pdm", "pre-commit")
|
|
22
|
-
PDM = which("pdm") if which("pdm") else (VENV_BIN / "pdm")
|
|
23
|
-
CMD_PREFIX = f"{VENV_BIN}/" if ACTIVE_VENV else f"{PDM} run "
|
|
24
|
-
PRECOMMIT = which("pre-commit") if which("pre-commit") else f"{CMD_PREFIX}pre-commit"
|
|
25
|
-
PTY = os.name != "nt"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
@task
|
|
29
|
-
def tests(c, deprecations=False):
|
|
30
|
-
"""Run the test suite, optionally with `--deprecations`."""
|
|
31
|
-
deprecations_flag = "" if deprecations else "-W ignore::DeprecationWarning"
|
|
32
|
-
c.run(f"{CMD_PREFIX}pytest {deprecations_flag}", pty=PTY)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
@task
|
|
36
|
-
def black(c, check=False, diff=False):
|
|
37
|
-
"""Run Black auto-formatter, optionally with `--check` or `--diff`."""
|
|
38
|
-
check_flag, diff_flag = "", ""
|
|
39
|
-
if check:
|
|
40
|
-
check_flag = "--check"
|
|
41
|
-
if diff:
|
|
42
|
-
diff_flag = "--diff"
|
|
43
|
-
c.run(f"{CMD_PREFIX}black {check_flag} {diff_flag} {PKG_PATH} tasks.py", pty=PTY)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
@task
|
|
47
|
-
def ruff(c, fix=False, diff=False):
|
|
48
|
-
"""Run Ruff to ensure code meets project standards."""
|
|
49
|
-
diff_flag, fix_flag = "", ""
|
|
50
|
-
if fix:
|
|
51
|
-
fix_flag = "--fix"
|
|
52
|
-
if diff:
|
|
53
|
-
diff_flag = "--diff"
|
|
54
|
-
c.run(f"{CMD_PREFIX}ruff check {diff_flag} {fix_flag} .", pty=PTY)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
@task
|
|
58
|
-
def lint(c, fix=False, diff=False):
|
|
59
|
-
"""Check code style via linting tools."""
|
|
60
|
-
ruff(c, fix=fix, diff=diff)
|
|
61
|
-
black(c, check=(not fix), diff=diff)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
@task
|
|
65
|
-
def tools(c):
|
|
66
|
-
"""Install development tools in the virtual environment if not already on PATH."""
|
|
67
|
-
for tool in TOOLS:
|
|
68
|
-
if not which(tool):
|
|
69
|
-
logger.info(f"** Installing {tool} **")
|
|
70
|
-
c.run(f"{CMD_PREFIX}pip install {tool}")
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
@task
|
|
74
|
-
def precommit(c):
|
|
75
|
-
"""Install pre-commit hooks to .git/hooks/pre-commit."""
|
|
76
|
-
logger.info("** Installing pre-commit hooks **")
|
|
77
|
-
c.run(f"{PRECOMMIT} install")
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
@task
|
|
81
|
-
def setup(c):
|
|
82
|
-
"""Set up the development environment."""
|
|
83
|
-
if which("pdm") or ACTIVE_VENV:
|
|
84
|
-
tools(c)
|
|
85
|
-
c.run(f"{CMD_PREFIX}python -m pip install --upgrade pip", pty=PTY)
|
|
86
|
-
c.run(f"{PDM} update --dev", pty=PTY)
|
|
87
|
-
precommit(c)
|
|
88
|
-
logger.info("\nDevelopment environment should now be set up and ready!\n")
|
|
89
|
-
else:
|
|
90
|
-
error_message = """
|
|
91
|
-
PDM is not installed, and there is no active virtual environment available.
|
|
92
|
-
You can either manually create and activate a virtual environment, or you can
|
|
93
|
-
install PDM via:
|
|
94
|
-
|
|
95
|
-
curl -sSL https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py | python3 -
|
|
96
|
-
|
|
97
|
-
Once you have taken one of the above two steps, run `invoke setup` again.
|
|
98
|
-
""" # noqa: E501
|
|
99
|
-
raise SystemExit(cleandoc(error_message))
|
|
File without changes
|