Back to index

moin  1.9.0~rc2
Public Member Functions | Static Public Attributes
MoinMoin.support.pygments.lexers.functional.LiterateHaskellLexer Class Reference
Inheritance diagram for MoinMoin.support.pygments.lexers.functional.LiterateHaskellLexer:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.support.pygments.lexers.functional.LiterateHaskellLexer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def get_tokens_unprocessed

Static Public Attributes

string name = 'Literate Haskell'
list aliases = ['lhs', 'literate-haskell']
list filenames = ['*.lhs']
list mimetypes = ['text/x-literate-haskell']

Detailed Description

For Literate Haskell (Bird-style or LaTeX) source.

Additional options accepted:

`litstyle`
    If given, must be ``"bird"`` or ``"latex"``.  If not given, the style
    is autodetected: if the first non-whitespace character in the source
    is a backslash or percent character, LaTeX is assumed, else Bird.

*New in Pygments 0.9.*

Definition at line 454 of file functional.py.


Member Function Documentation

Definition at line 472 of file functional.py.

00472 
00473     def get_tokens_unprocessed(self, text):
00474         hslexer = HaskellLexer(**self.options)
00475 
00476         style = self.options.get('litstyle')
00477         if style is None:
00478             style = (text.lstrip()[0] in '%\\') and 'latex' or 'bird'
00479 
00480         code = ''
00481         insertions = []
00482         if style == 'bird':
00483             # bird-style
00484             for match in line_re.finditer(text):
00485                 line = match.group()
00486                 m = bird_re.match(line)
00487                 if m:
00488                     insertions.append((len(code),
00489                                        [(0, Comment.Special, m.group(1))]))
00490                     code += m.group(2)
00491                 else:
00492                     insertions.append((len(code), [(0, Text, line)]))
00493         else:
00494             # latex-style
00495             from pygments.lexers.text import TexLexer
00496             lxlexer = TexLexer(**self.options)
00497 
00498             codelines = 0
00499             latex = ''
00500             for match in line_re.finditer(text):
00501                 line = match.group()
00502                 if codelines:
00503                     if line.lstrip().startswith('\\end{code}'):
00504                         codelines = 0
00505                         latex += line
00506                     else:
00507                         code += line
00508                 elif line.lstrip().startswith('\\begin{code}'):
00509                     codelines = 1
00510                     latex += line
00511                     insertions.append((len(code),
00512                                        list(lxlexer.get_tokens_unprocessed(latex))))
00513                     latex = ''
00514                 else:
00515                     latex += line
00516             insertions.append((len(code),
00517                                list(lxlexer.get_tokens_unprocessed(latex))))
00518         for item in do_insertions(insertions, hslexer.get_tokens_unprocessed(code)):
00519             yield item
00520 

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 468 of file functional.py.

Definition at line 469 of file functional.py.

Definition at line 470 of file functional.py.

Definition at line 467 of file functional.py.


The documentation for this class was generated from the following file: