How is Google Docs to Markdown so good on Discourse?

AI-generated summary

The discussion revolves around the effectiveness of Discourse’s Google Docs to Markdown conversion feature. mbbroberg appreciates the smooth transition and automatic table formatting, wondering about the underlying code. codinghorror credits @vinothkannans for the hard work, who reveals that a custom HTML to markdown JS module was created in /app/assets/javascripts/discourse/app/lib/to-markdown.js.

Other users, such as travelvc, share their positive experiences with the feature. qaisjp provides a tangential tip on exporting Google Docs as .docx for better conversion results using pandoc, but also plans to try the ‘Discourse converter’ in the future.

I frequently need to convert Google Docs to Markdown for work. Instead of installing a slightly-sketchy extension or downloading at .odt then running pandoc to convert to .md, I frequently copy/paste right into a Discourse discussion and viola.

Every single time it’s the smoothest Markdown transition. The same happens for tables when I copy table-structured information and it automatically builds a Markdown table around it.

How does it do that?

I started poking around the source code but the JS libraries are a bit out of my skillset. I ask because if it’s something I could use elsewhere in open source (first up: Joplin).

Any tips or advice on walking the code is appreciated.

50 Likes

That’s the result of @vinothkannans hard work! :flexed_biceps:

51 Likes

We created our own HTML to markdown JS module in /app/assets/javascripts/discourse/app/lib/to-markdown.js. Thanks for the appreciation.

55 Likes

Totally agree! I have been amazed a number of times copying Google Docs we’ve drafted into Discourse Wikis. Thanks @vinothkannans!

8 Likes

Slightly tangential to the rest of your post… I read somewhere that you can get better results if you export as .docx and then pandoc that to Markdown. And, for me, it’s worked fine (but I haven’t tried exporting as .odt and converting that to Markdown).

But the next time I need to convert from Google Docs to Markdown, I’ll definitely give the ‘Discourse converter’ a go :slight_smile:

4 Likes