mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
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
|
|
@ -107,6 +107,13 @@ def decode_wp_content(content, br=True):
|
|||
return re.sub(pattern, lambda m: dic[m.group()], string)
|
||||
content = _multi_replace(pre_tags, content)
|
||||
|
||||
# convert [caption] tags into <figure>
|
||||
content = re.sub(
|
||||
r'\[caption(?:.*?)(?:caption=\"(.*?)\")?\]'
|
||||
r'((?:\<a(?:.*?)\>)?(?:\<img.*?\>)(?:\<\/a\>)?)\s?(.*?)\[\/caption\]',
|
||||
r'<figure>\n\2\n<figcaption>\1\3</figcaption>\n</figure>',
|
||||
content)
|
||||
|
||||
return content
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue