Example #1
0
def createHtmlFile(fileBase) :
	print fileBase + ":"
	
	inputPath = os.path.join(inputDir, "%s.docbook" % fileBase)
	xhtmlOutputPath = os.path.join(outputDir, "%s.xhtml" % fileBase)
	htmlOutputPath = os.path.join(outputDir, "%s.html" % fileBase)
	
	docbookDocument = dom.parse(inputPath)
	htmlDocument = createHtmlDocument(docbookDocument)
	
	#note: Python's DOM implementation refuses to output a DTD
	#note: Python's DOM implementation only outputs an @xmlns when the attribute is explicitly added
	lib.writeXmlDocument(htmlDocument, xhtmlOutputPath)

	#create HTML document from XHTML document
	#xxx tidy refuses to output HTML
	#note: wrapping will wrap text in <code> elements, so it's disabled
	#note: tidy adds newlines to <code> elements, which show up as gaps
	subprocess.call([
		"tidy",
		"--quiet", "yes",
		"--output-file", htmlOutputPath,
		"--char-encoding", "utf8",
		"--input-xml", "yes",
		"--output-html", "yes",
		"--doctype", "strict",
		"--indent", "auto",
		"--indent-spaces", "4",
		"--wrap", "0",
		xhtmlOutputPath ])

	print "done\n"
def main() :
	for fileBase in fileBases :
		inputPath = os.path.join(inputDir, "%s.docbook" % fileBase)
		outputPath = os.path.join(outputDir, "%s.docbook" % fileBase)
		docbookDocument = parseValidateDocbook(inputPath)
		processDocbook(docbookDocument)
		lib.writeXmlDocument(docbookDocument, outputPath)