Search code examples
markdownpandocm4

GNU m4 adds empty lines at top


I am using GNU m4 to preprocess Pandoc Markdown. I have a m4 script that defines a macro to set text in smallcaps named gb_Attr.

m4_changequote({{,}})
m4_define({{gb_Attr}}, {{[$1]{.smallcaps}}})

and an input Markdown file

# Title

Lorem impsum

## Chapter 1

My attribute in gb_Attr(Smallcaps)

I call it like the following:

$ m4 -P script.m4 input.md 

The macro is expanded correctly but the output begins with two empty lines. How can I prevent those lines?


Solution

  • Use m4_dnl (Discard to Next Line) at end of lines!

    m4_changequote({{,}})m4_dnl
    m4_define({{gb_Attr}}, {{[$1]{.smallcaps}}})m4_dnl