Convert Word Documents to Markdown for LLM / AI consumptions

I’ve finally had the time to convert preprint academic articles of JCRINN to markdowns!

Microsoft Word documents are common in research, teaching, and administration. When preparing these documents for a large language model (LLM), converting them to Markdown gives you a readable text file that you can inspect, edit, and supply to an AI application.

Pandoc is a command-line document converter available on Linux. It supports Microsoft DOCX input and several Markdown formats, making it useful for preparing manuscripts, reports, lecture notes, and technical documentation. Its focus is document structure, rather than reproducing the original page layout. Pandoc documentation

For academic writing, sections such as Introduction, Methods, Results, and Discussion provide useful boundaries. A retrieval system can divide a document at these boundaries and retrieve relevant passages when answering a question. Microsoft’s Azure AI Search documentation provides a concrete example of indexing Markdown by heading and retaining section information. This supports using Markdown as a practical format for structured retrieval. Microsoft documentation

The practical benefits include:

  • Visible input: You can review the actual text supplied to the AI application.
  • Reusable content: The same file can support summarisation, question answering, search, and a document knowledge base.
  • Source tracking: Keeping the title, authors, DOI, and source URL helps connect extracted claims to their original document.
  • Controlled selection: You can provide relevant sections instead of repeatedly submitting the complete document.

Markdown does not make an LLM automatically understand a document better or prevent invented answers. It also does not necessarily reduce token usage compared with a good DOCX text extractor. File size on disk is not a reliable measure of model input tokens. The benefit is greater control over the text and structure entering your workflow.

How to convert DOCX documents to Markdown in Ubuntu / Linux

Step 1: Install Pandoc

sudo apt install pandoc

Ubuntu’s repository version may be older than the latest upstream release. If you need a newer feature or conversion fix, consult the official Pandoc installation instructions. A LaTeX installation is unnecessary for DOCX-to-Markdown conversion.

Step 2 : Convert DOCX to Markdown (single file)

pandoc "report.docx" --from=docx --to=gfm --wrap=none -o "report.md"

For an academic manuscript with footnotes and equations, Pandoc’s own Markdown format is another useful choice:

To extract embedded images and update their references:

pandoc "report.docx" --from=docx --to=markdown --wrap=none \
  --extract-media="report-assets" -o "report.md

These formats and options are documented in the Pandoc User’s Guide. Running another example with the same output filename replaces the previous Markdown file.

An image reference does not give a text-only model access to the image’s contents. Supply figures separately to a vision-capable system, or add verified descriptions and relevant values as text.

Step 3: Review the converted document

Compare it with the Word original. Check section headings, numerical results, units, table labels, equations, references, and figure captions. Complex tables and formatting may not survive conversion accurately. Pandoc conversion limitations

For research documents, retain the qualifications attached to findings. A reported accuracy value without its dataset, evaluation method, or limitations can produce a misleading summary.

Step 4: Use the Markdown with an LLM

Upload the file to an application that accepts Markdown, or paste a relevant section into the conversation. For a larger collection, configure your retrieval workflow to preserve document identity and section headings with each passage.

A useful starting prompt is:

Using only the supplied document, identify the research objective, method, dataset, main results, and limitations. Cite the relevant section for each item. Preserve numerical values and units exactly. If information is absent, state “not reported”.

BONUS: Batch convert all DOCX files with bash

For a folder containing several documents, save the following script as batch-docx-to-markdown.sh

The script can be downloaded here in this gist: https://gist.github.com/mypapit/df6615f8611f03678bc93ee0485001be#file-batch-docx-to-markdown-sh

Test Solar PV Monitoring Dashboards Using an Open-Source Renogy BT-1 Simulator

Renogy BT-1 telemetry provides useful information for monitoring the condition and performance of a solar photovoltaic system. It can report key values such as PV voltage, current, power generation, battery status, controller temperature, charging activity, and load consumption. These data are important for building dashboards, alerts, databases, and automation systems.

However, developing and testing such a monitoring system normally requires access to real Renogy hardware, including a compatible charge controller and BT-1 Bluetooth module. This can make early development difficult, especially when developers need to reproduce specific conditions such as low battery voltage, peak sunlight, nighttime discharge, or controller inactivity.

My latest open-source project, Renogy BT-1 Telemetry Simulator, removes this hardware requirement.

Application Screenshot

The Renogy BT-1 Telemetry Simulator addresses this problem by generating realistic sample telemetry and sending it as JSON to an HTTP or HTTPS endpoint without requiring physical solar equipment.

The simulator imitates telemetry commonly produced by a Renogy BT-1 module connected to a Renogy Rover MPPT charge controller.

You can manually configure values such as:

  • Solar PV voltage, current, power, and generated energy
  • Battery percentage, voltage, current, temperature, and battery type
  • Controller temperature and charging status
  • Load voltage, current, power, and energy consumption
  • Controller model, device ID, and BT-1 identifier

The application can also calculate PV and load power automatically.

Renogy BT-1 Telemetry Simulator Use Cases

The simulator is useful for testing the Solar PV under various situations:

  • Peak Sunshine
  • Nighttime operations
  • Low battery conditions
  • Heavy loads / light loads

Application Features

  • One-off HTTP Post transmission
  • Periodic transmission at a configurable interval
  • A default two-minute sending interval
  • Live JSON payload preview
  • Transmission logs with HTTP status, response, errors, and request duration

This is useful for testing local development servers, webhooks, staging systems, database storage, monitoring dashboards, and automated alerts before installing physical solar hardware.

Requirements

The application uses WPF and .NET 8, so it runs on Windows 10 or Windows 11. Developers can build it using Visual Studio 2022 or the standard dotnet command-line tools.

The current HTTP client accepts self-signed HTTPS certificates for local testing. This behaviour should not be treated as secure certificate validation for production systems.

Download the Source Code

Renogy BT-1 Telemetry Simulator is available on GitHub:

github.com/mypapit/renogybt1simulator

The project is released under the GNU General Public License version 3, allowing users to study, modify, and redistribute the source code according to the GPL terms.

This project is an independent simulator and is not an official Renogy product.

How to convert character encoding in text files

Here is how to convert text files from one character encoding to another in GNU/Linux:

#eg1
iconv -f ASCII -t UTF-8//IGNORE file.txt -o output.txt

#eg 2
iconv -f ISO-8859-1 -t UTF-8//TRANSLIT file.txt output.txt

The -f parameter denotes “from” and -t parameter denotes “to” character set.
//IGNORE means the “iconv” will ignore any characters that are not available in the target character set.

While “//TRANSLIT” means the converter will attempt to substitute characters that are not available in the target character set to the closest characters available, failing that, “???” will be replaced in its place.

Most GNU/Linux distribution have iconv preinstalled, if not, please consult your distribution documentation.