Skip to content

Commit

Permalink
Check for empty keys (fixes #1)
Browse files Browse the repository at this point in the history
  • Loading branch information
erayd committed Nov 23, 2020
1 parent a9e92e0 commit d4fa7a5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/slightly.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ import MarkdownIt from "markdown-it";
.then(p => {
// post-process images
p.content.querySelectorAll("img[src*='#']").forEach(img => {
if (img.parentNode.childElementCount === 1) img.parentNode.replaceWith(img);
let f = document.createElement("figure");
f.style.maxWidth = img.style.maxWidth;
img.style.maxWidth = "100%";
Expand All @@ -211,7 +212,9 @@ import MarkdownIt from "markdown-it";
decodeURI(format)
.split(";")
.forEach(attr => {
let [, key, val] = attr.trim().match(/^(.+?)(?:\s*=\s*(.+))?$/);
let matches = attr.trim().match(/^(.+?)(?:\s*=\s*(.+))?$/);
if (!matches) return;
let [, key, val] = matches;
switch (key) {
case "left":
case "right":
Expand Down

0 comments on commit d4fa7a5

Please sign in to comment.