« get me outta code hell

keep processed <img>'s in <p> - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <towerofnix@gmail.com>2021-02-06 14:20:24 -0400
committer(quasar) nebula <towerofnix@gmail.com>2021-02-06 14:20:24 -0400
commit0f5721ccae35840e0ceed0be4c6e881c3a9911c4 (patch)
tree889dbdb4dfa7564f74778542e94b06501c0a139c
parente3c5e8a0fe66af6e72e6e0e01189903233e51b9a (diff)
keep processed <img>'s in <p>
-rwxr-xr-xupd8.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/upd8.js b/upd8.js
index 26416b7..ba002d8 100755
--- a/upd8.js
+++ b/upd8.js
@@ -472,6 +472,7 @@ function transformMultiline(text, treatAsDocument=false) {
     let inBlockquote = false;
 
     for (let line of text.split(/\r|\n|\r\n/)) {
+        const imageLine = line.startsWith('<img');
         line = line.replace(/<img (.*?)>/g, (match, attributes) => img({
             lazy: true,
             link: true,
@@ -545,7 +546,7 @@ function transformMultiline(text, treatAsDocument=false) {
             // certain inline element tags should still be postioned within a
             // paragraph; other elements (e.g. headings) should be added as-is
             const elementMatch = line.match(/^<(.*?)[ >]/);
-            if (elementMatch && !['a', 'abbr', 'b', 'bdo', 'br', 'cite', 'code', 'data', 'datalist', 'del', 'dfn', 'em', 'i', 'img', 'ins', 'kbd', 'mark', 'output', 'picture', 'q', 'ruby', 'samp', 'small', 'span', 'strong', 'sub', 'sup', 'svg', 'time', 'var', 'wbr'].includes(elementMatch[1])) {
+            if (elementMatch && !imageLine && !['a', 'abbr', 'b', 'bdo', 'br', 'cite', 'code', 'data', 'datalist', 'del', 'dfn', 'em', 'i', 'img', 'ins', 'kbd', 'mark', 'output', 'picture', 'q', 'ruby', 'samp', 'small', 'span', 'strong', 'sub', 'sup', 'svg', 'time', 'var', 'wbr'].includes(elementMatch[1])) {
                 lineTag = '';
             }
         }