pilotmoon / PopClip-Extensions

Source code extensions in the official PopClip Extensions directory.

Home Page:https://www.popclip.app/extensions/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Copy HTML tables as Markdown

phaseOne opened this issue · comments

I noticed that the Copy As Markdown extension does not convert HTML tables to Markdown. I see from the docs that PopClip has integrated the Turndown package for conversion. @pilotmoon, from their docs it appears the addition of this feature here could be trivial by adding the turndown-plugin-gfm plugin to where Turndown is initialized in the PopClip closed source code. Once this has been completed, I don't believe any modifications to the Copy As Markdown extension are required. I'd make a PR, but I think this feature can only be added within the closed source components. I suppose I could make a forked version of this extension, but this seems like it would only be useful in the short-term.

Great suggestion.

I've had a go at implemeting this purely as an extension - see the referencing commit. Note it was developed against latest PopClip Build 3887 from https://pilotmoon.com/popclip/download.

Ideally, if I could get it to work I would integrate it into PopClip itself.

Unfortunately I can't get it to work. I think it may be because in PopClip we're using linkedom instead of JSDOM, so the document model is slightly different to what it is expecting. There's a rows property in the table node that it can't find. I've done as much as I can for now I think.