Exemplo n.º 1
0
def main():
    """
    Produce output and print to pager.
    """
    dummy = TextGen()
    print('')  # pylint: disable=C0325
    text_str = ''
    for _ in range(PARAS):
        pgraph = Paragraph(dummy.chunk(), int(Cli.width() * 0.6), True)
        pgraph.set_lmargin(Cli.width() // 5)
        text_str += str(pgraph)
    if PAGER is True:
        Cli.less(text_str)
    else:
        print(text_str)  # pylint: disable=C0325
Exemplo n.º 2
0
 def make_title(self):
     """
     Print a nice title page.
     """
     if self.title:
         s = ''
         s += ('\n' * (Cli.height() / 2 - 2))
         s += (('__' + self.title + '__').replace(' ', '_').center(
             Cli.width()))
         if self.author:
             s += '\n\n' + 'by'.center(
             Cli.width()) + '\n\n' + self.author.center(Cli.width())
         s += ('\n' * (Cli.height() / 2 - 2))
         s += ('-' * Cli.width())
         if self.section_no == 0:
             s += ('\n' * 4)
         return s
     else: return '[No title]'
Exemplo n.º 3
0
 def _initialize_fields():
     self.margin = margin
     self.width = Cli.width() - margin * 2
     self.tabpoints = margin, self.width
     self.author = None
     self.title = None
     self.date = ''
     self.buffer = ''
     self.lines = []
     self.pgraph_no = 0
     self.section_no = 0
     self.p_list = []
     self.s_list = []
Exemplo n.º 4
0
    def scan_lines(self):
        """
        Scan each line in 'lines'
        """
        #print "begin scan_lines()"
        for line in self.lines:
           #print 'begin loop: "{}"'.format(line)

	   #if line not empty
            if line != '' and line != '\n':
               #get title
                if line.find('\\title') >= 0:
                    self.title = line[(line.find('{') + 1):(line.find('}'))]

                elif line.find('\\author') >= 0:
                    self.author = line[(line.find('{') + 1):(line.find('}'))]

               # If '\section' tag is detected, create a new section and add an
#entry to the table of contents.
                elif line.find(r'\section') >= 0:
                    self.parse_section_tag(line)

                elif line.find(r'\hrule') >= 0:
                    self.buffer = '-' * Cli.width()
                    self.store_paragraph(True)

               # If the current line is  not empty, append it to the buffer.
                else:
                    if len(self.s_list) == 0 and len(line) != 0:
                        Section.count = -1
                        self.open_new_section() # Introduction")
		       #print "section=0"

                    self.buffer += (line + ' ')

           # If it's a blank line, we store the Paragraph and prepare to read in
#a  new one.
           #    strip_unknown_tags()
            else: self.store_paragraph(False)
Exemplo n.º 5
0
    def print_toc(self):
        """
        Create a table of contents and print to the screen.
        """
        s = ""
        any_visible = False
        for x in range(len(self.s_list)):
            if self.s_list[x].heading[0].isdigit()\
                and self.s_list[x].heading[0] != '0':
                any_visible = True
        if any_visible == True:
            s += ''
            s += "CONTENTS".center(Cli.width())
            s += ''

            for section in self.s_list:
                if section.heading[0].isdigit() and section.heading[0] != '0':
                    s += section.heading.center(Cli.width())
                s += '\n'
            s += ((('-' * (Cli.width() / 2)).center(Cli.width()) + '\n') * 1)
            s += ('\n')
            s += ((('-' * (Cli.width() / 2)).center(Cli.width()) + '\n') * 1)
            s += ('\n')
        return s