CDSoft / pp

PP - Generic preprocessor (with pandoc in mind) - macros, literate programming, diagrams, scripts...
http://cdelord.fr/pp
GNU General Public License v3.0
252 stars 21 forks source link

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

Closed bpj closed 5 years ago

bpj commented 5 years ago

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.)
CDSoft commented 5 years ago

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

bpj commented 5 years ago

You are a hero!

Den sön 7 juli 2019 07:45CDSoft <

skrev:

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/CDSoft/pp/issues/80?email_source=notifications&email_token=AAI3OUZE625QUQCMZCVSIDDP6F7GZA5CNFSM4H5FAKOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZLFBBI#issuecomment-508973189, or mute the thread https://github.com/notifications/unsubscribe-auth/AAI3OU4D2ELY6TDVGVU2HO3P6F7GZANCNFSM4H5FAKOA .