Example #1
0
    def createLatex(self, parent, token, page):

        args = [
            latex.Brace(string=u'\\textwidth', escape=False),
            latex.Brace(string=u"".join([f[0].upper() for f in token['form']]))
        ]
        return latex.Environment(parent, 'tabulary', start='\\par', args=args)
Example #2
0
    def createLatex(self, token, parent):
        cmd = latex.CustomCommand(parent, 'href')
        node = self.getShortcut(token)

        latex.Brace(cmd, string=node.link)
        latex.Brace(cmd, string=node.string)
        return cmd
Example #3
0
    def createLatex(self, parent, token, page):

        env = latex.Environment(parent, 'tabulary',
                                args=[latex.Brace(None, string=u'\\linewidth', escape=False),
                                      latex.Brace(None, string=u'LL')])

        for key, value in self.extension.getAcronyms(True).iteritems():
            latex.String(env, content=u'{}&{}\\\\'.format(key, value), escape=False)
Example #4
0
    def addNewCommand(self, cmd, content):
        """
        Add a NewDocumentCommand to latex preamble.
        """
        num = 0
        for match in re.finditer(r'#(?P<num>[0-9]+)', content):
            num = max(num, int(match.group('num')))

        args = [latex.Brace(string=cmd, escape=False), latex.Brace(string='m'*num)]
        self._commands[cmd] = latex.Command(None, 'NewDocumentCommand', args=args, escape=False,
                                            string=content, start='\n')
Example #5
0
 def createLatex(self, parent, token, page):
     label = token['label']
     if not token['satisfied']:
         brace = latex.Brace()
         latex.Command(brace, 'textcolor',
                       args=[latex.Brace(string='red')],
                       string=label)
         args = [brace]
     else:
         args = [latex.Brace(string=label)]
     return latex.Environment(parent, 'Requirement', args=args)
Example #6
0
    def createLatex(self, parent, token, page):

        if token['icon'] and (token['brand'] == 'construction'):
            src = 'media/framework/under-construction.png'
            wrapfig = latex.Environment(parent, 'wrapfigure',
                                        args=[latex.Brace(string='l'),
                                              latex.Brace(string='1in', escape=False)])
            latex.Command(wrapfig, 'includegraphics',
                          args=[latex.Bracket(string='height=0.6in', escape=False)],
                          string=src)
        return parent
Example #7
0
 def createLatex(self, token, parent):
     cmd = latex.CustomCommand(parent, 'href')
     node = self.getShortcut(token)
     if node.content is not None:
         latex.Brace(cmd, string=node.content)
     elif node.token:
         for n in node.token.children:
             self.translator.renderer.process(n, cmd)
     else:
         latex.Brace(cmd, string=node.link)
     latex.Brace(cmd, string=unicode(token.key))
     return cmd
Example #8
0
    def createLatex(self, parent, token, page):

        latex.Command(parent, 'newline', start='\n', end='\n')
        latex.String(parent, content='Issue(s):~', escape=False)
        no_seperator = True

        for issue in token['issues']:
            if not no_seperator:
                latex.String(parent, content='; ')
                no_seperator = False

            url = self.getURL(issue, token)
            if url is None:
                latex.Command(parent, 'textcolor', args=[latex.Brace(string='red')], string=issue)
            else:
                latex.Command(parent, 'href', args=[latex.Brace(string=url)], string=unicode(issue))
Example #9
0
    def createLatex(self, parent, token, page):

        # Argument list (see ALERT above)
        args = []
        if token(0)['prefix']:
            args.append(latex.Bracket(string=token['brand']))
        else:
            args.append(latex.Bracket())

        args.append(latex.Brace(string=token['brand']))

        if token(0).children:
            title = latex.Bracket()
            self.renderer.render(title, token(0), page)
            args.append(title)

        c_icon = token(1)['icon'] and (token['brand'] == 'construction')
        if c_icon:
            latex.Command(parent,
                          'tcbset',
                          string=u'height from=1in to 200in',
                          escape=False)

        env = latex.Environment(parent, 'alert', args=args)

        if c_icon:
            latex.Command(parent,
                          'tcbset',
                          string=u'height from=0in to 200in',
                          escape=False)

        token(0).parent = None
        return env
