Images with nonempty alt text, occurring by itself in a paragraph, will be rendered as figure with a caption, like pandoc's markdown (see <https://pandoc.org/MANUAL.html#images>). This is controlled with a new configuration option fig.captions.

This commit is contained in:
Stefan Björk 2019-12-12 15:52:42 +01:00
commit 9f1874345a

View file

@ -360,6 +360,11 @@ function get_posts($posts, $page = 1, $perpage = 0)
// Get the contents and convert it to HTML
$post->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
// Convert image tags to figures
if (config('fig.captions') == 'true') {
$post->body = preg_replace( '/<p>(<img .*?alt="(.*?)"\s*\/>)<\/p>/', '<figure>$1<figcaption>$2</figcaption></figure>', $post->body );
}
if (config('views.counter') == 'true') {
$post->views = get_views($post->file);
} else {