Ejemplo n.º 1
0
    def testLatex(self):
        # wrong image format
        ast = self.tokenize("!media http://clips.vorwaerts-gmbh.de/VfE.webm")
        with self.assertLogs(level='ERROR') as cm:
            res = self.render(ast, renderer=base.LatexRenderer())
        self.assertEqual(len(cm.output), 1)
        self.assertIn("are not supported with LaTeX", cm.output[0])

        # no float
        ast = self.tokenize(
            "!media http://clips.vorwaerts-gmbh.de/VfE.webm latex_src=Flag_of_Idaho.pdf"
        )
        res = self.render(ast, renderer=base.LatexRenderer())
        self.assertSize(res, 4)
        self.assertLatexCommand(res(0), 'includegraphics')
        self.assertIn('Flag_of_Idaho.pdf', res(0, 0)['content'])
        self.assertLatexCommand(
            res(2), 'url', string='http://clips.vorwaerts-gmbh.de/VfE.webm')

        # in float
        ast = self.tokenize(
            "!media http://clips.vorwaerts-gmbh.de/VfE.webm latex_src=Flag_of_Idaho.pdf caption=test id=idaho"
        )
        res = self.render(ast, renderer=base.LatexRenderer())
        self.assertSize(res, 1)
        self.assertLatexEnvironment(res(0), 'figure', size=5)
        self.assertLatexCommand(res(0, 0), 'caption', size=2)
        self.assertLatexCommand(res(0, 0, 0), 'label', size=1, string='idaho')
        self.assertLatexString(res(0, 0, 1), 'test')
        self.assertLatexCommand(res(0, 1), 'includegraphics')
        self.assertIn('Flag_of_Idaho.pdf', res(0, 1, 0)['content'])
        self.assertLatexCommand(
            res(0, 3), 'url', string='http://clips.vorwaerts-gmbh.de/VfE.webm')
Ejemplo n.º 2
0
    def testLatex(self):
        # wrong image format
        ast = self.tokenize("!media Flag_of_Idaho.svg")
        with self.assertLogs(level='ERROR') as cm:
            res = self.render(ast, renderer=base.LatexRenderer())
        self.assertEqual(len(cm.output), 1)
        self.assertIn("Images with the '.svg'", cm.output[0])

        # no float
        ast = self.tokenize(
            "!media Flag_of_Idaho.svg latex_src=Flag_of_Idaho.pdf")
        res = self.render(ast, renderer=base.LatexRenderer())
        self.assertSize(res, 1)
        self.assertLatexCommand(res(0), 'includegraphics')
        self.assertIn('Flag_of_Idaho.pdf', res(0, 0)['content'])

        # in float
        ast = self.tokenize(
            "!media Flag_of_Idaho.svg latex_src=Flag_of_Idaho.pdf caption=test id=idaho"
        )
        res = self.render(ast, renderer=base.LatexRenderer())
        self.assertSize(res, 1)
        self.assertLatexEnvironment(res(0), 'figure', size=2)
        self.assertLatexCommand(res(0, 0), 'caption', size=2)
        self.assertLatexCommand(res(0, 0, 0), 'label', size=1, string='idaho')
        self.assertLatexString(res(0, 0, 1), 'test')
        self.assertLatexCommand(res(0, 1), 'includegraphics')
        self.assertIn('Flag_of_Idaho.pdf', res(0, 1, 0)['content'])
Ejemplo n.º 3
0
    def testLatex(self):
        ast = modal.ModalSourceLink(None, src='framework/Makefile')
        res = self.render(ast, renderer=base.LatexRenderer())
        self.assertSize(res, 1)
        self.assertLatexString(res(0), content='(python/MooseDocs/test/extensions/framework/Makefile)')

        ast = modal.ModalSourceLink(None, string='test',
                                    src='moose/test/tests/kernels/simple_diffusion/simple_diffusion.i')
        res = self.render(ast, renderer=base.LatexRenderer())
        self.assertSize(res, 1)
        self.assertLatexString(res(0), content='test')

        print(res, "\n")
Ejemplo n.º 4
0
    def testCodeBlock(self):
        text = "```\nint x = 0;\n```"
        ast = self.tokenize(text)
        self.assertToken(ast(0),
                         'Code',
                         language='text',
                         content='\nint x = 0;\n',
                         escape=True)

        def helper(r):
            self.assertHTMLTag(r(0), 'pre', class_='moose-pre')
            self.assertHTMLTag(r(0)(0), 'code', class_='language-text')
            self.assertHTMLString(r(0)(0)(0), '\nint x = 0;\n', escape=True)

        res = self.render(ast)
        self.assertHTMLTag(res, 'body')
        helper(res)

        res = self.render(ast, renderer=base.MaterializeRenderer())
        self.assertHTMLTag(res, 'div')
        helper(res)

        tex = self.render(ast, renderer=base.LatexRenderer())
        self.assertLatex(tex(0),
                         'Environment',
                         'verbatim',
                         after_begin='\n',
                         before_end='\n',
                         escape=False)
        self.assertLatexString(tex(0)(0), 'int x = 0;', escape=False)
Ejemplo n.º 5
0
    def testSQARequirementDetails(self):

        tok = sqa.SQARequirementDetails(None)
        sqa.SQARequirementDetailItem(tok, label='foo')
        sqa.SQARequirementDetailItem(tok, label='bar')

        res = self.render(tok, renderer=base.HTMLRenderer())
        self.assertHTMLTag(res, 'body', size=1)
        self.assertHTMLTag(res(0), 'ol', size=2, class_='moose-sqa-details-list')
        self.assertHTMLTag(res(0)(0), 'li', size=0, class_='moose-sqa-detail-item')
        self.assertHTMLTag(res(0)(1), 'li', size=0, class_='moose-sqa-detail-item')

        res = self.render(tok, renderer=base.MaterializeRenderer())
        self.assertHTMLTag(res, 'div', size=1)
        self.assertHTMLTag(res(0), 'ol', size=2, class_='moose-sqa-details-list')
        self.assertHTMLTag(res(0)(0), 'li', size=0, class_='moose-sqa-detail-item')
        self.assertHTMLTag(res(0)(1), 'li', size=0, class_='moose-sqa-detail-item')

        res = self.render(tok, renderer=base.RevealRenderer())
        self.assertHTMLTag(res, 'div', size=1)
        self.assertHTMLTag(res(0), 'ol', size=2, class_='moose-sqa-details-list')
        self.assertHTMLTag(res(0)(0), 'li', size=0, class_='moose-sqa-detail-item')
        self.assertHTMLTag(res(0)(1), 'li', size=0, class_='moose-sqa-detail-item')

        res = self.render(tok, renderer=base.LatexRenderer())
        self.assertLatex(res(0), 'Environment', 'enumerate')
        self.assertLatex(res(0)(0), 'Command', 'item')
        self.assertLatex(res(0)(1), 'Command', 'item')
Ejemplo n.º 6
0
    def testLatex(self):
        _, res = self.execute(self.TEXT, renderer=base.LatexRenderer())
        self.assertSize(res, 3)

        self.assertLatex(res(0), 'Command', 'tcbset', size=1, escape=False)
        self.assertLatexString(res(0)(0),
                               content='height from=1in to 200in',
                               escape=False)

        self.assertLatex(res(1), 'Environment', 'alert', size=6)
        self.assertLatexArg(res(1), 0, 'Bracket', 'construction')
        self.assertLatexArg(res(1), 1, 'Brace', 'construction')

        self.assertLatex(res(1)(0), 'Environment', 'wrapfigure', size=1)
        self.assertLatexArg(res(1)(0), 0, 'Brace', 'l')
        self.assertLatexArg(res(1)(0), 1, 'Brace', '1in')
        self.assertLatex(res(1)(0)(0), 'Command', 'includegraphics', size=1)
        self.assertLatexArg(res(1)(0)(0), 0, 'Bracket', 'height=0.6in')
        self.assertLatexString(
            res(1)(0)(0)(0), content='media/framework/under-construction.png')

        self.assertLatex(res(1)(1), 'Command', 'par')
        self.assertLatexString(res(1)(2), content='Under')
        self.assertLatexString(res(1)(3), content=' ')
        self.assertLatexString(res(1)(4), content='construction')
        self.assertLatexString(res(1)(5), content='.')

        self.assertLatex(res(2), 'Command', 'tcbset', size=1, escape=False)
        self.assertLatexString(res(2)(0),
                               content='height from=0in to 200in',
                               escape=False)