Example #10
0
    def createLatex(self, parent, token, page):

        groups = self._getParameters(token, token['parameters'])
        for group, params in groups.iteritems():
            if not params:
                continue

            for name, param in params.iteritems():
                if param['deprecated']:
                    continue

                args = [
                    latex.Brace(string=name),
                    latex.Bracket(string=group),
                    latex.Bracket()
                ]
                latex.Command(args[2], 'texttt', string=param['cpp_type'])
                default = _format_default(param) or ''
                if default:
                    args.append(latex.Bracket(string=default))

                latex.Environment(parent,
                                  'InputParameter',
                                  args=args,
                                  string=param['description'])
Example #11
0
    def createLatex(self, parent, token, page):

        ctoken = token(1)
        opts = get_listing_options(ctoken)

        cap = token(0)
        key = cap['key']
        if key:
            latex.String(opts[0], content="label={},".format(key))

        tok = tokens.Token()
        cap.copyToToken(tok)
        if key:
            latex.String(opts[0], content="caption=")
        else:
            latex.String(opts[0], content="title=")

        if not cap.children:
            latex.String(opts[0], content="\\mbox{}", escape=False)
        else:
            self.translator.renderer.render(latex.Brace(opts[0]), tok, page)

        latex.Environment(parent,
                          'lstlisting',
                          string=ctoken['content'].strip('\n'),
                          escape=False,
                          after_begin='\n',
                          before_end='\n',
                          args=opts,
                          info=token.info)

        token.children = list()
        return parent
Example #12
0
    def createLatex(self, parent, token, page):

        headings = self.extension.binContent(page, token['location'],
                                             ContentExtension.LETTER)
        latex.Command(parent, 'par', start='\n')
        for items in headings.values():
            for text, path, label in sorted(items, key=lambda x: x[2]):
                args = [
                    latex.Brace(string=path, escape=False),
                    latex.Brace(string=label, escape=False)
                ]
                latex.Command(parent,
                              'ContentItem',
                              start='\n',
                              args=args,
                              string=text)
            latex.Command(parent, 'par', start='\n')
Example #13
0
    def createLatex(self, parent, token, page):
        prev = token.previous
        if prev and prev.name != 'SQARequirementDetails':
            latex.Command(parent, 'newline', start='\n', end='\n')
        latex.String(parent, content='Issue(s):~', escape=False)
        no_seperator = True

        for issue in token['issues']:
            if not no_seperator:
                latex.String(parent, content='; ')
                no_seperator = False

            url = self.getURL(issue, token)
            if url is None:
                latex.Command(parent, 'textcolor', args=[latex.Brace(string='red')], string=issue)
            else:
                latex.Command(parent, 'href', args=[latex.Brace(string=url)], string=str(issue))
Example #14
0
    def testCustomCommand(self):
        cmd = latex.CustomCommand(None, 'foo')
        self.assertEqual(cmd.write(), '\\foo')

        latex.Bracket(cmd, string=u'bar')
        latex.Brace(cmd, string=u'test')

        self.assertEqual(cmd.write(), '\\foo[bar]{test}')

        cmd = latex.CustomCommand(None, 'foo', start='this', end='that')
        self.assertEqual(cmd.write(), 'this\\foothat')
Example #15
0
 def createLatex(self, parent, token, page): #pylint: disable=no-self-use,unused-argument
     url = token['url'].lstrip('#')
     if url.startswith('https://') or url.startswith('http://'):
         cmd = latex.Command(parent, 'href',
                             args=[latex.Brace(string=url)],
                             info=token.info)
     else:
         cmd = latex.Command(parent, 'hyperref',
                             args=[latex.Bracket(string=url)],
                             info=token.info)
     return cmd
Example #16
0
    def createLatex(self, parent, token, page):

        args = []
        style = latex.parse_style(token)
        width = style.get('width', None)
        if width:
            if width.endswith('%'):
                width = u'{}\\textwidth'.format(int(width[:-1])/100.)
            args.append(latex.Brace(string=width, escape=False))
            token.children[0]['width'] = width
        else:
            args.append(latex.Brace(string=u'\\textwidth', escape=False))

        if (len(token.children) > 1) and (token.children[1].name == 'CardTitle'):
            title = latex.Brace()
            self.translator.renderer.render(title, token.children[1], page)
            token.children[1].parent = None
            args.append(title)

        return latex.Environment(latex.Environment(parent, 'center'), 'card', args=args)
