How can doc/docx files be converted to markdown or

2020-05-11 10:16发布

Is there a program or workflow to convert .doc or .docx files to Markdown or similar text?

PS: Ideally, I would welcome the option that a specific font (e.g. consolas) in the MS Word document will be rendered to text-code: ```....```.

11条回答
Ridiculous、
2楼-- · 2020-05-11 10:39

Here's an open-source web application built in Ruby to do this exact thing: https://word2md.com

查看更多
【Aperson】
3楼-- · 2020-05-11 10:42

Given that you asked this question on stackoverflow you're probably wanting a programmatic or command line solution for which I've included another answer.

However, an alternative solution might be to use the Writage Markdown plugin for Microsoft Word.

Writage turns Word into your Markdown WYSIWYG editor, so you will be able to open a Markdown file and edit it like you normally edit any document in Microsoft Word. Also it will be possible to save your Word document as a Markdown file without any other converters.

Under the covers, Writage uses Pandoc that you'll also need to install for this plugin to work.

It currently supports the following Markdown elements:

  • Headings
  • Lists (numbered and bulleted)
  • Links
  • Font styles such as bold, italic
  • Tables
  • Footnotes

This might be the ideal solution for many end users as they won't need to install or run any command line tools - but rather just stick with what they are most familiar.

查看更多
【Aperson】
4楼-- · 2020-05-11 10:43

You can use Word to Markdown (Ruby Gem) to convert it in one step. Conversion can be as simple as:

$ gem install word-to-markdown
$ w2m path/to/document.docx

It routes the document through LibreOffice, but also does it best to semantice headings based on their relative font size.

There's also a hosted version which would be as simple as drag-and-drop to convert.

查看更多
祖国的老花朵
5楼-- · 2020-05-11 10:44

If you're using Linux, try Pandoc (first convert .doc/.docx into html with LibreOffice or something and then run it).

On Windows (or if Pandoc doesn't work), you can try this website (online demo, you can download it): Markdownify

查看更多
【Aperson】
6楼-- · 2020-05-11 10:45

From here:

unoconv -f html test.docx
pandoc -f html -t markdown -o test.md test.html
查看更多
登录 后发表回答