
%.xml: %.cml
	# Protect HTML special chars in R code chunks
	Rscript -e 't <- readLines("$*.cml"); writeLines(gsub("<rcode([^>]*)>", "<rcode\\1><![CDATA[", gsub("</rcode>", "]]></rcode>", t)), "$*.xml")'

%.Rhtml : %.xml
	# Transform to .Rhtml
	xsltproc knitr.xsl $*.xml > $*.Rhtml

%.html : %.Rhtml
	# Use knitr to produce HTML
	Rscript -e 'library(knitr); knit("$<")'

web:
	make butterfly.xml
	make butterfly.Rhtml
	cp butterfly.html ~/Web/Reports/grImport/butterfly/
	cp *.svg ~/Web/Reports/grImport/butterfly/
	cp butterfly.ps ~/Web/Reports/grImport/butterfly/
	cp butterfly.png ~/Web/Reports/grImport/butterfly/
	cp butterfly-image.xml ~/Web/Reports/grImport/butterfly/
	cp butterfly.svg ~/Web/Reports/grImport/butterfly/
	cp butterfly.cml ~/Web/Reports/grImport/butterfly/
	cp butterfly.xml ~/Web/Reports/grImport/butterfly/
	cp butterfly.Rhtml ~/Web/Reports/grImport/butterfly/
	cp Makefile ~/Web/Reports/grImport/butterfly/
	cp knitr.xsl ~/Web/Reports/grImport/butterfly/
	cp common.xsl ~/Web/Reports/grImport/butterfly/