Example #17
0
 def createLatex(self, parent, token, page):
     pad = len(token.parent) * 0.01
     width = '{}\\textwidth'.format(token['medium'] / 12. - pad)
     env = latex.Environment(parent,
                             'minipage',
                             args=[
                                 latex.Bracket(string='t'),
                                 latex.Brace(string=width, escape=False)
                             ])
     if token is not token.parent.children[-1]:
         latex.Command(parent, 'hfill')
     return env
Example #18
0
    def createLatex(self, parent, token, page):
        node = self.getShortcut(token)

        link = node['link'].lstrip('#')
        if len(node) == 0:
            latex.String(parent, content='{}~'.format(node['prefix']), escape=False)
            h = latex.Command(parent, 'ref',
                              string=link,
                              info=token.info)
        else:
            h = latex.Command(parent, 'href',
                              args=[latex.Brace(string=link)],
                              string=node.children[0]['content'],
                              info=token.info)
        return h
Example #19
0
    def createLatex(self, parent, token, page):
        if token['header']:
            return None

        title = latex.Brace(string=token(0)['content'])
        reg = latex.Bracket(string=token['group'])
        args = [title, reg]

        if token['base']:
            args.append(latex.Bracket(string=token['base']))

        token(0).parent = None
        env = latex.Environment(parent, 'ObjectDescription', args=args)
        if len(token) == 0:
            latex.String(env, content="\\textcolor{red}{No Description.}", escape=False)
        return env
Example #20
0
    def createLatex(self, parent, token, page):
        master = parent

        if token['halign']:
            halign = token['halign']
            if halign != 'center':
                halign = 'flush{}'.format(halign)
            master = latex.Environment(master, halign)

        if token['border']:
            master = latex.Environment(master, 'fbox')

        if token['color']:
            master = latex.Brace(master)
            latex.Command(master, 'color', string=token['color'])

        return master
Example #21
0
    def createLatex(self, parent, token, page):

        latex.Command(parent, 'newline', start='\n', end='\n')
        latex.String(parent, content='Design:~', escape=False)

        no_seperator = True
        for design in token['design']:
            if not no_seperator:
                latex.String(parent, content='; ')
                no_seperator = False

            node = self.findDesign(design, token)
            if node:
                link = autolink.AutoLink(None, page=page)
                link.info = token.info
                self.createLatexHelper(parent, link, page, node)
            else:
                latex.Command(parent, 'textcolor', args=[latex.Brace(string='red')], string=design)
Example #22
0
    def createLatex(self, parent, token, page):
        prev = token.previous
        if prev and prev.name != 'RenderSQARequirementDetails':
            latex.Command(parent, 'newline', start='\n', end='\n')

        latex.String(parent, content='Design:~', escape=False)
        no_seperator = True
        for design in token['design']:
            if not no_seperator:
                latex.String(parent, content='; ')
                no_seperator = False

            node = self.findDesign(token['filename'], design, token['line'])
            if node:
                link = autolink.AutoLink(None, page=page)
                link.info = token.info
                self.createLatexHelper(parent, link, page, node)
            else:
                latex.Command(parent, 'textcolor', args=[latex.Brace(string='red')], string=design)
Example #23
0
    def createLatex(self, parent, token, page):

        # Create label option and render caption text
        cap = token(0)
        cap.parent = None
        label = latex.create_settings(label=cap['key'])

        text = tokens.String(None)
        cap.copyToToken(text)
        title = latex.Brace()
        self.translator.renderer.render(title, text, page)

        # Create example environment with upper and lower part
        example = latex.Environment(parent, 'example', args=[label, title])

        code = token.children[0]
        code.parent = None
        self.translator.renderer.render(example, code, page)  # upper
        latex.Command(example, 'tcblower', start='\n')
        return example
Example #24
0
 def createLatex(self, token, parent):  #pylint: disable=no-self-use,unused-argument
     url = token.url.lstrip('#')
     cmd = latex.CustomCommand(parent, 'href')
     latex.Brace(cmd, string=url)
     arg1 = latex.Brace(cmd)
     return arg1
Example #25
0
 def createLatex(self, parent, token, page):
     args = [latex.Brace(string=token['label'])]
     return latex.Environment(parent, 'Requirement', args=args)
Example #26
0
 def testBrace(self):
     enc = latex.Brace()
     self.assertEqual(enc.enclose, ('{', '}'))