Fix image caption generated by pandoc with fancybox enabled

This commit is contained in:
Mimi 2021-08-28 15:49:05 +08:00
parent e410399aac
commit c377515fd7
2 changed files with 6 additions and 2 deletions

View File

@ -45,7 +45,8 @@
margin-left: 4px;
}
.image-caption, .figure .caption {
// For fancybox and pandoc
.image-caption, img + figcaption, .fancybox + figcaption {
color: $grey-dark;
font-size: $font-size-small;
font-weight: bold;

View File

@ -49,7 +49,10 @@ NexT.utils = {
const imageTitle = $image.attr('title') || $image.attr('alt');
if (imageTitle) {
$imageWrapLink.append(`<p class="image-caption">${imageTitle}</p>`);
// Do not append image-caption if pandoc has already created a figcaption
if (!$imageWrapLink.next('figcaption').length) {
$imageWrapLink.append(`<p class="image-caption">${imageTitle}</p>`);
}
// Make sure img title tag will show correctly in fancybox
$imageWrapLink.attr('title', imageTitle).attr('data-caption', imageTitle);
}