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

Add "md" and "rst" output formats #20

Closed tajmone closed 7 years ago

tajmone commented 7 years ago

Currently PP supports md and rst as input formats (dialects), and html, pdf, odt, epub and mobi as output formats (formats).

I propose that md and rst should also be added to the output formats, and maybe even gfm (for GitHub markdown dialect). The reason is that often we reuse a same page (or snippet) for building html documentation as well as the repo's README (or even for the Wiki pages). CDSoft website could be an example of such usage, since it seems to share some common documents with its GitHub repos.

So it wouldn't be rare to also "convert" a document from markdown to markdown (or from ReST to ReST, or ReST to markdown). In such case, macros should be aware of the output format and behave accordingly. An example would be a macro that does nothing if the output is markdown or ReST, or that produces markdown instead of html, etc.

Other times it might have to do with importing different snippets depending on the output --- for example, blocks containing reference links definitions.

I think that gfm might be a candidate too because in PP's workflow we'd usually take advantage of pandoc flavored markdown in the source document (because of its added benefits), but the popularity of GitHub will often dictate converting the final README doc to GFM --- which offers both added features (like Task Lists) as well as lacking some features (like footnotes).

CDSoft commented 7 years ago

Well, with the current implementation, having the same identifiers for dialects and outputs won't work. In fact both dialects and outputs options activate builtin macros that do the same thing (emit or not their arguments). md/rst is a generic name for all markdown/restructuredtext variants and is used to generate markdown hyperlinks for images. For variants of md (or rst?), I prefer using pandoc (I generate README.md as well as my pp web page with pp and pandoc to get a github markdown file, see Makefile. You can define any macro on the command line. e.g. pp -DREADME ... and use them in the document \ifdef(README)(...)). Pandoc knows markdown way better than pp ;-) Maybe some specific variants could be added to output (like gfm) but md and rst, which are dialects, also work as outputs (they just define \md and \rst).

tajmone commented 7 years ago

Thanks.

md and rst, which are dialects, also work as outputs (they just define \md and \rst).

... I didn't know that, good to know.

I'll follow your advice and set some macro on the command line to indicate that output is same as input, and add the appropriate checks within the macros themselves.