How to preserve formatting when converting Markdown to Word
Explains the reasons why titles, lists, code blocks and fonts are easily distorted after Markdown is converted to Word, and provides check items before conversion, steps to correct styles in Word after conversion, and a checklist.
Key points of this article
- Titles, lists, and code blocks are out of shape. Most of the time, the Markdown syntax is not recognized correctly. Check the syntax of the source file first and then convert it. It is less labor-intensive than modifying it piece by piece afterwards.
- There is no native style for code blocks in Word. Uniform width fonts and shading are used, which is less error-prone than manually setting the font line by line.
- After conversion, replace the manual font size with built-in styles such as "Heading 1, Heading 2" so that the table of contents, navigation pane and subsequent revisions can work properly.
- After the conversion, the title level, list number, code indentation, and Chinese and English fonts must be checked item by item. Important content requires manual review.
When converting notes, reports or paper drafts written in Markdown into Word, the common problem is not loss of content, but formatting: secondary headings become text, list numbers are messed up, code blocks are crowded together, and Chinese fonts and English fonts do not match. This type of problem is especially obvious when writing technical documents, course handouts, and project descriptions, because these contents contain a lot of titles, lists, and codes.
This article is for anyone who needs to hand over Markdown documents to others for review, printing, or archiving. After reading, you will be able to determine which formats are prone to problems during conversion, know what to check before conversion, and learn to use styles to correct titles, lists, and code blocks in Word at once instead of manually adjusting each section.
How to retain the format when converting to Word? One sentence conclusion
Whether the format can be preserved depends on two things: whether the Markdown syntax of the source file is standardized, and whether Word's style system is used to inherit it after conversion. The table below can help you quickly choose a method.
| your situation | Recommended practices | reason |
|---|---|---|
| The content is short, with only simple titles and paragraphs | Direct conversion, check title level after conversion | The format is simple, there are few mistakes, and manual verification is quick |
| Technical documentation with extensive headings, lists, and code blocks | Check the grammar first, then change the style uniformly in Word after conversion | Syntax errors will cause title or list recognition to fail. Unified styles can be fixed at once. |
| Formal drafts that need to be submitted to others for review or printing | Organize in UniDoc web editor and export to Word | You can confirm the format section by section in the editor, and the exported file is more suitable for continued editing. |
| Table of contents and chapter navigation need to be preserved | You must use Word's built-in "Heading 1" and "Heading 2" styles | The table of contents and navigation pane only recognize built-in title styles, and manual bold and large font sizes are invalid. |
| Documentation with lots of code snippets | Code blocks are uniformly set to a fixed-width font and shaded | Word does not have a native code block style. After unified settings, reading and typesetting will be more stable. |
Before you start: Confirm these points first
Before starting the conversion, taking a few minutes to check the source files can save a lot of rework time.
- Whether the title has spaces. Standard Markdown titles require a space after "#", such as "## Installation Steps". Without spaces, many conversion tools will treat this line as an ordinary paragraph, and the title level will be lost after conversion.
- Whether there are blank lines before and after the list. When a list follows a paragraph without a blank line, some parsers will swallow the list into the paragraph, causing confusion in numbering and indentation.
- Whether code blocks appear in pairs. The code block starts and ends with three backticks. If there is one missing end character, all the following content will be regarded as code, and the entire format will be distorted.
- Whether there are any special characters that need to be reserved in the document. If there are superscripts, subscripts, formulas or tables in the text, make sure they are written uniformly in the source file before conversion, otherwise it will be difficult to correct them one by one after conversion.
- The mixed fonts of Chinese and English should be thought of in advance. Word Chinese fonts and Western fonts are set separately. Decide in advance what Chinese font and English font to use for the main text. This will save a lot of trouble when you change the styles later.
Steps to correct headings, lists and code blocks in UniDoc web editor
The following steps are suitable for situations where the format is found to be incorrect after conversion and needs to be corrected uniformly. UniDoc web page editor supports Word-compatible editing and can export the organized content into Word files, which is suitable for this kind of finishing work.
- Open app.unidoc.top, create a new document, and paste the converted Markdown content or the organized text into it.
- Go through it from beginning to end, first looking only at the structure, not the font. Confirm whether the levels of first-level headings, second-level headings, and third-level headings are correct, and whether there are any paragraphs that should be headings but become text.
- Select the paragraphs that should be headings one by one, and set them to the corresponding heading style, such as "Heading 1" or "Heading 2". The table of contents and navigation generated in this way can be displayed correctly.
- Checklist. The unordered list and the ordered list must maintain consistent symbols and numbers. When encountering a point where the number is re-counted from the beginning, the starting number must be adjusted separately.
- Process code blocks. Select all code paragraphs, set them to a fixed-width font, such as Consolas or Courier New, and add a light gray shading to the paragraphs. Indentation within code should be preserved and tabs should not be replaced with spaces.
- Unify the text font. Set the Chinese text to a Chinese font, and set the English and numbers to a Western font to avoid the incongruity caused by mixing Chinese and English fonts in the same paragraph.
- Check tables and formulas. The column width and header bolding of the table must be reconfirmed. If the formula is a simple symbol, check whether it is displayed completely.
- After confirming that it is correct, export it to a Word format file, download it locally, and then open it with desktop office software to check it again.
Check each item after completion
Do not send the exported Word file directly. Check it item by item to avoid bringing formatting problems to readers.
| Check item | What do you think? | What if there's a problem? |
|---|---|---|
| Title level | Open the navigation pane to see if the chapter structure is consistent with the source file | Reset the paragraph at the error level to the corresponding heading style |
| Catalogue | Insert or update the catalog to see if the entry is complete and the page number is reasonable | There is a lack of entries in the directory, usually because the title is still in a manual format, changed to a built-in title style and regenerated. |
| List number | One by one ordered list to see whether the numbers are continuous and whether the symbols of the unordered list are unified. | When the number is broken, reset the starting number of the list; when the list is taken apart, merge adjacent paragraphs |
| Code block | Check whether the font is of equal width, indentation and line wrapping are normal | When indentation is lost, go back to the source file to check if spaces are used instead of Tab, correct and re-paste |
| Chinese and English fonts | Turn over a few paragraphs at random to see if the expected fonts are used in Chinese and English | Unify the revision in the style, not paragraph by paragraph, to avoid omission |
| Content integrity | Look at the source file and check for missing segments, missing pictures, or digital errors | Missing paragraphs are made up from the source file; machine-converted text, important numbers and technical terms should be checked manually |
# Core comparison
Many people will hesitate between "direct conversion" and "organize first and then convert". The difference between the two mainly lies in the workload and the stability of the results: the direct conversion speed is fast, but the title, list, and code blocks are easy to miss; first organize the source file syntax, and then convert, the later correction work will be much less, and the consistency of the final file is better.
| Practice | Suitable for the situation | Main risk |
|---|---|---|
| Direct conversion | Short essays with few titles and no code blocks | When the syntax is flawed, the title and list are easy to identify and fail, and need to be reworked paragraph by paragraph. |
| Sort out the grammar before you convert it | Technical documents, handouts, official manuscripts to be reviewed | It takes more time to check in the early stage, but the workload of subsequent correction is significantly reduced. |
# frequently asked questions (FAQ)
1. Why is there no shading in the code block from Markdown to Word?
Most of the conversion results retain only text and equal-width fonts, and do not add shading automatically. Select all the code paragraphs in Word and manually add light gray shading. If there are a lot of code blocks, it is recommended to set one segment uniformly, and then apply it to other code snippets with a format brush.
2. Why is the directory empty after conversion?
The table of contents only contains paragraphs that use the built-in heading style. If the titles are only manually bold and enlarged in font size, Word cannot recognize them. Change these titles to the "title 1" or "title 2" style, and then update the catalog.
3. What should I do if the numbering of the ordered list is confused after the conversion?
Numbering is usually due to the fact that the list is cut off by paragraphs or blank lines, or because the paragraph styles before and after the list are inconsistent. The problem can be solved by merging split list paragraphs or resetting the starting number at the list.
4. How to unify Chinese font and English font together?
In the style setting of Word, specify fonts for Chinese and western languages respectively, and apply them to the full text after modifying the text style. This is more reliable than stage-by-stage adjustment, and it is convenient for unified revision in the future.
5. Does the conversion result need to be manually reviewed?
Need. Machine conversion will inevitably lead to misplacement of individual symbols, incomplete display of formulas or rewriting of professional terms, especially those involving numbers, codes and proper nouns. Please check them item by item against the source file before export.
# Summary
When Markdown is converted to Word to retain the format, the key is to check the syntax before conversion and modify it uniformly with the title, list and font style of Word after conversion. Set the title to the built-in style, code block uniform and other wide fonts and shading, and then check the list item by item, most of the formatting problems can be solved in one revision.


