mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-18 18:33:42 +00:00
Support linebreaks inside a and img elements
* See: https://github.com/next-theme/hexo-theme-next/issues/497
This commit is contained in:
parent
968ac54906
commit
edf3675f32
@ -10,13 +10,13 @@ hexo.extend.filter.register('after_post_render', data => {
|
||||
const theme = hexo.theme.config;
|
||||
if (!theme.exturl && !theme.lazyload) return;
|
||||
if (theme.lazyload) {
|
||||
data.content = data.content.replace(/(<img[^>]*) src=/img, '$1 data-src=');
|
||||
data.content = data.content.replace(/(<img[^>]*)src=/ig, '$1data-src=');
|
||||
}
|
||||
if (theme.exturl) {
|
||||
const siteHost = parse(config.url).hostname || config.url;
|
||||
// External URL icon
|
||||
const exturlIcon = theme.exturl_icon ? '<i class="fa fa-external-link-alt"></i>' : '';
|
||||
data.content = data.content.replace(/<a[^>]* href="([^"]+)"[^>]*>([^<]+)<\/a>/img, (match, href, html) => {
|
||||
data.content = data.content.replace(/<a[^>]*href="([^"]+)"[^>]*>([^<]+)<\/a>/ig, (match, href, html) => {
|
||||
// Exit if the href attribute doesn't exists.
|
||||
if (!href) return match;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user