I just realized that I forgot one essential part: to check that the raw LaTeX element contains `\noindent`! Here is the corrected version: ``````lua function Para (para) if 'RawInline' == para.content[1].tag then -- Format may be 'tex' or 'latex' if para.content[1].format:match('tex$') then -- Don't forget this: if para.content[1].text:match('\\noindent') then para.content:remove(1) -- It may be followed by a space if 'Space' == para.content[1].tag then para.content:remove(1) end return pandoc.Div( {para}, {['custom-style'] = 'Body Text 2'} ) end end end return nil end `````` Den fre 11 mars 2022 18:55Paul Kelleher skrev: > Thank you! > > I also just realized that since I write md with Scrivener, I can create a > component type "noindent" and then change the prefix (and, if needed, > suffix) of the block of text contained in that component. I just played > with that and it's working wonderfully. But your solutions will be very > useful if/when I'm unable to use Scrivener. Thanks again! > > On Friday, March 11, 2022 at 11:14:55 AM UTC-6 BP wrote: > >> You can do it, but there are quite a few things you need to think about: >> >> ``````lua >> function Para (para) >> if 'RawInline' == para.content[1].tag then >> -- Format may be 'tex' or 'latex' >> if para.content[1].format:match('tex$') then >> para.content:remove(1) >> -- It may be followed by a space >> if 'Space' == para.content[1].tag then >> para.content:remove(1) >> end >> return pandoc.Div( >> {para}, >> {['custom-style'] = 'Body Text 2'} >> ) >> end >> end >> return nil >> end >> `````` >> >> I would do it the other way around and insert the `\noindent` when >> producing LaTeX (although I think it is not needed, since Pandoc sets >> `parindent` to zero). The code is much simpler! >> >> ``````lua >> function Div (div) >> if 'Body Text 2' == div.attributes['custom-style'] then >> if 'Para' == div.content[1].tag then >> div.content[1].content:insert( >> 1, >> pandoc.RawInline('latex', "\\noindent ") -- Note the trailing >> space! >> ) >> return div >> end >> end >> return nil >> end >> `````` >> >> HTH, >> >> /bpj >> >> Den fre 11 mars 2022 17:21Paul Kelleher skrev: >> >>> Thank you! I was able to get this to work great for compiling from md to >>> docx. But if want to compile from md to pdf, I need "\noindent". If I wrote >>> using \noindent, could a filter be used to strip out that latex command and >>> then wrap the paragraph in that custom-style div? >>> >>> On Friday, March 11, 2022 at 1:23:03 AM UTC-6 BP wrote: >>> >>>> You can use a custom-style div: >>>> >>>> ``````markdown >>>> ::: {custom-style="Body Text 2"} >>>> Paragraph text. >>>> ::: >>>> `````` >>>> >>>> >>>> >>>> Den tors 10 mars 2022 21:45Paul Kelleher >>>> skrev: >>>> >>>>> Thank you so much for posting this filter that converts the paragraph >>>>> after block quote to Body Text 2! It worked great for me. But: I also have >>>>> other element environments (e.g. equations) that I'd like to suppress >>>>> indents after when I use pandoc to compile md to docx. I couldn't get your >>>>> complex paragraphs filter to work for me. However, I'm already used to >>>>> writing "\noindent" from my LaTeX days (and it helps to have that if I want >>>>> to compile md to tex anyway). Would it be possible to write a filter that >>>>> assigns the Block Text 2 style to every paragraph that starts with >>>>> "\noindent"? >>>>> >>>>> On Wednesday, October 27, 2021 at 11:57:34 AM UTC-5 Bastien Dumont >>>>> wrote: >>>>> >>>>>> If all you want is to prevent indentation, you can use a filter that >>>>>> I wrote for a similar need: >>>>>> https://github.com/badumont/lua-filters/tree/complex-paragraphs/complex-paragraphs >>>>>> (which supports other output formats and enables you to control more >>>>>> precisely what is indented or not). If you really need to set a style, the >>>>>> following filter should work: >>>>>> >>>>>> ``` >>>>>> is_preceding_BlockQuote = false >>>>>> >>>>>> function Block(block) >>>>>> if block.t == 'BlockQuote' then >>>>>> is_preceding_BlockQuote = true >>>>>> elseif is_preceding_BlockQuote == true then >>>>>> is_preceding_BlockQuote = false >>>>>> return pandoc.Div(block, {['custom-style'] = 'Body Text 2'}) >>>>>> end >>>>>> end >>>>>> ``` >>>>>> >>>>>> Le Wednesday 27 October 2021 à 09:32:34AM, Landon Yarrington a écrit >>>>>> : >>>>>> > To clarify, in the MRE above, my goal is to get the paragraph >>>>>> immediately after >>>>>> > the blockquote to render as "Body Text 2" according to the style in >>>>>> the >>>>>> > ref_template.docx. Using this and every other stylesheet I've made, >>>>>> the >>>>>> > following paragraphs always come out as style "First Paragraph." >>>>>> > >>>>>> > On Wednesday, October 27, 2021 at 12:28:02 PM UTC-4 Landon >>>>>> Yarrington wrote: >>>>>> > >>>>>> > I'm trying to process block quotes in a way such that the following >>>>>> > paragraph directly after a block quote is styled as a continuation >>>>>> of the >>>>>> > paragraph in which the blockquote is nested. I tried several >>>>>> different >>>>>> > styles, but cannot seem to achieve this. I almost filed an issue on >>>>>> GH, but >>>>>> > thought twice :-) >>>>>> > >>>>>> > I'm using pandoc 2.15 with the following command. >>>>>> > >>>>>> > `pandoc -N -t docx -f >>>>>> > >>>>>> markdown+markdown_attribute+mmd_link_attributes+simple_tables+multiline_tables+auto_identifiers+table_captions+yaml_metadata_block+raw_attribute+implicit_figures+latex_macros+header_attributes >>>>>> >>>>>> > --reference-doc=ref_template.docx example.md -o TEST_example.docx` >>>>>> > Is this a user-error, a problem with my ref_template.docx, or what? >>>>>> > >>>>>> > And here's `example.md` >>>>>> > ```` >>>>>> > # Heading1 >>>>>> > >>>>>> > Here's some text. Here's some text. Here's some text. Here's some >>>>>> text. >>>>>> > Here's some text. Here's some text. Here's some text. Here's some >>>>>> text. >>>>>> > Here's some text. Here's some text. Here's some text. Here's some >>>>>> text. >>>>>> > Here's some text. Here's some text. Here's some text. Here's some >>>>>> text. >>>>>> > Here's some text. Here's some text. Here's some text. Here's some >>>>>> text. >>>>>> > Here's some text. Here's some text. Here's some text. >>>>>> > >>>>>> > Here's some text. Here's some text. Here's some text. Here's some >>>>>> text. >>>>>> > Here's some text. Here's some text. Here's some text. Here's some >>>>>> text. >>>>>> > Here's some text. Here's some text. Here's some text. Here's some >>>>>> text. >>>>>> > >>>>>> > ## Heading 2 >>>>>> > >>>>>> > Here's some text. Here's some text. Here's some text. Here's some >>>>>> text. >>>>>> > Here's some text. Here's some text. Here's some text. Here's some >>>>>> text. >>>>>> > Here's some text. >>>>>> > >>>>>> > Here's some text. Here's some text. Here's some text. Here's some >>>>>> text. >>>>>> > Here's some text. Here's some text. >>>>>> > >>>>>> > > Block quote time. Block quote time. Block quote time. Block quote >>>>>> time. >>>>>> > Block quote time. Block quote time. Block quote time. Block quote >>>>>> time. >>>>>> > Block quote time. Block quote time. Block quote time. Block quote >>>>>> time. >>>>>> > Block quote time. Block quote time. Block quote time. Block quote >>>>>> time. >>>>>> > Block quote time. Block quote time. Block quote time. >>>>>> > >>>>>> > Back to the text. Back to the text. Back to the text. Back to the >>>>>> text. >>>>>> > Back to the text. >>>>>> > >>>>>> > Here's some text. Here's some text. Here's some text. Here's some >>>>>> text. >>>>>> > Here's some text. Here's some text. Here's some text. Here's some >>>>>> text. >>>>>> > Here's some text. Here's some text. >>>>>> > ```` >>>>>> > >>>>>> > -- >>>>>> > 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 [1]pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> > To view this discussion on the web visit [2] >>>>>> https://groups.google.com/d/msgid/ >>>>>> > pandoc-discuss/86c4d6cd-4ea3-41ad-aae9-c301f049a2can% >>>>>> 40googlegroups.com. >>>>>> > >>>>>> > References: >>>>>> > >>>>>> > [1] mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org >>>>>> > [2] >>>>>> https://groups.google.com/d/msgid/pandoc-discuss/86c4d6cd-4ea3-41ad-aae9-c301f049a2can%40googlegroups.com?utm_medium=email&utm_source=footer >>>>>> >>>>>> -- >>>>> 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...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/pandoc-discuss/bc83b25d-d676-4582-ba04-830e3f378c2an%40googlegroups.com >>>>> >>>>> . >>>>> >>>> -- >>> 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...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> >> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/pandoc-discuss/58f80fd9-5017-4ae2-8a86-225d3fa79463n%40googlegroups.com >>> >>> . >>> >> -- > 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-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/pandoc-discuss/fd41c606-6011-4bfc-9a6e-33103faaba75n%40googlegroups.com > > . > -- 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-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhBXRLeMnxhuud-N4qx_QW7PTTdv_5CsWj0sTB%3DOeu-70Q%40mail.gmail.com.