Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
$ pandoc -s <input>.docx --wrap=none --reference-links --extract-media=media -t gfm --filter ./ -o <output>.md


  • --wrap=none 勝手にwrapさせたくない(defaultではwrapしてしまう)
  • --reference-links
  • --extract-media=media docxに埋め込まれたpngなどを抽出できる
  • -t gfm github形式のmarkdownで出力したい(tableがpandoc defaultのmarkdownは他の形式になってしまう)

ref: Pandoc - Pandoc User’s Guide

ref: How to remove title anchor when converting docx to markdown? · Issue #1893 · jgm/pandoc

  • filterを使い、title anchorを削除する
#!/usr/bin/env python
# copied from
Pandoc filter to convert all regular text to uppercase.
Code, link URLs, etc. are not affected.
from pandocfilters import toJSONFilter, Str
def despan(key, value, format, meta):
if key == 'Span':
return []
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment