1 files changed, 13 insertions(+), 6 deletions(-)
M web2gmi.js
M web2gmi.js => web2gmi.js +13 -6
@@ 32,15 32,22 @@ const convert = (dom, title) => {
output += `# ${title}\n\n`;
}
+ const rewriteLink = href =>
+ "?" + encodeURIComponent(href);
+
const emitLink = link => {
- let desc = sanitize(link.innerHTML);
- if (desc === "") {
- const img = link.querySelector("img");
- if (img) {
- desc = `${img.alt ? " " + img.alt : ""}\n\n`;
- }
+ let desc = sanitize(link.innerHTML);
+ if (desc === "") {
+ const img = link.querySelector("img");
+ if (img) {
+ desc = `${img.alt ? " " + img.alt : ""}\n\n`;
}
+ }
+ if (link.protocol === "http:" || link.protocol === "https:") {
+ output += `=> ${rewriteLink(link.href)} ${desc}\n`;
+ } else {
output += `=> ${link.href} ${desc}\n`;
+ }
};
let visited = [];