#NEWLINE# def _parseHeader( self ) : #NEWLINE# #INDENT# '\n        Determines language of a code block from shebang line and whether said\n        line should be removed or left in place. If the sheband line contains a\n        path (even a single /) then it is assumed to be a real shebang line and\n        left alone. However, if no path is given (e.i.: #!python or :::python)\n        then it is assumed to be a mock shebang for language identifitation of\n        a code fragment and removed from the code block prior to processing for\n        code highlighting. When a mock shebang (e.i: #!python) is found, line\n        numbering is turned on. When colons are found in place of a shebang\n        (e.i.: :::python), line numbering is left in the current state - off\n        by default.\n\n        Also parses optional list of highlight lines, like:\n\n            :::python hl_lines="1 3"\n        ' #NEWLINE# import re #NEWLINE# lines = self . src . split ( '\n' ) #NEWLINE# fl = lines . pop ( 0 ) #NEWLINE# c = re . compile ( '\n            (?:(?:^::+)|(?P<shebang>^[#]!)) # Shebang or 2 or more colons\n            (?P<path>(?:/\\w+)*[/ ])?        # Zero or 1 path\n            (?P<lang>[\\w+-]*)               # The language\n            \\s*                             # Arbitrary whitespace\n            # Optional highlight lines, single- or double-quote-delimited\n            (hl_lines=(?P<quot>"|\')(?P<hl_lines>.*?)(?P=quot))?\n            ' , re . VERBOSE ) #NEWLINE# m = c . search ( fl ) #NEWLINE# if m : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# self . lang = m . group ( 'lang' ) . lower ( ) #NEWLINE# #UNINDENT# except IndexError : #NEWLINE# #INDENT# self . lang = None #NEWLINE# #UNINDENT# if m . group ( 'path' ) : #NEWLINE# #INDENT# lines . insert ( 0 , m ) #NEWLINE# #UNINDENT# if ( ( self . linenums is None ) and m . group ( 'shebang' ) ) : #NEWLINE# #INDENT# self . linenums = True #NEWLINE# #UNINDENT# self . hl_lines = parse_hl_lines ( m . group ( 'hl_lines' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# lines . insert ( 0 , fl ) #NEWLINE# #UNINDENT# self . src = '\n' . join ( lines ) . strip ( '\n' )