Ejemplo n.º 7
0
    def testBookmarkWrong(self):
        link = autolink.AutoLink(None, page='core.md', bookmark='wrong')

        res = self.render(link, renderer=base.HTMLRenderer())
        self.assertHTMLTag(res, 'body', size=1)
        self.assertHTMLTag(res(0),
                           'a',
                           string='extensions/core.html#wrong',
                           href='extensions/core.html#wrong',
                           class_='moose-error')

        res = self.render(link, renderer=base.MaterializeRenderer())
        self.assertHTMLTag(res, 'div', size=1)
        self.assertHTMLTag(res(0),
                           'a',
                           string='extensions/core.html#wrong',
                           href='extensions/core.html#wrong',
                           class_='moose-error')

        res = self.render(link, renderer=base.RevealRenderer())
        self.assertHTMLTag(res, 'div', size=1)
        self.assertHTMLTag(res(0),
                           'a',
                           string='extensions/core.html#wrong',
                           href='extensions/core.html#wrong',
                           class_='moose-error')

        res = self.render(link, renderer=base.LatexRenderer())
        self.assertSize(res, 1)
        self.assertLatexString(res(0), '_text_')
Ejemplo n.º 8
0
    def testSQARequirementDesign(self, mock_design):
        """
        RenderSQARequirementDesign.findDesign tries to look up a page via the translator.findPage,
        but the current setup for unit testing is not setup to allow for page lookups, so this
        is just testing for the error case for now.

        TODO: MooseDocsTestCase needs to handle the ability to find pages
        """
        mock_design.return_value = None # Allows log error to be skipped
        tok = sqa.SQARequirementDesign(None, design=['file.md'], line=42, filename='file')

        res = self.render(tok, renderer=base.HTMLRenderer())
        self.assertHTMLTag(res, 'body', size=1)
        self.assertHTMLTag(res(0), 'p', size=2, class_='moose-sqa-items')
        self.assertHTMLString(res(0)(0), 'Design: ')
        self.assertHTMLTag(res(0)(1), 'a', string='file.md', class_='moose-sqa-error')

        res = self.render(tok, renderer=base.MaterializeRenderer())
        self.assertHTMLTag(res, 'div', size=1)
        self.assertHTMLTag(res(0), 'p', size=2, class_='moose-sqa-items')
        self.assertHTMLString(res(0)(0), 'Design: ')
        self.assertHTMLTag(res(0)(1), 'a', string='file.md', class_='moose-sqa-error')

        res = self.render(tok, renderer=base.RevealRenderer())
        self.assertHTMLTag(res, 'div', size=1)
        self.assertHTMLTag(res(0), 'p', size=2, class_='moose-sqa-items')
        self.assertHTMLString(res(0)(0), 'Design: ')
        self.assertHTMLTag(res(0)(1), 'a', string='file.md', class_='moose-sqa-error')

        res = self.render(tok, renderer=base.LatexRenderer())
        self.assertSize(res, 2)
        self.assertLatexString(res(0), 'Design:~')
        self.assertLatex(res(1), 'Command', 'textcolor')
        self.assertLatexArg(res(1), 0, 'Brace', string='red')
        self.assertLatexString(res(1)(0), 'file.md')
Ejemplo n.º 9
0
 def testMinimalLatex(self):
     """The link and floats stuff is dropped by the LaTeX renderer"""
     link = autolink.SourceLink(None)
     core.Link(link, string='Content', url='something')
     res = self.render(link, renderer=base.LatexRenderer())
     self.assertSize(res, 1)
     self.assertLatexString(res(0), 'Content')
Ejemplo n.º 10
0
    def testSQARequirementMatrixItemUnSatisfied(self):

        tok = sqa.SQARequirementMatrixItem(None,
                                           label='F1.1.1',
                                           satisfied=False)

        res = self.render(tok, renderer=base.HTMLRenderer())
        self.assertHTMLTag(
            res(0)(0),
            'span',
            string='F1.1.1',
            class_=
            'moose-sqa-requirement-number moose-sqa-requirement-unsatisfied')

        res = self.render(tok, renderer=base.MaterializeRenderer())
        self.assertHTMLTag(
            res(0)(0),
            'span',
            string='F1.1.1',
            class_=
            'moose-sqa-requirement-number tooltipped moose-sqa-requirement-unsatisfied'
        )

        res = self.render(tok, renderer=base.RevealRenderer())
        self.assertHTMLTag(
            res(0)(0),
            'span',
            string='F1.1.1',
            class_=
            'moose-sqa-requirement-number moose-sqa-requirement-unsatisfied')

        res = self.render(tok, renderer=base.LatexRenderer())
        arg = res(0)['args'][0]
        self.assertLatex(arg(0), 'Command', 'textcolor', string='F1.1.1')
        self.assertLatexArg(arg(0), 0, 'Brace', string='red')
