Exemple #1
0
    def pre_process(self):
        if not 'language' in self.arguments:
            self.arguments['language'] = getkey(self.arguments, 'primary', u'?') 
        self.arguments['caption'] = getkey(self.arguments, 'caption', u'')
        self.arguments['linenumbers'] = getkey(self.arguments, 'linenumbers', u'no')
        self.arguments['highlight'] = getkey(self.arguments, 'highlight', '')
        self.arguments['wrap'] = getkey(self.arguments, 'wrap', 'yes')
 
        self.localvars['id'] = 'code%i' % G.getid()
        
        if not self.content:
            G.warn("Empty Code object at %s +%d! Perhaps it starts with xxxx: Then add a - separator line before content." % (self.filepath, self.lineno))
            return

        # Clean empty lines
        self.content = self.content.replace('\n \n', '\n\n')
        
        if have_pygment:
            if getkey(self.arguments, 'language', u'') == u'':
                lexer = guess_lexer(self.content)
            else:
                try:
                    lexer = get_lexer_by_name(getkey(self.arguments, 'language', 'text'))
                except ClassNotFound:
                    G.error('Cound not find class %s at %s +%d' % (getkey(self.arguments, 'language', 'text'), self.filepath, self.lineno))
                    lexer = get_lexer_by_name('text')
            G.debug(u''.join(['Lexer is ',str(lexer)]))
 
            linenumbers = True if self.arguments['linenumbers'] == 'yes' else False
            wrap = True if self.arguments['wrap'] == 'yes' else False
            highlights = self.arguments['highlight'].split(',')
            highlight_lines = []
            for hl in highlights:
                parts = hl.split('-')
                if len(parts) == 2:
                    highlight_lines += range(int(parts[0]), int(parts[1])+ 1)
                elif hl:
                    highlight_lines.append(int(hl))
 
            formatter = HtmlFormatter(
                linenos = linenumbers,
                nowrap = not wrap,
                hl_lines = highlight_lines
            )
 
            self.localvars['code'] = unicode(highlight(unicode(self.content), lexer, formatter))
        else:
            G.debug('No highlighting done')
            self.localvars['code'] = u'\n'.join(['<pre>',unicode(self.content),'</pre>'])
 
        self.script = unicode(getkey(self.globalvars, '$Templates.Code.script', u''))
        self.script = varsub(self.script, 
                           [self.localvars,
                           self.arguments,
                           self.globalvars],
                           getkey(self.globalvars, '$Templates', False),
                           recursive=getkey(self.arguments, 'substitute', 'yes') != 'no')
Exemple #2
0
    def pre_process(self):
        if not 'language' in self.arguments:
            self.arguments['language'] = getkey(self.arguments, 'primary', u'?') 
        self.arguments['caption'] = getkey(self.arguments, 'caption', u'')
        self.arguments['linenumbers'] = getkey(self.arguments, 'linenumbers', u'no')
        self.arguments['highlight'] = getkey(self.arguments, 'highlight', '')
        self.arguments['wrap'] = getkey(self.arguments, 'wrap', 'yes')
 
        self.localvars['id'] = 'code%i' % G.getid()
        
        if not self.content:
            G.warn("Empty Code object at %s +%d! Perhaps it starts with xxxx: Then add a - separator line before content." % (self.filepath, self.lineno))
            return

        # Clean empty lines
        code_result =  run(self.content)
        self.content = code_result.replace('\n \n', '\n\n')
        if have_pygment:
            if getkey(self.arguments, 'language', u'') == u'':
                lexer = guess_lexer(self.content)
            else:
                try:
                    lexer = get_lexer_by_name(getkey(self.arguments, 'language', 'text'))
                except ClassNotFound:
                    G.error('Cound not find class %s at %s +%d' % (getkey(self.arguments, 'language', 'text'), self.filepath, self.lineno))
                    lexer = get_lexer_by_name('text')
            G.debug(u''.join(['Lexer is ',str(lexer)]))
 
            linenumbers = True if self.arguments['linenumbers'] == 'yes' else False
            wrap = True if self.arguments['wrap'] == 'yes' else False
            highlights = self.arguments['highlight'].split(',')
            highlight_lines = []
            for hl in highlights:
                parts = hl.split('-')
                if len(parts) == 2:
                    highlight_lines += range(int(parts[0]), int(parts[1])+ 1)
                elif hl:
                    highlight_lines.append(int(hl))
 
            formatter = HtmlFormatter(
                linenos = linenumbers,
                nowrap = not wrap,
                hl_lines = highlight_lines
            )
            self.localvars['code'] = unicode(highlight(unicode(self.content), lexer, formatter))
        else:
            G.debug('No highlighting done')
            self.localvars['code'] = u'\n'.join(['<pre>',unicode(self.content),'</pre>'])
 
        self.script = unicode(getkey(self.globalvars, '$Templates.Exec.script', u''))
        self.script = varsub(self.script, 
                           [self.localvars,
                           self.arguments,
                           self.globalvars],
                           getkey(self.globalvars, '$Templates', False),
                           recursive=getkey(self.arguments, 'substitute', 'yes') != 'no')
