đ§ Second Brain
Search
Convert Markdown to Rich Text (Google Docs)
When you work with Markdown you inevitably will need an efficient way to convert from Markdown to Rich Text sometimes, e.g., Google Docs. Tweet
GDocs -> Markdown
The other way around can be achieved simply with the Google Docs extension: Docs⢠to Markdown - Google Workspace Marketplace. Or in Google Docs you can now export directly export as MD with
File -> Download -> Markdown (.md)
.
# Why to convert?
Usually, if you work in your Second Brain, let’s say with Neovim or Obsidian, you need to share a doc with someone else, which is something Markdown is less good.
# Share Collaboratively
You could simply share it with something like HackMD. I even shared how to still use Obsidian/Neovim and collaboratively work on HackMD in HackMD (check Obsidian chapter) with Symbolic Link and GitHub repo.
# Share via Website (HTML)
Either share it via MD, publish it to your website with something like QuartzâQuartz - Publish Obsidian Vault, or use the conversion tools explained below.
Side-Note
This very website is a markdown and shared with the mentioned Quartz. There has been zero conversion or formatting; it’s 1:1 the Markdown file I have written.
# Conversion: Export with Pandoc
But there are easier ways with Pandoc. Once the plugin is installed, and you have locally Pandoc installed, check with the below script:
|
|
You can simply export the document to the format of your liking:
You’ll see all the Pandoc Plugin:
exporter; they support all major formats such as MS Word (docx), LibreOffice (ODT), and many others. Notice that I also installed Better Export PDF and Excalidraw, which show up in the above image.
# The challenges
Text with bold, italic, links, and tables usually has no problems. What you need to have a special look at is:
- in-line-code and code-blocks
- call-outs
- footnotes
- images
- Header formatting (h1-h7)
The best format I found is odt
with Open Libre Office. It does convert the header correctly, e.g., title h1 is still h1. If you use docx, these are usually gone.
Also, images will be converted correctly, except I have problems with webp
, as these sometimes get added as binary text to the document, which makes opening the document very laggy. Better duplicate the markdown file, remove all .webp
, and export.
Once you have the odt
file, you can simply copy and paste the text from the open LibreOffice file to Google Docs, and all formatting will persist.
Note: that code (inline or blocks) is just changed to mono fonts like Courier New
. So, if you want to upload it further to a website, e.g., Webflow, WordPress, or any others, make sure that you add the proper block within your tool of use. These tools usually need an additional marker. For example, in Webflow, you need to manually add a block and cut and paste the code into it (see more on
docs).
That’s why using Markdown for web formatting is so much simpler. There is no anxiety that carefully formatted text will get lost; it contains all the content, including formatting, unlike rich text tools like Google Docs. Read more on Rich Text.
# Examples
# Exported with Obsidian Pandoc to OpenLibre and copy+paste to Google Docs
- The H2 header has persisted
- bold/italic is accurately kept
- code block formatted with a different font, here
Courier New
- Links are properly converted
- Call outs are visible as such, but need extra care if you use Webflow, or other tools
- Tables are correctly converted
- Images, here PNG, are converted and exported, too.
An Example of an exported Markdown file to OpenLibre odt file format.
# Paste from Markdown: Google Docs
Wow, I just learned even another, easier way: Copy your MD to the clipboard and Paste from Markdown
, I didn’t know they added this feature. Bravo Google Docs team đđť.
Please Activate
This option is not activated by default. The âCopy as Markdownâ and âPaste from âMarkdownâ options will be OFF by default and can be enabled in Docs by going toÂ
Tools > Preferences > Enable Markdown
. Visit the Help Center to learn more about using Markdown in Google Docs, Slides, & Drawings.
And then you can simply Paste from Markdown
(and Copy as Markdown)
Even images work !!
Another option to export can be achieved with Copy as Markdown
, or download Gdoc file as MD file with File -> Download -> Markdown (.md)
.
# Export MD directly with Google Docs
TIL (2024-10-14), you can import a Markdown file directly with Google docs File -> Open
 or Open with Google Docs
 from Drive. Read more on
Google Workspace Updates: Import and export Markdown in Google Docs.
Origin: Markdown vs Rich Text
References:
Created 2024-10-14