sweet cheese & crackers

pull/139/head
Matthew Butterick 7 years ago
parent 3972173eac
commit 7171c73e3f

@ -31,7 +31,7 @@ parser.add_option('--cssclass', default="source", dest="cssclass")
lexer = "" lexer = ""
code = "" code = ""
lines-to-highlight = "" lines_to_highlight = ""
py_version = sys.version_info.major py_version = sys.version_info.major
sys.stdout.write("ready\n") sys.stdout.write("ready\n")
sys.stdout.flush() sys.stdout.flush()
@ -48,7 +48,7 @@ while 1:
formatter = HtmlFormatter(linenos=options.linenos, formatter = HtmlFormatter(linenos=options.linenos,
cssclass=options.cssclass, cssclass=options.cssclass,
encoding="utf-8", encoding="utf-8",
hl_lines=lines-to-highlight) hl_lines=lines_to_highlight)
if py_version >= 3: if py_version >= 3:
sys.stdout.write(highlight(code, lexer, formatter).decode("utf-8")) sys.stdout.write(highlight(code, lexer, formatter).decode("utf-8"))
else: else:
@ -57,17 +57,17 @@ while 1:
sys.stdout.flush() sys.stdout.flush()
lexer = "" lexer = ""
code = "" code = ""
lines-to-highlight = "" lines_to_highlight = ""
elif lexer == "": elif lexer == "":
# Starting another lex. First line is the lexer name. # Starting another lex. First line is the lexer name.
try: try:
lexer = get_lexer_by_name(line, encoding="guess") lexer = get_lexer_by_name(line, encoding="guess")
except ClassNotFound: except ClassNotFound:
lexer = get_lexer_by_name("text", encoding="guess") lexer = get_lexer_by_name("text", encoding="guess")
elif lines-to-highlight == "": elif lines_to_highlight == "":
# Starting another lex. Second line is list of lines to highlight, # Starting another lex. Second line is list of lines to highlight,
# formatted as string of whitespace-separated integers # formatted as string of whitespace-separated integers
lines-to-highlight = [int(str) for str in line.split()] lines_to_highlight = [int(str) for str in line.split()]
else: else:
# Accumulate more code # Accumulate more code
# Use `line_raw`: Do want trailing space, \n, \r # Use `line_raw`: Do want trailing space, \n, \r

@ -1 +1 @@
1488160788 1488162387

Loading…
Cancel
Save