diff --git a/lib/obsidian-image.js b/lib/obsidian-image.js index 0a13430..fd9a3c0 100644 --- a/lib/obsidian-image.js +++ b/lib/obsidian-image.js @@ -1,6 +1,7 @@ import {visit} from "unist-util-visit"; const regex = /\!\[\[(([a-z\-_0-9\\/\:]+\s*)+\.(jpg|jpeg|png|gif|svg|webp))]]/gi; +const regex2 = /\!\[\[(([a-z\-_0-9\\/\:]+\s*)+\.(jpg|jpeg|png|gif|svg|webp))]]/gi; //TODO why can't I reuse regex literal??? function convertTextNode(node) { const searchText = node.value; @@ -46,7 +47,8 @@ function convertTextNode(node) { }; const imageNode = { - type: "myImage", + type: "image", + //TODO: Use some kind of option to pass in default images path url: encodeURI(match[1]), //encode white space from file name alt: match[1], }; @@ -77,7 +79,7 @@ function convertTextNode(node) { export default function attacher(options) { return function transformer(tree, vfile) { visit(tree, "text", (node) => { - if (regex.test(node.value)) { + if (regex2.test(node.value)) { const newNode = convertTextNode(node); node.type = "paragraph"; node.children = newNode.children;