1
0
Fork 0
forked from github/pelican

Merge pull request #1507 from dairiki/bug.rst-newlines-in-abbr

Fix for #949 bug with custom reST :abbr: role
This commit is contained in:
Justin Mayer 2014-12-06 08:35:43 -08:00
commit 7b852ffe9d
2 changed files with 33 additions and 1 deletions

View file

@ -70,7 +70,7 @@ directives.register_directive('code-block', Pygments)
directives.register_directive('sourcecode', Pygments)
_abbr_re = re.compile('\((.*)\)$')
_abbr_re = re.compile('\((.*)\)$', re.DOTALL)
class abbreviation(nodes.Inline, nodes.TextElement):

View file

@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, print_function
from mock import Mock
from pelican.tests.support import unittest
class Test_abbr_role(unittest.TestCase):
def call_it(self, text):
from pelican.rstdirectives import abbr_role
rawtext = text
lineno = 42
inliner = Mock(name='inliner')
nodes, system_messages = abbr_role(
'abbr', rawtext, text, lineno, inliner)
self.assertEqual(system_messages, [])
self.assertEqual(len(nodes), 1)
return nodes[0]
def test(self):
node = self.call_it("Abbr (Abbreviation)")
self.assertEqual(node.astext(), "Abbr")
self.assertEqual(node['explanation'], "Abbreviation")
def test_newlines_in_explanation(self):
node = self.call_it("CUL (See you\nlater)")
self.assertEqual(node.astext(), "CUL")
self.assertEqual(node['explanation'], "See you\nlater")
def test_newlines_in_abbr(self):
node = self.call_it("US of\nA \n (USA)")
self.assertEqual(node.astext(), "US of\nA")
self.assertEqual(node['explanation'], "USA")