Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button to copy as [cleaned] HTML #79

Open
jkingsman opened this issue Jul 24, 2023 · 3 comments
Open

Button to copy as [cleaned] HTML #79

jkingsman opened this issue Jul 24, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@jkingsman
Copy link
Contributor

I'd be interested in a feature to convert the cleaned markdown into clean HTML and then copy that (eliminating all the cruft of the Google Drive HTML export). Basically, alongside the Copy Markdown and Download Markdown (that I'm adding right now), there'd be a Copy HTML.

However, I know that that is adding essentially a new format to export in that's not Markdown.

I'm personally interested in this feature, but am more than happy to fork and add it there rather than PR this.

When I write this, @Mr0grog, are you interested in a PR? Or is that getting a bit too far from your vision?

@Mr0grog
Copy link
Owner

Mr0grog commented Jul 25, 2023

Hmmm, I think I’m a little on the fence about that. With the conversion to Markdown, things are comparably straightforward. Lots of stuff in Google Docs just can’t be represented in Markdown and it gets thrown out; stuff is pretty stripped down. On the other hand, HTML output can be as stripped down or detailed as you want, and there are lots of ways to do things, so it feels like this necessarily involves a lot of opinion about what kind of HTML you want, or what kinds of formatting you want to drop vs. keep, etc. It seems to me like this feature wind up being as big as the rest of the library.

What exactly are you thinking here? Or is your intent to strip stuff down just as much as you would for Markdown, so this is effectively like converting to Markdown, then rendering as HTML (even if that’s not necessarily how it actually works)?

@jkingsman
Copy link
Contributor Author

this is effectively like converting to Markdown, then rendering as HTML (even if that’s not necessarily how it actually works)?

Exactly. My idea was using Markdown as a relatively clean intermediary; probably something along the lines of taking the Markdown and handing it to Showdown. My use case would be Copy as HTML for sites that accept limited/vanilla HTML for styling like forums, text sharing sites like Archive of our Own, etc. My current workflow is drafting in Google Docs and using your site to bring it to Markdown which I can then use my local Markdown editor to export as clean, limited HTML for import to those sites -- this would eliminate a step there and let me paste-then-click to go from Docs to those sites.

Hmmm, I think I’m a little on the fence about that.

Totally understand. That's why I wanted to discuss rather than just PRing -- I totally get that it's very much a tack-on to your functionality and don't want to be presumptuous in proposing it on top of the meat of your work.

Lots of stuff in Google Docs just can’t be represented in Markdown and it gets thrown out; stuff is pretty stripped down.

I honestly hadn't thought of that, but I would imagine that almost all generated Markdown would pass through an HTML renderer fine (although I admit it was only today I really looked at the code you wrote for Docs => Markdown conversion; great stuff in the face of spaghetti hah). I don't think that the HTML conversion would be mutating/dropping things all that much more.

Thanks for your thoughts and time!

@Mr0grog
Copy link
Owner

Mr0grog commented Aug 2, 2023

Sorry I lost track of this issue. Thinking on it more, this might be useful, and I’d be OK if you want to work on adding it (assuming you’re still interested!).

probably something along the lines of taking the Markdown and handing it to Showdown.

I think this should use Remark/Rehype packages for this (example usage) since we are already in that ecosystem. (You can see where we set up a similar processing pipeline in convert.js).

I would imagine that almost all generated Markdown would pass through an HTML renderer fine

Yeah, it’s always valid Markdown output, which means it will definitely make valid HTML. I was more concerned that Docs → Markdown → HTML would strip out more than desired from the original doc, but it sounds like really stripping things down (not just simplifying the HTML code) is exactly what you want from from this, so it makes sense. (For example, if you have colored text in your doc, the Markdown conversion here will strip it out, which is intentional — 99% of the time, you don’t want that in a Markdown version of the doc.)

@Mr0grog Mr0grog added the enhancement New feature or request label Aug 2, 2023
@Mr0grog Mr0grog changed the title Button to copy cleaned HTML -- PR or fork? Button to copy as [cleaned] HTML Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants