mirror of
https://github.com/danpros/htmly.git
synced 2026-04-20 12:36:23 +05:30
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:
parent
013c18e975
commit
9f1874345a
1 changed files with 5 additions and 0 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue