From 878a28a030b0205b07ad18d3a4ba5817e7c52f5e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 11 Dec 2017 01:47:02 +0100 Subject: [PATCH] m.abbr: fix case of empty title, test it. --- pelican-plugins/m/abbr.py | 4 +-- pelican-plugins/m/test/abbr/page.html | 41 +++++++++++++++++++++++++++ pelican-plugins/m/test/abbr/page.rst | 6 ++++ pelican-plugins/m/test/test_abbr.py | 12 ++++++++ 4 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 pelican-plugins/m/test/abbr/page.html create mode 100644 pelican-plugins/m/test/abbr/page.rst create mode 100644 pelican-plugins/m/test/test_abbr.py diff --git a/pelican-plugins/m/abbr.py b/pelican-plugins/m/abbr.py index 7e19629e..39163c9d 100644 --- a/pelican-plugins/m/abbr.py +++ b/pelican-plugins/m/abbr.py @@ -28,8 +28,8 @@ from docutils.parsers import rst def abbr(name, rawtext, text, lineno, inliner, options={}, content=[]): abbr, title = parse_link(text) - if not title: - return [nodes.abbreviation(abbr, abbr)], [] + if not abbr: + return [nodes.abbreviation(title, title)], [] return [nodes.abbreviation(abbr, abbr, title=title)], [] def register(): diff --git a/pelican-plugins/m/test/abbr/page.html b/pelican-plugins/m/test/abbr/page.html new file mode 100644 index 00000000..b827dd05 --- /dev/null +++ b/pelican-plugins/m/test/abbr/page.html @@ -0,0 +1,41 @@ + + + + + m.abbr | A Pelican Blog + + + + + + + + + + + + + +
+
+
+
+
+
+

m.abbr

+ +

Text. Text.

+ +
+
+
+
+
+ + diff --git a/pelican-plugins/m/test/abbr/page.rst b/pelican-plugins/m/test/abbr/page.rst new file mode 100644 index 00000000..5268b216 --- /dev/null +++ b/pelican-plugins/m/test/abbr/page.rst @@ -0,0 +1,6 @@ +m.abbr +###### + +:summary: no. + +:abbr:`Text `. :abbr:`Text`. diff --git a/pelican-plugins/m/test/test_abbr.py b/pelican-plugins/m/test/test_abbr.py new file mode 100644 index 00000000..47210f33 --- /dev/null +++ b/pelican-plugins/m/test/test_abbr.py @@ -0,0 +1,12 @@ +from m.test import PluginTestCase + +class Abbr(PluginTestCase): + def __init__(self, *args, **kwargs): + super().__init__(__file__, '', *args, **kwargs) + + def test(self): + self.run_pelican({ + 'PLUGINS': ['m.htmlsanity', 'm.abbr'] + }) + + self.assertEqual(*self.actual_expected_contents('page.html')) -- 2.30.2