Skip to content

Pandoc Lua filters for handling comments during Markdown ↔ DOCX conversions

License

Notifications You must be signed in to change notification settings

qq3g7bad/pandoc-comment-extractor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

pandoc-comment-extractor

A Pandoc Lua filter for embedding and extracting comments between Markdown and DOCX.

🌱 Overview

This repository contains two Pandoc Lua filters for handling comments during Markdown ↔ DOCX conversions:

  1. md2docx_add_comment.lua
    • Embeds HTML-style comments (<!-- comment -->) from Markdown into DOCX as document comments.
  2. docx2md_add_comment.lua
    • Extracts comments from DOCX headers and converts them back into Markdown comments.

These filters are useful for tracking metadata across conversions.


🚀 Usage

🔴 Markdown → DOCX (md2docx_add_comment.lua)

Use this script to embed comments into DOCX headers.

$ pandoc input.md -o output.docx --lua-filter=md2docx_add_comment.lua

Example

Markdown Input:

<!-- COMMENT EXAMPLE -->
## Section 1

DOCX Output:

  • The header "Section 1" will have a comment attached: COMMENT EXAMPLE.

🔵 DOCX → Markdown (docx2md_add_comment.lua)

Use this script to extract comments from DOCX and restore them as Markdown comments.\

Note

Use the --track-changes=all option for extracting DOCX comments.

$ pandoc input.docx -t gfm -o output.md --track-changes=all --lua-filter=docx2md_add_comment.lua

Example

DOCX Input:

  • A document with a header "Section 1" containing a comment: COMMENT EXAMPLE.

Markdown Output:

<!-- COMMENT EXAMPLE -->
## Section 1

🟡 Installation

Clone this repository and use the Lua filters with Pandoc:

$ git clone https://github.com/qq3g7bad/pandoc-comment-extractor.git
$ cd pandoc-comment-extractor
$ pandoc input.md -o output.docx --lua-filter=md2docx_add_comment.lua
$ pandoc input.docx -t gfm -o output.md --track-changes=all --lua-filter=docx2md_add_comment.lua

About

Pandoc Lua filters for handling comments during Markdown ↔ DOCX conversions

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages