CDSoft / pp

PP - Generic preprocessor (with pandoc in mind) - macros, literate programming, diagrams, scripts...

Home Page:http://cdelord.fr/pp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please make the character(s) used for block parameter fences configurable.

bpj opened this issue · comments

I would greatly appreciate a macro for setting the fence character(s) used for macro block parameters in the spirit of !macrochars.

Consider this real-life example:

!paramfencechars(+~)

!def(param_def)
++++++++++++++++++++++++++++++++++++++++++++++++
!ifndef(param_code)(`!1`)(!if(!param_code)(`!1`)(!1))

:   ````{=latex}
    \begin{minipage}{\textwidth}
    \vspace{-1\baselineskip}
    \let\toprule\relax
    \let\bottomrule\relax
    ````

    |
    |-----|---------
    |Required:|!ifeq(!2)(y)(yes)(!ifeq(!2)(n)(no)(!2))
    |Value:|!3
!ifne(!4)()
++++++++++++++++++++++++++
    |Default:|!4
++++++++++++++++++++++++++

    ````{=latex}
    \vspace{-1\baselineskip}
    \end{minipage}
    ````
++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

(The GH highlighter doesn't get the table, which kind of ruins my point but please read on!)

The reason this would be useful is that if your text editor is set up to properly highlight Pandoc Markdown syntax it will highlight everything between tilde or backtick fences as a string or some other monochrome, but if the macro parameter contains Markdown you really want it to be highlighted as Markdown. There probably are ways to work around this in editor's highlighting engines --- I have had some success convincing the vim-pandoc-syntax plugin to not treat rows of tildes as fences, but it broke in other ways: the fence had to be an even number of tildes divisible by 4 or everything becomes Strikeout! --- but I think that the most convenient way of working around it, since it wouldn't affect those not using pp and would help everyone using pp regardless of which editor they use is to make it possible to configure which characters pp sees as parameter block fences. Otherwise everything should be as usual, except that a !minparamfencechars(COUNT) macro to set the minimum number of characters seen as a fence probably would be a good idea too.

(BTW: a default value for `!paramcode) should still be set in an appropriate place. I explicitly want empty/0 rather than undefined to be the false values!)

(BTW 2: In case anyone with LaTeX savvy sees this and wonders what the minipage is for other than containing the rule relaxations it causes the longtable to be contained within the itemize definition rather than being placed according to the whole page width.)

(BTW 3: the param_ in the user macro names doesn't refer to pp macro params but to object initialization parameters and/or function arguments in the documentation of which this macro is used.)

Done in pp v 2.9. The macro macroblockargs changes the default chars for block arguments.