From c974b96b88dc46b440cd7862e1d2cd7da5c8b1ae Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Thu, 10 Apr 2014 10:08:51 +0200 Subject: [PATCH] Truncate lines in parser errors. The offending lines of code displayed in the error message are truncated to 80 characters. This should make reading the error messages less of a pain when dealing with very long lines of HTML/XML. --- lib/oga/xml/parser.y | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/oga/xml/parser.y b/lib/oga/xml/parser.y index 27b366d..a208799 100644 --- a/lib/oga/xml/parser.y +++ b/lib/oga/xml/parser.y @@ -204,7 +204,13 @@ end prefix = ' ' end - code << "#{prefix}#{number}: #{line.strip}\n" + line = line.strip + + if line.length > 80 + line = line[0..79] + ' (more)' + end + + code << "#{prefix}#{number}: #{line}\n" end end