Ejemplo n.º 11
0
    def testLatex(self):
        _, res = self.execute(self.TEXT, renderer=base.LatexRenderer())
        self.assertSize(res, 1)

        self.assertLatex(res(0), 'Environment', 'alert', size=5)
        self.assertLatexArg(res(0), 0, 'Bracket', 'construction')
        self.assertLatexArg(res(0), 1, 'Brace', 'construction')
Ejemplo n.º 12
0
    def testLatex(self):
        ast, res = self.execute(self.TEXT, renderer=base.LatexRenderer())

        self.assertSize(res, 13)
        for i, j, s in zip([0, 2, 4], [1, 3, 5], self.SHORTCUTS):
            self.assertLatexEnvironment(res(i),
                                        'lstlisting',
                                        size=1,
                                        escape=False,
                                        after_begin='\n',
                                        before_end='\n',
                                        info=ast.info)
            self.assertLatexArg(res(i), 0, 'Bracket', size=3)
            self.assertLatexString(res(i)['args'][0](0),
                                   content='label=' + s + ',')
            self.assertLatexString(res(i)['args'][0](1), content='caption=')
            self.assertLatexString(res(i)['args'][0](2),
                                   content='\\mbox{}',
                                   escape=False)
            self.assertLatexString(res(i, 0), content=s.capitalize())
            self.assertLatexEnvironment(res(j),
                                        'lstlisting',
                                        size=1,
                                        escape=False,
                                        after_begin='\n',
                                        before_end='\n',
                                        info=ast.info)
            self.assertLatexString(res(j, 0), content=s.capitalize())

        self.assertLatexCommand(res(6), 'par')
        for i, j, s in zip([7, 9, 11], [8, 10, 12], self.SHORTCUTS):
            self.assertLatexString(res(i), content='Listing~')
            self.assertLatexCommand(res(j), 'ref', size=1)
            self.assertLatexString(res(j, 0), content=s)
Ejemplo n.º 13
0
    def testSQARequirementIssues(self):

        tok = sqa.SQARequirementIssues(None, issues=['#1', '#2'], url='https://github.com/idaholab/moose')
        res = self.render(tok, renderer=base.HTMLRenderer())
        self.assertHTMLTag(res, 'body', size=1)
        self.assertHTMLTag(res(0), 'p', size=3, class_='moose-sqa-items')
        self.assertHTMLString(res(0)(0), 'Issue(s): ')
        self.assertHTMLTag(res(0)(1), 'a', string='#1', href='https://github.com/idaholab/moose/issues/1')
        self.assertHTMLTag(res(0)(2), 'a', string='#2', href='https://github.com/idaholab/moose/issues/2')

        res = self.render(tok, renderer=base.MaterializeRenderer())
        self.assertHTMLTag(res, 'div', size=1)
        self.assertHTMLTag(res(0), 'p', size=3, class_='moose-sqa-items')
        self.assertHTMLString(res(0)(0), 'Issue(s): ')
        self.assertHTMLTag(res(0)(1), 'a', string='#1', href='https://github.com/idaholab/moose/issues/1')
        self.assertHTMLTag(res(0)(2), 'a', string='#2', href='https://github.com/idaholab/moose/issues/2')

        res = self.render(tok, renderer=base.RevealRenderer())
        self.assertHTMLTag(res, 'div', size=1)
        self.assertHTMLTag(res(0), 'p', size=3, class_='moose-sqa-items')
        self.assertHTMLString(res(0)(0), 'Issue(s): ')
        self.assertHTMLTag(res(0)(1), 'a', string='#1', href='https://github.com/idaholab/moose/issues/1')
        self.assertHTMLTag(res(0)(2), 'a', string='#2', href='https://github.com/idaholab/moose/issues/2')

        res = self.render(tok, renderer=base.LatexRenderer())
        self.assertSize(res, 3)
        self.assertLatexString(res(0), 'Issue(s):~')
        self.assertLatex(res(1), 'Command', 'href', string='#1')
        self.assertLatexArg(res(1), 0, 'Brace', 'https://github.com/idaholab/moose/issues/1')
        self.assertLatex(res(2), 'Command', 'href', string='#2')
        self.assertLatexArg(res(2), 0, 'Brace', 'https://github.com/idaholab/moose/issues/2')
