Come fa Google Docs su Discourse a convertire così bene in Markdown?

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 Mi Piace

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

51 Mi Piace

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

55 Mi Piace

Concordo pienamente! Sono rimasto sorpreso diverse volte nel copiare documenti di Google Docs che avevamo redatto nelle Wiki di Discourse. Grazie @vinothkannans!

8 Mi Piace

Leggermente tangenziale rispetto al resto del tuo post… Ho letto da qualche parte che si possono ottenere risultati migliori se si esporta come .docx e poi si converte in Markdown con pandoc. E, per me, ha funzionato perfettamente (anche se non ho provato a esportare come .odt e convertire quello in Markdown).

Ma la prossima volta che dovrò convertire da Google Docs a Markdown, proverò sicuramente il ‘convertitore Discourse’ :slight_smile:

4 Mi Piace