Skip to content

Commit 9a46a35

Browse files
authored
Merge pull request #31 from mshroyer/fixup
Fixup lint and test
2 parents e8946a2 + 4a5b809 commit 9a46a35

2 files changed

Lines changed: 27 additions & 23 deletions

File tree

pelican/plugins/graphviz/mdx_graphviz.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@
4848

4949
import base64
5050
import errno
51+
import os
5152
import re
53+
from subprocess import PIPE, Popen
5254
import xml.etree.ElementTree as ET
5355

5456
from markdown import Extension
@@ -65,9 +67,6 @@ def __init__(self, errmsg):
6567

6668
def run_graphviz(program, code, options=None, format="png"):
6769
"""Run graphviz program and returns image data."""
68-
import os
69-
from subprocess import PIPE, Popen
70-
7170
if not options:
7271
options = []
7372

@@ -184,7 +183,12 @@ def run(self, parent, blocks):
184183
r"<!-- Title: (.*) Pages: \d+ -->",
185184
output.decode("utf-8"),
186185
)
187-
if m:
186+
# Gating against a matched title of "%3" works around an old
187+
# graphviz issue, which is still present in the version
188+
# shipped with Ubuntu 24.04:
189+
#
190+
# https://gitlab.com/graphviz/graphviz/-/issues/1376
191+
if m and m.group(1) != "%3":
188192
img.set("alt", m.group(1))
189193
else:
190194
img.set("alt", config["alt-text-default"])

pelican/plugins/graphviz/test_graphviz.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828

2929
TEST_FILE_STEM = "test"
3030
TEST_DIR_PREFIX = "pelicantests."
31-
GRAPHVIZ_RE = r'<{0} class="{1}"><img alt="{2}" src="data:image/svg\+xml;base64,[0-9a-zA-Z+=]+"></{0}>'
31+
GRAPHVIZ_RE = (
32+
r'<{0} class="{1}"><img alt="{2}" '
33+
r'src="data:image/svg\+xml;base64,[0-9a-zA-Z+=]+"></{0}>'
34+
)
3235

3336
GRAPHVIZ_RE_XML = r'<svg width="\d+pt" height="\d+pt"'
3437

@@ -214,24 +217,21 @@ def test_output(self):
214217
"""Test for GRAPHVIZ_IMAGE_CLASS setting."""
215218
TestGraphviz.test_output(self)
216219

217-
# This test is commented out because it fails in the GitHub action, even
218-
# though it works fine locally. For some strange reason, the alt property
219-
# is set to "%3", instead of "foo". This should be investigated further.
220-
#
221-
# class TestGraphvizAltTextWithoutID(TestGraphviz):
222-
# """Class for testing the case where the Graphviz element has no id."""
223-
#
224-
# def setUp(self):
225-
# """Initialize the configuration."""
226-
# TestGraphviz.setUp(
227-
# self,
228-
# digraph_id=None,
229-
# alt_text="foo",
230-
# )
231-
#
232-
# def test_output(self):
233-
# """Test for GRAPHVIZ_IMAGE_CLASS setting."""
234-
# TestGraphviz.test_output(self)
220+
221+
class TestGraphvizAltTextWithoutID(TestGraphviz):
222+
"""Class for testing the case where the Graphviz element has no id."""
223+
224+
def setUp(self):
225+
"""Initialize the configuration."""
226+
TestGraphviz.setUp(
227+
self,
228+
digraph_id=None,
229+
alt_text="foo",
230+
)
231+
232+
def test_output(self):
233+
"""Test for GRAPHVIZ_IMAGE_CLASS setting."""
234+
TestGraphviz.test_output(self)
235235

236236

237237
class TestGraphvizAltTextViaOption(TestGraphviz):

0 commit comments

Comments
 (0)