Exemple #3
0
    def process(self):
        template_name = getkey(self.arguments, 'template', self.object_name)
        template = getkey(self.globalvars['$Templates'], template_name)
        self.body = unicode(getkey(template, 'body'))
        self.pre_process()

        self.body = self.body.replace('%content%', unicode(self.content))
        
        G.debug(self.globalvars['$Labels'])
        self.body = varsub(self.body, 
                           [self.localvars,
                           self.arguments,
                           self.globalvars],
                           getkey(self.globalvars, '$Templates', False),
                           recursive=getkey(self.arguments, 'substitute', 'yes') != 'no')
Exemple #4
0
    def pre_process(self):
        # Do heading and toc stuff here
        if self.arguments.has_key('level'):
            self.localvars['level'] = self.arguments['level']
        else:
            self.localvars['level'] = '2'
        G.debug(''.join(['Level set to ', self.localvars['level']]))

        if self.arguments.has_key('primary'):
            self.localvars['title'] = self.arguments['primary']
        G.debug(''.join(['Title set to ', self.localvars['title']]))

        # Store title to TOC
        if u'label' in self.arguments:
            self.localvars['safe_title'] = self.arguments[u'label']
            self.globalvars['$Labels'][self.arguments[u'label']] = {
                'id': self.localvars['safe_title'],
                'caption': getkey(self.localvars, 'title', 'title missing'),
            }
        else:
            self.localvars['safe_title'] = safe_link(
                getkey(self.localvars, 'title', 'title missing'))
        counter_tick(self.globalvars['$Counters'],
                     ''.join(['toc', str(self.localvars['level'])]))
        tocitem = {
            'safe_title':
            self.localvars['safe_title'],
            'link':
            '#%s' % self.localvars['safe_title'],
            'title':
            self.localvars['title'],
            'level':
            self.localvars['level'],
            'numbering':
            varsub(''.join(['%numbering', self.localvars['level'], '%']),
                   [self.globalvars], [])
        }
        self.localvars['numbering'] = tocitem['numbering']

        if (int(self.localvars['level']) <= int(
                getkey(self.globalvars, 'toc_depth', 3))):
            self.globalvars['$TOC'].append(tocitem)
        if (int(self.localvars['level']) <= int(
                getkey(self.globalvars, 'alt_toc_depth', 3))):
            self.globalvars['$ALTTOC'].append(tocitem)

        return True
Exemple #5
0
    def pre_process(self):
        # Do heading and toc stuff here
        if self.arguments.has_key('level'):
            self.localvars['level'] = self.arguments['level']
        else:
            self.localvars['level'] = '2'
        G.debug(''.join(['Level set to ',self.localvars['level']]))
        
        if self.arguments.has_key('primary'):
            self.localvars['title'] = self.arguments['primary']
        G.debug(''.join(['Title set to ',self.localvars['title']]))
        
        # Store title to TOC
        if u'label' in self.arguments:
            self.localvars['safe_title'] = self.arguments[u'label']
            self.globalvars['$Labels'][self.arguments[u'label']] = {
                'id':  self.localvars['safe_title'],
                'caption': getkey(self.localvars,'title','title missing'),
            }
        else:
            self.localvars['safe_title'] = safe_link(
                getkey(self.localvars,'title','title missing'))
        counter_tick(self.globalvars['$Counters'],
                     ''.join(['toc',str(self.localvars['level'])]))
        tocitem = { 'safe_title': self.localvars['safe_title'],
                    'link': '#%s' % self.localvars['safe_title'],
                    'title': self.localvars['title'],
                    'level': self.localvars['level'],
                    'numbering': varsub(
                        ''.join(['%numbering',
                                 self.localvars['level'],
                                 '%']),
                        [self.globalvars],
                        [])
                  }
        self.localvars['numbering'] = tocitem['numbering']

        if (int(self.localvars['level']) <= 
            int(getkey(self.globalvars, 'toc_depth', 3))):
            self.globalvars['$TOC'].append(tocitem)
        if (int(self.localvars['level']) <= 
            int(getkey(self.globalvars, 'alt_toc_depth', 3))):
            self.globalvars['$ALTTOC'].append(tocitem)
        

        return True
Exemple #6
0
    def pre_process(self):
        root_path = self.globalvars.get('root') or '.'
        self_filename = self.filepath.replace(root_path, '')
        exclude_string = ','.join(
            [self.arguments.get('exclude', ''), self_filename])
        exclude_files = exclude_string.split(',')
        files = self.arguments.get(u'startwith', '').split(',')

        listed_files = os.listdir(root_path)
        listed_files.sort()
        for path in listed_files:
            if not path in files:
                files.append(path)

        remarks = []
        for path in files:
            if os.path.isfile(
                    os.path.join(root_path, path)
            ) and path not in exclude_files and not path.startswith('.'):
                G.info('Reading file %s' % path)

                # Load file (locally on its own)
                p = Processor.Processor(getkey(self.globalvars, 'root'), path,
                                        'no', True, '%s.html' %
                                        path)  # make them think they are main
                #p = Processor('', filename, 'html', True, outfile)
                if p.init_file():
                    p.load_objects()
                    p.close_file()
                else:
                    G.error('Skipping file "%s"' % path)
                    continue

                # Filter out objects we need
                needed_objects = []
                comment_objects = []
                doctitle = 'no title object found'
                for obj in p.objects:
                    if obj.object_name in ('Paragraph', 'Title', 'Input',
                                           'Use', 'Template', 'Heading',
                                           'TOC'):
                        needed_objects.append(obj)
                        if obj.object_name == 'Title':
                            doctitle = obj.arguments.get(u'title', 'wtf')
                    if obj.object_name == 'Comment' or obj.content.startswith(
                            "\nTODO") or obj.content.startswith("TODO"):
                        if not obj.arguments.get('state', False):
                            if obj.object_name == 'Comment':
                                obj.arguments['state'] = 'warning'
                            else:
                                obj.arguments['state'] = 'critical'
                        comment_objects.append(obj)

                p.objects = needed_objects
                p.preprocess_objects()
                p.process_objects_for_syntax_sugar()
                p.process_object_queue()

                # Take index comment objects
                for obj in comment_objects:
                    remarks.append({
                        'filename': obj.filepath,
                        'linenumber': obj.lineno,
                        'object_type': obj.object_name,
                        'note': obj.content,
                        'state': obj.arguments.get('state'),
                    })

                # Add main TOC item
                counter_tick(self.globalvars['$Counters'],
                             ''.join(['toc', str(1)]))
                tocitem = {
                    'safe_title':
                    path,
                    'link':
                    '%s.html' % path,
                    'title':
                    p.globalvars.get('title', doctitle),
                    'level':
                    1,
                    'numbering':
                    varsub(''.join(['%indexnumbering',
                                    str(1), '%']), [self.globalvars], [])
                }
                self.globalvars['$TOC'].append(dict(tocitem))
                self.globalvars['$ALTTOC'].append(dict(tocitem))

                # Extract Headings from TOC
                toc = p.globalvars.get('$TOC', False)
                if not toc:
                    G.error('The file "%s" did not have any TOC' % path)
                    continue

                for entry in toc:
                    level = entry.get('level', False)
                    if not level:
                        G.error('level missing for some entry in file "%s"' %
                                path)
                        continue
                    level = int(level) + 1
                    safe_title = entry.get('safe_title', False)
                    if not safe_title:
                        G.error(
                            'safe_title missing for some entry in file "%s"' %
                            path)
                        continue
                    title = entry.get('title', 'untitled')
                    counter_tick(self.globalvars['$Counters'],
                                 ''.join(['toc', str(level)]))
                    numbering = varsub(
                        ''.join(['%indexnumbering',
                                 str(level), '%']), [self.globalvars], [])
                    tocitem = {
                        'safe_title': '%s-%s' % (path, safe_title),
                        'link': '%s.html#%s' % (path, safe_title),
                        'title': title,
                        'level': level,
                        'numbering': numbering,
                    }
                    if (level <= int(getkey(self.globalvars, 'toc_depth', 3))):
                        self.globalvars['$TOC'].append(dict(tocitem))

                    if (level <= int(
                            getkey(self.globalvars, 'alt_toc_depth', 7))):
                        self.globalvars['$ALTTOC'].append(dict(tocitem))

        self.globalvars['$IndexedRemarks'] = remarks
        # This object is now "obselete"
        self.removed = True
