-
-
Save kofm/56557deb9f20dd5f34c7e234a7de0b4b to your computer and use it in GitHub Desktop.
A pandoc filter for MS Word track changes to criticmarkup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- a lua filter for panodoc | |
-- run pandoc your_word_doc.docx --track-change=all -t markdown --lua-filter=criticmarkup.lua | |
-- TODO: Detect substitutions in adjacent insertion/deletions | |
-- TODO: capture whole comment hightlight rather than just start point of comment | |
function Span(elem) | |
if elem.classes[1] and elem.classes[1] == "insertion" then | |
local opener = { pandoc.RawInline(FORMAT, "{++ ") } | |
local closer = { pandoc.RawInline(FORMAT, " ++}") } | |
return opener .. elem.content .. closer | |
elseif | |
elem.classes[1] and elem.classes[1] == "deletion" then | |
local opener = { pandoc.RawInline(FORMAT, "{-- ") } | |
local closer = { pandoc.RawInline(FORMAT, " --}") } | |
return opener .. elem.content .. closer | |
elseif | |
elem.classes[1] and elem.classes[1] == "comment-start" then | |
if elem.t == nil then | |
return pandoc.RawInline(FORMAT, "") | |
end | |
local opener = { pandoc.RawInline(FORMAT, "{>> ") } | |
local closer = { pandoc.RawInline(FORMAT, " ("), pandoc.RawInline(FORMAT, elem.attributes.author), pandoc.RawInline(FORMAT, ")<<}")} | |
return opener .. elem.content .. closer | |
elseif | |
elem.classes[1] and (elem.classes[1] == "comment-end" or elem.classes[1] == "paragraph-insertion") then | |
return pandoc.RawInline(FORMAT, "") | |
else | |
return nil | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment