CDSoft / pp

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

!include in pp interferes with !include in PlantUML #67

Closed holmboe closed 5 years ago

holmboe commented 5 years ago

I am trying to use the !include directive in PlantUML and it is processed by pp before it reaches PlantUML, and naturally it fails.

A Markdown file:

!uml(network-overview-diagram)(Network Overview Diagram)
~~~
!include <tupadr3/common>
!include <tupadr3/font-awesome/cloud>
FA_CLOUD([datacenter],Datacenter,frame) #White {
}
~~~

The error message is: pp: include wrong number of arguments

I thought I'd work around the issue by using !includeurl, which is a PlantUML directive, but not a pp directive, but it fails too.

CDSoft commented 5 years ago

You can tell pp not to preprocess some parts of the file with the !raw macro:

  !uml(network-overview-diagram)(Network Overview Diagram)

!raw(!)include <tupadr3/common> !raw(!)include <tupadr3/font-awesome/cloud> FA_CLOUD([datacenter],Datacenter,frame) #White { }

or:

  !uml(network-overview-diagram2)(Network Overview Diagram)

!raw

  !include <tupadr3/common>
  !include <tupadr3/font-awesome/cloud>
  FA_CLOUD([datacenter],Datacenter,frame) #White {
  }
CDSoft commented 5 years ago

You can also use macrochars to change the character used to execute macros. e.g.:

!macrochars(§)  §comment(from here, § calls pp macros)

§uml(network-overview-diagram3)(Network Overview Diagram)

!include <tupadr3/common> !include <tupadr3/font-awesome/cloud> FA_CLOUD([datacenter],Datacenter,frame) #White { }


§macrochars(!)  !comment(restore the default char)

I use this macro in pp.md to document macros without executing them.

holmboe commented 5 years ago

I was hoping for something along the lines of your second comment (with the macrochars), much appreciated that it did in fact exist. It solved my problem. :1st_place_medal:

FYI, I also tried !raw(!)include and !raw-with-block as per your first comment but couldn't get it to work in my tests, though I might very well have messed something up on my end.