Exemple #7
0
    def pre_process(self):
        if not getkey(self.arguments, 'file'):
            self.arguments['file'] = getkey(self.arguments, 'primary', u'') 
        filename = getkey(self.arguments, 'file')
        if not getkey(self.arguments, 'mode'):
            self.arguments['mode'] = getkey(self.globalvars['$Figure'], 'mode',u'')
        if not filename:
            mode = 'inline'
        else:
            mode = 'normal'
        self.arguments['caption'] = getkey(self.arguments, 'caption', u'')
        self.localvars['title'] = getkey(self.arguments, 'caption', 'Untitled')
        self.localvars['safe_title'] = getkey(self.arguments, 
            'label', 'figure_'+safe_link(
                getkey(self.localvars,'title','untitled')))

        # Store title to TOC
        counter_tick(self.globalvars['$Counters'], 'figure')
                     
        tocitem = { 'safe_title': self.localvars['safe_title'],
                    'link': '#%s' % self.localvars['safe_title'],
                    'title': getkey(self.localvars, 'title', 'Untitled'),
                    'level': 1,
                    'section': '!!toc1!!',
                    'numbering': varsub('%numberingfigure%', [self.globalvars], [])
                  }
        self.localvars['numbering'] = tocitem['numbering']

        self.globalvars['$TOF'].append(tocitem)

        parts = filename.split('.')
        extension = parts[-1].lower()
        if self.arguments.get('format', False):
            self.localvars['format'] = self.arguments.get('format') 
        elif extension == 'png':
            self.localvars['format'] = 'image/png;base64'
        elif extension == 'jpg' or extension == 'jpeg':
            self.localvars['format'] = 'image/jpeg;base64'
        elif extension == 'gif':
            self.localvars['format'] = 'image/gif;base64'
        elif extension == 'svg':
            self.localvars['format'] = 'image/svg+xml;base64'
        else:
            G.warn('Unknown image format: '+extension)
            self.localvars['format'] = extension 

        indata = ''
        if not filename in getkey(self.globalvars,'$Base64Data',{}):
            # Caching
            # TODO This caching should be stored in css instead as well
            if mode == 'normal':
                try:
                    f = open(filename, 'r')
                    indata = f.read()
                except IOError:
                    G.error(''.join(['The image file "',filename,'" could not be opened.']))
            elif mode == 'inline':
                filename = self.localvars.get('safe_title')
                if not filename in getkey(self.globalvars,'$Base64Data',{}):
                    indata = self.content 
            if 'base64' in self.localvars.get('format'):
                data = base64.b64encode(indata)
            else:
                data = ''.join([s for s in indata.splitlines() if s])
            self.globalvars['$Base64Data'][filename] = data

        self.localvars['data'] = self.globalvars['$Base64Data'][filename]

        if not 'width' in self.arguments:
            self.localvars['width'] = self.globalvars['$Figure']['width']
