IRC xchat log support

Issue #340 resolved
Anonymous created an issue

The default timestamp format xchat log files seems to be {{{%b %d %H:%M:%S}}} (it's a setting, but I'm pretty sure I didn't change the setting), resulting in lines like this:

{{{ Jun 18 12:59:57 <nick> Message }}}

This requires a small tweak to pygments.lexers.text.IrcLogsLexer.timestamp (though the current comment I notice seems to indicate xchat support).

Adding this made it work for me:

{{{ | # xchat \w{3}\s\d{2}\s # Date \d{2}:\d{2}:\d{2}\s+ # Time + Whitespace }}}

though maybe just loosening the first group would be enough, specifically this:

{{{ (?: (?:\d{1,4} [-/]?)+ # Date as - or /-separated groups of digits }}}

{{{\d?\d:\d\d:\d\d}}} seems like a pretty unique marker that indicates a time, and everything before it is a date (in some format).

Reported by guest

Comments (5)

  1. thatch

    Yeah, it doesn't quite support the default xchat logging format, and this patch fixes the timestamp issue. I also see the following mishandled, and will work on a more generic patch that doesn't require such strict matching on lines (i.e. if a timestamp is found, go ahead and highlight it then see if we need to punt on the remainder of the line):

    **** BEGIN LOGGING AT Fri Jul 25 21:53:38 2008
    Jul 25 21:53:38 -ChanServ-	[#trac] Welcome to #trac.
  2. Log in to comment