Ejemplo n.º 14
0
    def testSQARequirementMatrixItemSatisfied(self):

        tok = sqa.SQARequirementMatrixItem(None, label='F1.1.1', reqname='path:Foo')

        res = self.render(tok, renderer=base.HTMLRenderer())
        self.assertHTMLTag(res, 'body', size=1)
        self.assertHTMLTag(res(0), 'li', size=2)
        self.assertHTMLTag(res(0)(0), 'span', string='F1.1.1', class_='moose-sqa-requirement-number')
        self.assertHTMLTag(res(0)(1), 'span', size=0, class_='moose-sqa-requirement-content')

        res = self.render(tok, renderer=base.MaterializeRenderer())
        self.assertHTMLTag(res, 'div', size=1, class_='moose-content')
        self.assertHTMLTag(res(0), 'li', size=2, class_='collection-item')
        self.assertHTMLTag(res(0)(0), 'span', string='F1.1.1', id_='path:Foo', class_='moose-sqa-requirement-number tooltipped', **{'data-tooltip':'path:Foo'})
        self.assertHTMLTag(res(0)(1), 'span', size=0, class_='moose-sqa-requirement-content')

        res = self.render(tok, renderer=base.RevealRenderer())
        self.assertHTMLTag(res, 'div', size=1)
        self.assertHTMLTag(res(0), 'li', size=2)
        self.assertHTMLTag(res(0)(0), 'span', string='F1.1.1', class_='moose-sqa-requirement-number')
        self.assertHTMLTag(res(0)(1), 'span', size=0, class_='moose-sqa-requirement-content')

        res = self.render(tok, renderer=base.LatexRenderer())
        self.assertSize(res, 1)
        self.assertLatex(res(0), 'Environment', 'Requirement')
        self.assertLatexArg(res(0), 0, 'Brace', string='F1.1.1')
Ejemplo n.º 15
0
    def testLatex(self):
        _, res = self.execute('!content a-to-z location=extensions',
                              renderer=base.LatexRenderer())
        self.assertSize(res, 8)
        self.assertLatex(res(0), 'Command', 'par')
        self.assertLatex(res(1),
                         'Command',
                         'ContentItem',
                         string='Acronym Extension')
        self.assertLatexArg(res(1), 0, 'Brace', 'extensions/acronym.tex')
        self.assertLatexArg(res(1), 1, 'Brace', 'acronym-extension')

        self.assertLatex(res(2), 'Command', 'par')
        self.assertLatex(res(3),
                         'Command',
                         'ContentItem',
                         string='Content Extension')
        self.assertLatexArg(res(3), 0, 'Brace', 'extensions/content.tex')
        self.assertLatexArg(res(3), 1, 'Brace', 'content-extension')

        self.assertLatex(res(4),
                         'Command',
                         'ContentItem',
                         string='Core Extension')
        self.assertLatexArg(res(4), 0, 'Brace', 'extensions/core.tex')
        self.assertLatexArg(res(4), 1, 'Brace', 'core-extension')

        self.assertLatex(res(5), 'Command', 'par')
        self.assertLatex(res(6),
                         'Command',
                         'ContentItem',
                         string='Table Extensions')
        self.assertLatexArg(res(6), 0, 'Brace', 'extensions/table.tex')
        self.assertLatexArg(res(6), 1, 'Brace', 'table-extensions')
Ejemplo n.º 16
0
    def testSQARequirementPrequisites(self):
        tok = sqa.SQARequirementPrequisites(None, specs=[('path', 'name0', 'F1.1'),
                                                         ('path', 'name1', 'F1.2')])
        res = self.render(tok, renderer=base.HTMLRenderer())
        self.assertHTMLTag(res, 'body', size=1)
        self.assertHTMLTag(res(0), 'p', size=3)
        self.assertHTMLString(res(0)(0), 'Prerequisite(s): ')
        self.assertHTMLTag(res(0)(1), 'a', string='F1.1', href='#path:name0')
        self.assertHTMLTag(res(0)(2), 'a', string='F1.2', href='#path:name1')

        res = self.render(tok, renderer=base.MaterializeRenderer())
        self.assertHTMLTag(res, 'div', size=1)
        self.assertHTMLTag(res(0), 'p', size=3)
        self.assertHTMLString(res(0)(0), 'Prerequisite(s): ')
        self.assertHTMLTag(res(0)(1), 'a', string='F1.1', href='#path:name0')
        self.assertHTMLTag(res(0)(2), 'a', string='F1.2', href='#path:name1')

        res = self.render(tok, renderer=base.RevealRenderer())
        self.assertHTMLTag(res, 'div', size=1)
        self.assertHTMLTag(res(0), 'p', size=3)
        self.assertHTMLString(res(0)(0), 'Prerequisite(s): ')
        self.assertHTMLTag(res(0)(1), 'a', string='F1.1', href='#path:name0')
        self.assertHTMLTag(res(0)(2), 'a', string='F1.2', href='#path:name1')

        res = self.render(tok, renderer=base.LatexRenderer())
        self.assertLatexString(res(0), 'Prerequisite(s):~')
        self.assertLatexString(res(1), 'F1.1; F1.2')
