plemarquand / obsidian-capture

Chrome extension to send sites and selections directly to Obsidian
MIT License
0 stars 0 forks source link

HTMLarkdown maintainer says hi! #1

Open EvitanRelta opened 1 year ago

EvitanRelta commented 1 year ago

Hello!

I'm the maintainer of HTMLarkdown, and saw u were using the package.
I haven't really tried using it beyond Jest unit tests, so I was wondering if u've encountered any problem with it? or got any feedback/questions on it?

I see that ure removing <article> tags and replacing &nbsp; with spaces in ur code snippet below, so im guessing its not working as u hoped?

// HTMLarkdown doesn't like the <article> tag that comes out of readability.
content = content.replace('<article>', '').replace('</article>', '')

const htmlarkdown = new HTMLarkdown()
let markdown = htmlarkdown.convert(content, true).replace(/&nbsp;/g, ' ')

Also, sorry for the lack of documentations for adding custom rules.
Haven't got around adding those yet, but I can help if u need a specific feature from HTMLarkdown!

plemarquand commented 1 year ago

Hi @EvitanRelta, thanks for reaching out!

I've switched to using a proper noop rule for the <article> tag locally, but I'm going to keep encountering that kind of issue with every tag that HTMLardown doesn't understand (so far I've also encountered oddball tags like <figure> and <picture> not working). Ideally there would be a way to make all unknown tags a no-op/passthrough as opposed to just dropping their contents.

I'm replacing &nbsp;s just because the ultimate destination for the markdown doesn't support them, not sure thats something HTMLarkdown should care about

EvitanRelta commented 1 year ago

yo sflr! Have been busy with school work.

Alright thanks for the feedback!
In the future, I'm planning to add

But for now, to fix ur 1st issue, u could do:

const htmlarkdown = new HTMLarkdown()

/** Noop rule, that is associated with any element. */
const blanketNoopRule: Rule = {
    filter: [() => true],
    replacement: () => innerContent => innerContent
}

// Set the rule to run LAST, after all other rules.
// This will make it so that it's the "default rule", should an element not
// match any other rule.
htmlarkdown.addRule(blanketNoopRule, false)