forked from github/pelican
Convert Wordpress caption to figure
In Wordpress, inserting image with a caption can look like: [caption id="attachment_42" caption="Image Description"]<a ...><img ... /></a>[/caption] [caption id="attachment_42"]<a ...><img ... /></a> Image Description[/caption] [caption id="attachment_42"]<img ... > Image Description[/caption] Replace by an HTML figure tag
This commit is contained in:
parent
3be0703b14
commit
48166bd687
3 changed files with 79 additions and 1 deletions
|
|
@ -334,6 +334,32 @@ class TestWordpressXmlImporter(unittest.TestCase):
|
|||
escaped_quotes = re.search(r'\\[\'"“”‘’]', md)
|
||||
self.assertFalse(escaped_quotes)
|
||||
|
||||
def test_convert_caption_to_figure(self):
|
||||
def r(f):
|
||||
with open(f, encoding='utf-8') as infile:
|
||||
return infile.read()
|
||||
silent_f2p = mute(True)(fields2pelican)
|
||||
test_post = filter(
|
||||
lambda p: p[0].startswith("Caption on image"),
|
||||
self.posts)
|
||||
with temporary_folder() as temp:
|
||||
md = [r(f) for f in silent_f2p(test_post, 'markdown', temp)][0]
|
||||
|
||||
caption = re.search(r'\[caption', md)
|
||||
self.assertFalse(caption)
|
||||
|
||||
for occurence in [
|
||||
'/theme/img/xpelican.png.pagespeed.ic.Rjep0025-y.png',
|
||||
'/theme/img/xpelican-3.png.pagespeed.ic.m-NAIdRCOM.png',
|
||||
'/theme/img/xpelican.png.pagespeed.ic.Rjep0025-y.png',
|
||||
'This is a pelican',
|
||||
'This also a pelican',
|
||||
'Yet another pelican',
|
||||
]:
|
||||
# pandoc 2.x converts into 
|
||||
# pandoc 3.x converts into <figure>src<figcaption>text</figcaption></figure>
|
||||
self.assertIn(occurence, md)
|
||||
|
||||
|
||||
class TestBuildHeader(unittest.TestCase):
|
||||
def test_build_header(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue