Hi,
Thanks, Leonard! That helps me a lot. :-)
I'm still wondering if it can be done without having to write raw OOXML. To me it feels that knowledge about OOXML is something that belongs into rather into a writer than in a filter. My idea is that the functions Emph, Para, and so on would return a pandoc.Div or pandoc.Span with the custom style as an attribute. (That is kind of how I imagine fenced divs and bracketed spans with custom styles work.)function Para(elem)return pandoc.Div(elem.c) -- set attribute with custom-style = 'CHAP_BM' hereendDoes that sound reasonable? How would one set attribute?Leonard Rosenthol schrieb am Mittwoch, 24. März 2021 um 19:23:41 UTC+1:Forgot two important methods!!```local function docx_inline(text)return pandoc.RawInline("openxml", text)endlocal function docx_block(text)return pandoc.RawBlock("openxml", text)end```On Wed, Mar 24, 2021 at 2:22 PM Leonard Rosenthol <leon...-bM6h3K5UM15l57MIdRCFDg@public.gmane.org> wrote:Unfortunately, you have to actually write the "raw" DOCX XML output from your filter. I did some of this in a bunch of filters that I wrote to handle producing ISO standards from markdown.here's an example of where I mapped definition lists to use a custom style in Word.```local RAW_TERM_OPEN = '<w:pPr><w:pStyle w:val="Term(s)"/></w:pPr><w:r><w:t>'local RAW_TERM_CLOSE = '</w:t></w:r>'local RAW_LINEBREAK = '<w:br />'local function do_def_list(dl)local outList = {}for i, item in ipairs(dl.content) do-- debug(string.format("Found item %d - %s | %s", i, pandoc.utils.stringify(item[1]), item[2]))local termNum = string.format("3.%d", i)local outTerm = docx_inline( RAW_TERM_OPEN ..termNum ..RAW_LINEBREAK ..pandoc.utils.stringify(item[1]) ..RAW_TERM_CLOSE)local outDef = item[2];table.insert(outList, {outTerm, outDef})endreturn pandoc.DefinitionList(outList)end-------------------------- don't do anything unless we target docxif FORMAT ~= "docx" thenreturn {}end-- this is the "main" Pandoc routine that connects the parts of the doc->methodsreturn {{DefinitionList = do_def_list,}}```On Wed, Mar 24, 2021 at 2:16 PM Henning Schwentner <henning.s...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:Hi,I've written a book on LeanPub and then signed a contract with a "real" publisher. Now I'm using Pandoc (thanks for the great tool!) to convert the sources from LeanPub's Markua to Addison-Wesley's homegrown Word template. They have defined their own style for everything, e.g. normal body text is in style CHAP_BM or emphasized text in style BOLD.I'm trying to write a Lua filter that makes use of the custom style feature of the Pandoc DOCX writer. So I want to replace the following Markdown# Chapter 1: IntroductionYou *really* have to be **honest** here.with::: {custom-style="CHAP_TTL"}Chapter 1: Introduction:::::: {custom-style="CHAP_BM"}You [really]{custom-style="ITAL"} have to be [honest]{custom-style="BOLD"} here.:::in my Lua filter so that the DOCX-Writer then can work its magic. I tried something likefunction Emph(elem)return '[' .. elem.c .. ']{custom-style="ITAL"}'endfunction Para(elem)return pandoc.Para('::: {custom-style="CHAP_BM"}\n' .. elem.c .. '\n:::')endbut it does not work—the whole text including the added ']{custom-style="ITAL"}' and so on ends up in the docx file and the formatting is not changed. What am I doing wrong?Any help here would be greatly appreciated!Best,Henning--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/95ba2798-44ed-4028-aed5-d3d868c9407bn%40googlegroups.com.