def main(inputFileName): outputFileName = "%s.html" % inputFileName rubyLexer = RubyLexer() rubyLexer.add_filter(RelabelNegativeCommentsFilter()) htmlPageFormatter = HtmlPageFormatter(title = inputFileName) inputFile = open(inputFileName, "r") code = inputFile.read() inputFile.close() print("pygmentizing %s into %s ..." % (inputFileName, outputFileName)) outputFile = open(outputFileName, "w") highlight(code, rubyLexer, htmlPageFormatter, outfile = outputFile) outputFile.close()
def process(inputFileName, relativeBaseDir = ""): #E the output file name is the input file name with ".html" on the end outputFileName = "%s.html" % inputFileName #E use the Ruby lexer provided by Pygments to parse Ruby input files rubyLexer = RubyLexer() rubyLexer.add_filter(RelabelExtremeCommentsFilter()) htmlPageFormatter = HtmlPageFormatter(title = inputFileName, relativeBaseDir = relativeBaseDir) inputFile = open(inputFileName, "r") code = inputFile.read() inputFile.close() print("pygmentizing %s into %s ..." % (inputFileName, outputFileName)) outputFile = open(outputFileName, "w") highlight(code, rubyLexer, htmlPageFormatter, outfile = outputFile) outputFile.close()