class TexLogParser::HighlightedMessages
Matches messages as produces by LaTeX 3, i.e. those of these forms:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ./plain.tex:5: fontspec error: "font-not-found" ! ! The font "NoSuchFont" cannot be found. ! ! See the fontspec documentation for further information. ! ! For immediate help type H <return>. !............................................... l.5 \setmainfont{NoSuchFont}
and
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ! fontspec error: "font-not-found" ! ! The font "NoSuchFont" cannot be found. ! ! See the fontspec documentation for further information. ! ! For immediate help type H <return>. !............................................... l.5 \setmainfont{NoSuchFont}
and
................................................. . LaTeX info: "xparse/define-command" . . Defining command \fontspec with sig. 'O{}mO{}' on line 472. .................................................
and
************************************************* * widows-and-orphans warning: "orphan-widow" * * Orphan on page 1 (second column) and widow on page 2 (first column) *************************************************
Public Class Methods
new()
click to toggle source
Creates a new instance.
Calls superclass method
LogParser::RegExpPattern::new
# File lib/tex_log_parser/patterns/highlighted_messages.rb, line 53 def initialize super(/^(!{3,}|\.{3,}|\*{3,})$/, { pattern: lambda { |m| case m[1][0] when '!' /^l\.(\d+)/ when '*' /^\*{3,}\s*$/ when '.' /^\.{3,}\s*$/ else raise("Expected one of `[!.*]` but found: #{m[1][0]}") end }, until: :match, inclusive: true }) end
Public Instance Methods
read(lines)
click to toggle source
(see LogParser::RegExpPattern#read
)
Calls superclass method
LogParser::RegExpPattern#read
# File lib/tex_log_parser/patterns/highlighted_messages.rb, line 72 def read(lines) # @type [Message] msg msg, consumed = super(lines) is_error = @start_match[1][0] == '!' if is_error file_line_match = %r{^(/?(?:.*?/)*[^/]+):(\d+):\s*}.match(msg.message) line = nil if !file_line_match.nil? # if file-line active msg.source_file = file_line_match[1] line = file_line_match[2].to_i msg.message.gsub!(file_line_match[0], '') elsif !@end_match[1].nil? # No file-line format, so use line number from end match line = @end_match[1].to_i end msg.source_lines = { from: line, to: line } unless line.nil? msg.level = :error msg.message.gsub!(/^.*?For immediate help type.*$/, '') msg.message.gsub!(/^!\.+\s*$/, '') msg.message.gsub!(/^l\.\d+\s+.*$/, '') else # BROKEN_BY_LINEBREAKS # TODO: may be split across lines --> remove whitespace before extracting line_match = /on line\s+(\d+)\.$/.match(msg.message) unless line_match.nil? line = line_match[1].to_i msg.source_lines = { from: line, to: line } end msg.level = @start_match[1][0] == '*' ? :warning : :info msg.message.gsub!(@end_match[0], '') end msg.preformatted = true msg.message.sub!(@start, '') msg.message.gsub!(/^#{Regexp.escape(@start_match[1][0])}\s+/, '') msg.message.strip! [msg, consumed] end