in lib/pygments/popen.rb [270:313]
def handle_header_and_return(header, id)
if header
header = header_to_json(header)
bytes = header["bytes"]
res = @out.read(bytes.to_i)
if header["method"] == "highlight"
if res.nil?
@log.warn "[#{Time.now.iso8601}] No highlight result back from mentos."
stop "No highlight result back from mentos."
raise MentosError, "No highlight result back from mentos."
end
res = res[0..-2]
@log.info "[#{Time.now.iso8601}] Highlight in process."
start_id = res[0..7]
end_id = res[-8..-1]
if not (start_id == id and end_id == id)
@log.error "[#{Time.now.iso8601}] ID's did not match. Aborting."
stop "ID's did not match. Aborting."
raise MentosError, "ID's did not match. Aborting."
else
res = res[10..-11]
@log.info "[#{Time.now.iso8601}] Highlighting complete."
res
end
end
res
else
@log.error "[#{Time.now.iso8601}] No header data back."
stop "No header data back."
raise MentosError, "No header received back."
end
end