I'm using a combination of markdown and m4 to produce three different versions of a document depending on the flags given at the beginning. Let's call them Gold, Silver, and Bronze.
The problem that I've come across is that if I have a section that appears within an ifdef statement that has commas, m4 considers the rest of the section to be false.
ifdef(`GOLDANDSILVER',dnl
## Here's a subsection header
### Subsubsection about this, that, and the other thing
Aren't examples fun? Here's some punctuation, failure, and misfortune.
)dnl
Interestingly, it does not fail on the subsubsection, but fails in the body text.
My current, ugly, solution is to use a 'dummy comma' that can be piped to, and replaced by, sed.
ifdef(`GOLDANDSILVER',dnl
## Here's a subsection header
### Subsubsection about thisREPLACE_ME_COMMA thatREPLACE_ME_COMMA and the other thing
Aren't examples fun? Here's some punctuationREPLACE_ME_COMMA failureREPLACE_ME_COMMA and misfortune.
)dnl
I'm looking for a cleaner, preferably m4-only, solution that allows me to have "," in the body of my ifdef statements.
What I've learned by trial and error:
- m4 seems to ignore any content or definitions on lines prefixed with #
- [,] does not escape a comma
- [[,]] does not escape a comma