Open Andrea-28-03 opened 10 months ago
Smart join is incredible but it delete all the links and tabulations.
Because smart join operates in pure text mode. And it is (almost) intended for pasting from PDF.
Is there a way to fix it also with an custom trasform it would be really usefull
Yes, a custom transform could do it.
From the picture you provided, It seems that there are spaces and newlines inside markdown links. I checked it and it looks like a bug in turndown.
So if you want to write a custom transform to do the task, note that remark will produce a bad syntax tree because of it. Of course you can also use regex instead of remark to avoid it.
The following script might helps. It uses a simple regex.
export async function stripWhiteSpacesInLinks(input, { turndown }) {
if (input.types.includes("text/html")) {
const html = await input.getType("text/html");
const md = turndown.turndown(await html.text());
return md.replace(/\[\n*(.*)\n*\]\((.*)\)/gm, "[$1]($2)");
}
return { kind: "err", value: "No html found in clipboard!" };
}
stripWhiteSpacesInLinks.type = "blob";
No, I tried it, it works exactly like the normal copy and paste. I think it can't find the link...
I tried some different replacement or founding methods, but them didn't change anything
export async function fanculo(input, { turndown }) {
if (input.types.includes("text/html")) {
const html = await input.getType("text/html");
const md = turndown.turndown(await html.text());
return md.replace(/\[\n*(.*)\n*\]\(html:\\(.*)\)/sgu, " [$1]($2)");
/*return md.replace(/\[.*(\d+).*\].*?\(html:\\(.*?)\)/gms, function (match, text, url) {
// Personalizza la formattazione dei link come desiderato
return ` [${text}](${url})`;*/
}
return {kind: "err", value: "No html found in clipboard!"};
}
fanculo.type = "blob";
The script works for me.
It seems I can't expect this bug to be fixed on turndown's side: https://github.com/mixmark-io/turndown/pull/419
When I get more time I will fix it in the default paste command, maybe by maintaining a fork of turndown.
You are right, using perplexity from the official website and then pasting it with your script does work, really great. But from the custom frame of perplexity it doesn't, it would be great if you knew a workaround about that, but it is ok also like that, thanks
Hi, I use perplexity and it makes citations that when i normally copy and paste them on obsidian they breake and make a lot of blanks lines,
![image](https://github.com/kxxt/obsidian-advanced-paste/assets/62112468/f559a5c6-faa4-4d7c-8129-ce1a1ae49503)
Smart join is incredible but it delete all the links and tabulations. Is there a way to fix it also with an custom trasform it would be really usefull It does this only with that site and can't understand why...