Exemple #8
0
    def pre_process(self):
        root_path = self.globalvars.get('root') or '.'
        self_filename = self.filepath.replace(root_path, '')
        exclude_string = ','.join([self.arguments.get('exclude', ''), self_filename])
        exclude_files = exclude_string.split(',')
        files = self.arguments.get(u'startwith', '').split(',')

        listed_files = os.listdir(root_path)
        listed_files.sort()
        for path in listed_files:
            if not path in files:
                files.append(path)
        
        remarks = []
        for path in files:
            if os.path.isfile(os.path.join( root_path, path)) and path not in exclude_files and not path.startswith('.'):
                G.info('Reading file %s' % path)

                # Load file (locally on its own)
                p = Processor.Processor(getkey(self.globalvars,'root'), path, 'no', True, '%s.html' % path) # make them think they are main
                #p = Processor('', filename, 'html', True, outfile)
                if p.init_file():
                    p.load_objects()
                    p.close_file()
                else:
                    G.error('Skipping file "%s"' % path)
                    continue
                
                # Filter out objects we need
                needed_objects = []
                comment_objects = []
                doctitle = 'no title object found'
                for obj in p.objects:
                    if obj.object_name in ('Paragraph', 'Title', 'Input', 'Use', 'Template','Heading', 'TOC'):
                        needed_objects.append(obj)
                        if obj.object_name == 'Title':
                            doctitle = obj.arguments.get(u'title', 'wtf')
                    if obj.object_name == 'Comment' or obj.content.startswith("\nTODO") or obj.content.startswith("TODO"):
                        if not obj.arguments.get('state', False):
                            if obj.object_name == 'Comment':
                                obj.arguments['state'] = 'warning'
                            else:
                                obj.arguments['state'] = 'critical'
                        comment_objects.append(obj)

                p.objects = needed_objects
                p.preprocess_objects()
                p.process_objects_for_syntax_sugar()
                p.process_object_queue()

                # Take index comment objects
                for obj in comment_objects:
                    remarks.append({
                        'filename': obj.filepath,
                        'linenumber': obj.lineno,
                        'object_type': obj.object_name,
                        'note': obj.content,
                        'state': obj.arguments.get('state'),
                    })

                # Add main TOC item
                counter_tick(self.globalvars['$Counters'],
                             ''.join(['toc',str(1)]))
                tocitem = { 'safe_title': path,
                            'link': '%s.html' % path,
                            'title': p.globalvars.get('title', doctitle),
                            'level': 1,
                            'numbering': varsub(
                                ''.join(['%indexnumbering',
                                         str(1),
                                         '%']),
                                [self.globalvars],
                                [])
                          }
                self.globalvars['$TOC'].append(dict(tocitem))
                self.globalvars['$ALTTOC'].append(dict(tocitem))

                # Extract Headings from TOC
                toc = p.globalvars.get('$TOC', False)
                if not toc:
                    G.error('The file "%s" did not have any TOC' % path)
                    continue

                for entry in toc:
                    level = entry.get('level', False)
                    if not level:
                        G.error('level missing for some entry in file "%s"' % path)
                        continue
                    level = int(level) + 1
                    safe_title = entry.get('safe_title', False)
                    if not safe_title:
                        G.error('safe_title missing for some entry in file "%s"' % path)
                        continue
                    title = entry.get('title', 'untitled')
                    counter_tick(self.globalvars['$Counters'],
                             ''.join(['toc',str(level)]))
                    numbering = varsub(
                        ''.join(['%indexnumbering', str(level), '%']), 
                        [self.globalvars], [])
                    tocitem = { 'safe_title': '%s-%s' % (path, safe_title),
                                'link':  '%s.html#%s' % (path, safe_title),
                                'title': title,
                                'level': level,
                                'numbering': numbering,
                              }
                    if (level <= 
                        int(getkey(self.globalvars, 'toc_depth', 3))):
                        self.globalvars['$TOC'].append(dict(tocitem))

                    if (level <= 
                        int(getkey(self.globalvars, 'alt_toc_depth', 7))):
                        self.globalvars['$ALTTOC'].append(dict(tocitem))
        
        self.globalvars['$IndexedRemarks'] = remarks
        # This object is now "obselete"
        self.removed = True
