Skip to content

Instantly share code, notes, and snippets.

@yzhang2907
Created July 8, 2024 16:16
Show Gist options
  • Save yzhang2907/a7012b271b5e9dae3c1bf12f21eacbe5 to your computer and use it in GitHub Desktop.
Save yzhang2907/a7012b271b5e9dae3c1bf12f21eacbe5 to your computer and use it in GitHub Desktop.
pandoc: Convert DOCX to Markdown That Displays Properly in VS Code Preview

Pandoc: Convert DOCX to Markdown That Displays Properly in VS Code Preview

Normally, you get something like this if you don't specify anything beyond "markdown":

Command: pandoc -t markdown .\test-pandoc.docx -o test-pandoc.md

Result:

  -----------------------------------------------------------------------
  **Table heading 1**     **Table heading 2**     **Table heading 3**
  ----------------------- ----------------------- -----------------------
  Content                 Content content         Content                                         
  -----------------------------------------------------------------------

Which shows up weird in VS Code preview.

VS Code preview likes pipe tables, so we gotta disable a couple of pandoc plugins.

Command: pandoc -f docx -t markdown-simple_tables-multiline_tables-grid_tables .\test-pandoc.docx -o test-pandoc.md

Result:

| **Table heading 1** | **Table heading 2** | **Table heading 3** |
|---------------------|---------------------|---------------------|
| Content             | Content content     | Content             |

This should now show up nice and proper in VS Code preview panel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment