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

Auto pass options to renderers by default

ricpelo opened this issue · comments

Hi! I love your tool, I use it a lot, but a have a question:

Every time I code an UML diagram, I put the same two lines in front of the diagram code:

scale 2.5
skinparam backgroundColor transparent

For instance:

!uml(images/baseobject.png {.plain width=70%})
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scale 2.5
skinparam backgroundColor transparent
yii\base\BaseObject <|-- yii\base\Component
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I always want scale to be 2.5 and the background color to be transparent. Every time I write a diagram, I need to repeat the same two lines again and again.

Is there a way to avoid this repetition?

Thanks a lot in advance!

Hi,
There are several solutions:

  1. define a macro and call it at the beginning of every scripts (this make the repeated text smaller ;-)

  2. define a new uml like macro that adds these two lines for you (not tested...)

    !def(umlconf)

    scale 2.5
    skinparam backgroundColor transparent
    

    !def(myuml)

    !ifdef(3)
    ~~~~~~
    uml(!1)($2)
    ```
    !umlconf
    $3
    ```
    ~~~~~~
    !ifndef(3)
    ~~~~~~
    uml(!1)
    ```
    !umlconf
    $2
    ```
    ~~~~~~
    

A third solution would be to add a new builtin macro !umlprefix that defines a prefix added to every uml diagrams.
It's easy to implement but must be used carefully since such side effects will affect all uml macro calls which may lead to unexpected effects.
Do you think such a macro could be useful.

Great ideas, thank you very much!