Ejemplo n.º 17
0
    def testSQARequirementMatrix(self):
        tok = sqa.SQARequirementMatrix(None)

        res = self.render(tok, renderer=base.HTMLRenderer())
        self.assertSize(res, 1)
        self.assertHTMLTag(res(0),
                           'ul',
                           size=0,
                           class_='moose-sqa-requirements')

        res = self.render(tok, renderer=base.MaterializeRenderer())
        self.assertSize(res, 1)
        self.assertHTMLTag(
            res(0),
            'ul',
            size=0,
            class_='moose-sqa-requirements collection with-header')

        res = self.render(tok, renderer=base.RevealRenderer())
        self.assertSize(res, 1)
        self.assertHTMLTag(res(0),
                           'ul',
                           size=0,
                           class_='moose-sqa-requirements')

        res = self.render(tok, renderer=base.LatexRenderer())
        self.assertSize(res, 0)
Ejemplo n.º 18
0
    def testBookmark(self):
        link = autolink.AutoLink(None, page='core.md', bookmark='unordered-nested-lists')

        res = self.render(link, renderer=base.HTMLRenderer())
        self.assertHTMLTag(res, 'body', size=1)
        self.assertHTMLTag(res(0), 'a', size=3, href='extensions/core.html#unordered-nested-lists')
        self.assertHTMLString(res(0)(0), 'Nested')
        self.assertHTMLString(res(0)(1), ' ')
        self.assertHTMLString(res(0)(2), 'lists')

        res = self.render(link, renderer=base.MaterializeRenderer())
        self.assertHTMLTag(res, 'div', size=1)
        self.assertHTMLTag(res(0), 'a', size=3, href='extensions/core.html#unordered-nested-lists')
        self.assertHTMLString(res(0)(0), 'Nested')
        self.assertHTMLString(res(0)(1), ' ')
        self.assertHTMLString(res(0)(2), 'lists')

        res = self.render(link, renderer=base.RevealRenderer())
        self.assertHTMLTag(res, 'div', size=1)
        self.assertHTMLTag(res(0), 'a', size=3, href='extensions/core.html#unordered-nested-lists')
        self.assertHTMLString(res(0)(0), 'Nested')
        self.assertHTMLString(res(0)(1), ' ')
        self.assertHTMLString(res(0)(2), 'lists')

        res = self.render(link, renderer=base.LatexRenderer())
        self.assertSize(res, 1)
        self.assertLatex(res(0), 'Command', 'hyperref')
        self.assertLatexArg(res(0), 0, 'Bracket', 'unordered-nested-lists')
        self.assertLatexString(res(0)(0), 'Nested')
        self.assertLatexString(res(0)(1), ' ')
        self.assertLatexString(res(0)(2), 'lists')
Ejemplo n.º 19
0
    def testOptional(self):
        link = autolink.AutoLink(None, page='not_a_file.md', optional=True)

        self._testOptionalHelper(link)

        res = self.render(link, renderer=base.LatexRenderer())
        self.assertSize(res, 1)
        self.assertLatexString(res(0), 'not_a_file.md')
Ejemplo n.º 20
0
    def testExact(self):
        link = autolink.AutoLink(None, page='extensions/core.md', exact=True)

        self._testLinkHelper(link)

        res = self.render(link, renderer=base.LatexRenderer())
        self.assertSize(res, 1)
        self._assertLatex(res(0))
Ejemplo n.º 21
0
 def testLatex(self):
     ast = self.tokenize('!devel example\ntest')
     res = self.render(ast, renderer=base.LatexRenderer())
     self.assertLatex(res(0), 'Environment', 'example')
     self.assertLatex(res(0, 0), 'Environment', 'verbatim', string='test')
     self.assertLatex(res(0, 1), 'Command', 'tcblower')
     self.assertLatex(res(0, 2), 'Command', 'par')
     self.assertLatexString(res(0, 3), content='test')
Ejemplo n.º 22
0
    def testMinimal(self):
        link = autolink.AutoLink(None, page='core.md')

        self._testLinkHelper(link)

        res = self.render(link, renderer=base.LatexRenderer())
        self.assertSize(res, 1)
        self._assertLatex(res(0))
Ejemplo n.º 23
0
    def testLatex(self):
        ast, res = self.execute(self.TEXT[0], renderer=base.LatexRenderer())
        self.assertSize(res, 1)
        self.assertLatexEnvironment(res(0), 'verbatim', size=1, escape=False, after_begin='\n',
                                    before_end='\n', info=ast.info)
        self.assertLatexString(res(0,0), content=self.CODE[0])

        ast, res = self.execute(self.TEXT[1], renderer=base.LatexRenderer())
        self.assertSize(res, 2)
        self.assertLatexEnvironment(res(0), 'lstlisting', size=1, escape=False, after_begin='\n',
                                    before_end='\n', info=ast.info)
        self.assertLatexArg(res(0), 0, 'Bracket', size=2)
        self.assertLatexString(res(0)['args'][0](0), content='title=')
        self.assertLatex(res(0)['args'][0](1), 'Brace', 'Brace', size=3)
        self.assertLatexString(res(0)['args'][0](1)(0), content='the')
        self.assertLatexString(res(0)['args'][0](1)(1), content=' ')
        self.assertLatexCommand(res(0)['args'][0](1)(2), 'textbf', size=1)
        self.assertLatexString(res(0)['args'][0](1)(2)(0), content='caption')
        self.assertLatexString(res(0,0), content=self.CODE[1])
        self.assertLatexEnvironment(res(1), 'lstlisting', size=1, escape=False, after_begin='\n',
                                    before_end='\n', info=ast.info)
        self.assertLatexArg(res(1), 0, 'Bracket')
        self.assertLatexString(res(1,0), content=self.CODE[1])

        ast, res = self.execute(self.TEXT[2], renderer=base.LatexRenderer())
        self.assertSize(res, 5)
        self.assertLatexEnvironment(res(0), 'lstlisting', size=1, escape=False, after_begin='\n',
                                    before_end='\n', info=ast.info)
        self.assertLatexArg(res(0), 0, 'Bracket', size=3)
        self.assertLatexString(res(0)['args'][0](0), content='label=file1,')
        self.assertLatexString(res(0)['args'][0](1), content='caption=')
        self.assertLatex(res(0)['args'][0](2), 'Brace', 'Brace', size=3)
        self.assertLatexString(res(0)['args'][0](2)(0), content='the')
        self.assertLatexString(res(0)['args'][0](2)(1), content=' ')
        self.assertLatexCommand(res(0)['args'][0](2)(2), 'ul', size=1)
        self.assertLatexString(res(0)['args'][0](2)(2)(0), content='caption')
        self.assertLatexString(res(0,0), content=self.CODE[2])
        self.assertLatexEnvironment(res(1), 'lstlisting', size=1, escape=False, after_begin='\n',
                                    before_end='\n', info=ast.info)
        self.assertLatexArg(res(1), 0, 'Bracket')
        self.assertLatexString(res(1,0), content=self.CODE[2])
        self.assertLatexCommand(res(2), 'par')
        self.assertLatexString(res(3), content='File~')
        self.assertLatexCommand(res(4), 'ref', size=1)
        self.assertLatexString(res(4,0), content='file1')
Ejemplo n.º 24
0
 def testLatex(self):
     _, res = self.execute(self.TEXT, renderer=base.LatexRenderer())
     self.assertSize(res, 6)
     self.assertLatex(res(0), 'Command', 'par')
     self.assertLatexString(res(1), u'Idaho National Laboratory (INL)')
     self.assertLatexString(res(2), u' ')
     self.assertLatexString(res(3), u'and')
     self.assertLatexString(res(4), u' ')
     self.assertLatexString(res(5), u'INL')
Ejemplo n.º 25
0
    def testAlternative(self):
        link = autolink.AutoLink(None, page='not_a_file.md', alternative='core.md')

        self._testLinkHelper(link)

        res = self.render(link, renderer=base.LatexRenderer())
        self.assertSize(res, 1)
        self.assertLatexString(res(0), "Warning: The 'alternative' setting for automatic links " \
                                       "has no effect on LaTeX renderers.")
Ejemplo n.º 26
0
    def testLatex(self):
        ast, res = self.execute(self.TEXT[0], renderer=base.LatexRenderer())
        self.assertSize(res, 2)
        self.assertLatexEnvironment(res(0),
                                    'lstlisting',
                                    size=1,
                                    escape=False,
                                    after_begin='\n',
                                    before_end='\n',
                                    info=ast.info)
        self.assertLatexArg(res(0), 0, 'Bracket', size=4)
        self.assertLatexString(res(0)['args'][0](0), content='language=C++,')
        self.assertLatexString(res(0)['args'][0](1),
                               content='label=diffusion-c,')
        self.assertLatexString(res(0)['args'][0](2), content='caption=')
        self.assertLatexString(res(0)['args'][0](3),
                               content='\\mbox{}',
                               escape=False)
        self.assertLatexString(res(0, 0), content=self.CODE[0].strip('\n'))
        self.assertLatexEnvironment(res(1),
                                    'lstlisting',
                                    size=1,
                                    escape=False,
                                    after_begin='\n',
                                    before_end='\n',
                                    info=ast.info)
        self.assertLatexArg(res(1), 0, 'Bracket', size=1)
        self.assertLatexString(res(1)['args'][0](0), content='language=C++,')
        self.assertLatexString(res(1, 0), content=self.CODE[0].strip('\n'))

        ast, res = self.execute(self.TEXT[1], renderer=base.LatexRenderer())
        self.assertSize(res, 2)
        self.assertLatexEnvironment(res(0),
                                    'verbatim',
                                    size=1,
                                    escape=False,
                                    after_begin='\n',
                                    before_end='\n',
                                    info=ast.info)
        self.assertLatexString(res(0, 0), content=self.CODE[1].strip('\n'))
        self.assertLatexString(res(1),
                               content='(framework/src/kernels/Diffusion.C)')
Ejemplo n.º 27
0
 def testLatex(self):
     ast, res = self.execute(self.TEXT, renderer=base.LatexRenderer())
     self.assertSize(res, 1)
     self.assertLatexEnvironment(res(0),
                                 'verbatim',
                                 size=1,
                                 escape=False,
                                 after_begin='\n',
                                 before_end='\n',
                                 info=ast.info)
     self.assertLatexString(res(0, 0), content=self.CODE.strip('\n'))
Ejemplo n.º 28
0
    def testMinimalLatex(self, mock_find_heading):
        head = core.Heading(None, level=1, id_='bookmark')
        core.Word(head, content='heading')
        mock_find_heading.return_value = head

        link = autolink.LocalLink(None, bookmark='bookmark')
        res = self.render(link, renderer=base.LatexRenderer())
        self.assertSize(res, 1)
        self.assertLatex(res(0), 'Command', 'hyperref')
        self.assertLatexArg(res(0), 0, 'Bracket', 'bookmark')
        self.assertLatexString(res(0)(0), 'heading')
Ejemplo n.º 29
0
 def testLatex(self):
     _, res = self.execute(self.TEXT, renderer=base.LatexRenderer())
     self.assertEqual(len(res), 8)
     self.assertLatex(res(0), 'Command', 'par')
     self.assertLatexString(res(1), 'Not')
     self.assertLatexString(res(2), ' ')
     self.assertLatexString(res(3), 'comment')
     self.assertLatexString(res(4), ' ')
     self.assertLatexString(res(5), 'and')
     self.assertLatexString(res(6), ' ')
     self.assertLatexString(res(7), 'not')
Ejemplo n.º 30
0
    def testBookmark(self):
        link = autolink.AutoLink(None, page='core.md', bookmark='unordered-nested-lists')

        self._testBookmarkHelper(link)

        res = self.render(link, renderer=base.LatexRenderer())
        self.assertSize(res, 1)
        self.assertLatex(res(0), 'Command', 'hyperref')
        self.assertLatexArg(res(0), 0, 'Bracket', 'unordered-nested-lists')
        self.assertLatexString(res(0)(0), 'Nested')
        self.assertLatexString(res(0)(1), ' ')
        self.assertLatexString(res(0)(2), 'lists')