Class: TexLogParser::StandardError

Inherits:
Object
  • Object
show all
Includes:
LogParser::RegExpPattern
Defined in:
lib/tex_log_parser/patterns/standard_error.rb

Overview

Matches messages of this form:

! File ended while scanning use of \@footnotetext.
<inserted text>
                \par
<*> plain.tex

and

! Font TU/NoSuchFont(0)/m/n/9=NoSuchFont at 9.0pt not loadable: Metric (TFM) fi
le or installed font not found.
<to be read again>
                 relax
l.40 \end{document}

Instance Method Summary collapse

Methods included from LogParser::RegExpPattern

#begins_at?

Methods included from LogParser::Pattern

#begins_at?

Constructor Details

#initializeStandardError

Creates a new instance.

[View source]

22
23
24
25
26
# File 'lib/tex_log_parser/patterns/standard_error.rb', line 22

def initialize
  super(/^! \w+/,
        { pattern: ->(_) { /^\s*<\*>\s+([^\s]+)|^l\.(\d+)\s+/ }, until: :match, inclusive: true }
  )
end

Instance Method Details

#read(lines) ⇒ Array<(Message, Int)>

Reads a message from the given lines.

Parameters:

Returns:

  • (Array<(Message, Int)>)

    An array of the message that was read, and the number of lines that it spans.

Raises:

  • If no message end could be found among the given lines.

[View source]

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/tex_log_parser/patterns/standard_error.rb', line 29

def read(lines)
  # @type [Message] msg
  msg, consumed = super(lines)

  msg.level = :error
  # Remove last line
  msg.message.gsub!(@ending[:pattern][nil], '')
  # Remove `! ` prefix
  msg.message.sub!(/^!\s*/, '')
  # Remove trailing whitespace
  msg.message.rstrip!

  file = @end_match[1]
  line = @end_match[2].to_i

  msg.source_file = file unless file.nil?
  msg.source_lines = { from: line, to: line } unless line.nil? || line.zero?
  msg.preformatted = true

  [msg, consumed]
end