Skip to content

Commit

Permalink
convert \n to spaces in the alt text
Browse files Browse the repository at this point in the history
hoping gohugoio/hugo#11681 to be fixed
  • Loading branch information
yihui committed Nov 8, 2023
1 parent 8d87e63 commit fc1b233
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion js/alt-title.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[...document.getElementsByTagName('img')].forEach(el => {
if (!el.title) el.title = el.alt;
if (el.alt) {
el.alt = el.alt.replace(/\n/g, ' ');
if (!el.title) el.title = el.alt;
}
});

0 comments on commit fc1b233

Please sign in to comment.