Exemple #9
0
    def pre_process(self):
        if not getkey(self.arguments, 'file'):
            self.arguments['file'] = getkey(self.arguments, 'primary', u'')
        filename = getkey(self.arguments, 'file')
        if not getkey(self.arguments, 'mode'):
            self.arguments['mode'] = getkey(self.globalvars['$Figure'], 'mode',
                                            u'')
        if not filename:
            mode = 'inline'
        else:
            mode = 'normal'
        self.arguments['caption'] = getkey(self.arguments, 'caption', u'')
        self.localvars['title'] = getkey(self.arguments, 'caption', 'Untitled')
        self.localvars['safe_title'] = getkey(
            self.arguments, 'label',
            'figure_' + safe_link(getkey(self.localvars, 'title', 'untitled')))

        # Store title to TOC
        counter_tick(self.globalvars['$Counters'], 'figure')

        tocitem = {
            'safe_title': self.localvars['safe_title'],
            'link': '#%s' % self.localvars['safe_title'],
            'title': getkey(self.localvars, 'title', 'Untitled'),
            'level': 1,
            'section': '!!toc1!!',
            'numbering': varsub('%numberingfigure%', [self.globalvars], [])
        }
        self.localvars['numbering'] = tocitem['numbering']

        self.globalvars['$TOF'].append(tocitem)

        parts = filename.split('.')
        extension = parts[-1].lower()
        if self.arguments.get('format', False):
            self.localvars['format'] = self.arguments.get('format')
        elif extension == 'png':
            self.localvars['format'] = 'image/png;base64'
        elif extension == 'jpg' or extension == 'jpeg':
            self.localvars['format'] = 'image/jpeg;base64'
        elif extension == 'gif':
            self.localvars['format'] = 'image/gif;base64'
        elif extension == 'svg':
            self.localvars['format'] = 'image/svg+xml;base64'
        else:
            G.warn('Unknown image format: ' + extension)
            self.localvars['format'] = extension

        indata = ''
        if not filename in getkey(self.globalvars, '$Base64Data', {}):
            # Caching
            # TODO This caching should be stored in css instead as well
            if mode == 'normal':
                try:
                    f = open(filename, 'r')
                    indata = f.read()
                except IOError:
                    G.error(''.join([
                        'The image file "', filename, '" could not be opened.'
                    ]))
            elif mode == 'inline':
                filename = self.localvars.get('safe_title')
                if not filename in getkey(self.globalvars, '$Base64Data', {}):
                    indata = self.content
            if 'base64' in self.localvars.get('format'):
                data = base64.b64encode(indata)
            else:
                data = ''.join([s for s in indata.splitlines() if s])
            self.globalvars['$Base64Data'][filename] = data

        self.localvars['data'] = self.globalvars['$Base64Data'][filename]

        if not 'width' in self.arguments:
            self.localvars['width'] = self.globalvars['$Figure']['width']
Exemple #10
0
    def pre_process(self):
        self.needs_rerun = not self.needs_rerun 

        self.arguments['caption'] = getkey(self.arguments, 'caption', u'')
        self.localvars['title'] = getkey(self.arguments, 'caption', 'Untitled')

        if not getkey(self.arguments, 'file'):
            self.arguments['file'] = getkey(self.arguments, 'primary', u'') 
        filename = getkey(self.arguments, 'file')
        if not getkey(self.arguments, 'mode'):
            self.arguments['mode'] = getkey(self.globalvars.get('$Table', {}), 'mode',u'')
        mode = self.arguments['mode']
        self.localvars['headers'] = self.arguments.get('headers', False) or self.globalvars.get('$Table', {}).get('headers', 'yes')

        # Store title to TOT (Table of Tables)
        self.localvars['safe_title'] = 'table_'+safe_link(
                getkey(self.localvars,'title','untitled'))
        counter_tick(self.globalvars['$Counters'], 'table')
                     
        tocitem = { 'safe_title': self.localvars['safe_title'],
                    'link': '#%s' % self.localvars['safe_title'],
                    'title': getkey(self.localvars, 'title', 'Untitled'),
                    'level': 1,
                    'section': '!!toc1!!',
                    'numbering': varsub('%numberingtable%', [self.globalvars], [])
                  }
        self.localvars['numbering'] = tocitem['numbering']

        self.globalvars['$TOT'].append(tocitem)

        data = ''
        # Caching
        # TODO This caching should be stored in css instead as well
        if mode == 'normal':
            try:
                f = open(filename, 'r')
                data = f.read()
            except IOError:
                G.error(''.join(['The image file "',filename,'" could not be opened.']))
        elif mode == 'inline':
            data = self.content 

        if not 'width' in self.arguments and 'width' in self.globalvars.get('$Table', []):
            self.localvars['width'] = self.globalvars.get('$Table', []).get('width')

        splitter = re.compile("[ ]{2,}")
        rows = []
        for (nr, line) in enumerate(data.splitlines()):
            if nr == 0:
                pass
            elif nr == 1 and self.localvars.get('headers', False) in ('1', 'yes'):
                headers = []
                for header in splitter.split(line):
                    headers.append({'text': header})
                self.localvars['$Headers'] = headers
            else:
                cells = []
                for cell in splitter.split(line):
                    cells.append({'text': cell})
                rows.append({'$Cells': cells})
        self.localvars['$Rows'] = rows