Skip to content

Instantly share code, notes, and snippets.

@tgpfeiffer
Created April 2, 2017 09:41
Show Gist options
  • Save tgpfeiffer/b41e38afab21e2f2463e79066decd74a to your computer and use it in GitHub Desktop.
Save tgpfeiffer/b41e38afab21e2f2463e79066decd74a to your computer and use it in GitHub Desktop.
Convert a Docbook-structured Scaml file to single-page/multi-page HTML Raw
// convert the HAML/SCAML layout file to Docbook XML
val engine = new org.fusesource.scalate.TemplateEngine
val output = engine.layout("src/main/docbook/handbook.scaml")
val file = (target in Compile).value / "handbook.xml"
IO.write(file, output)
// create Docbook HTML
import scala.sys.process._
// TODO make this independent of local user's environment
val xsltool = "xsltproc"
val dbPath = "/usr/share/xml/docbook/stylesheet/nwalsh5/1.79.0/html"
val dbOptions = "--stringparam" :: "section.autolabel" :: "1" ::
"--stringparam" :: "section.label.includes.component.label" :: "1" ::
"--stringparam" :: "chunker.output.encoding" :: "UTF-8" ::
Nil
val singlePageCmd: List[String] = xsltool :: dbOptions ++
List("-o", "handbook/index.html",
s"$dbPath/onechunk.xsl", file.toString)
singlePageCmd.!
val multiPageCmd: List[String] = xsltool :: dbOptions ++
List("-o", "handbook-pages/",
s"$dbPath/chunk.xsl", file.toString)
multiPageCmd.!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment