示例#1
0
def test_package_template_dir(monkeypatch, doc):
    renderer = Mock()
    resource = PackageTemplateDir(renderers='html',
                                  path=Path('mypkg') / 'templates')
    resource.alter(document=doc,
                   rendererName='html',
                   renderer=renderer,
                   target=Path('buildir'))
    renderer.importDirectory.assert_called_with(
        str(Path('mypkg') / 'templates'))
示例#2
0
def test_package_template_dir_user_dir(monkeypatch, doc):
    renderer = Mock()
    resource = PackageTemplateDir(renderers='html', package='mypkg')
    monkeypatch.setattr('os.path.isdir', lambda x: True)
    monkeypatch.setattr('plasTeX.PackageResource.rendererDir',
                        lambda x: 'html')

    resource.alter(document=doc,
                   rendererName='html',
                   renderer=renderer,
                   target='buildir')
    renderer.importDirectory.assert_called_with('mypkg' + os.sep)
示例#3
0
def test_package_template_dir_missing(monkeypatch, doc):
    renderer = Mock()
    resource = PackageTemplateDir(renderers='html', package='mypkg')
    monkeypatch.setattr('os.path.isdir', lambda x: False)
    monkeypatch.setattr('plasTeX.PackageResource.rendererDir',
                        lambda x: 'html')
    mock_logger = Mock()
    monkeypatch.setattr('plasTeX.PackageResource.log.error', mock_logger)

    resource.alter(document=doc,
                   rendererName='html',
                   renderer=renderer,
                   target='buildir')

    assert mock_logger.call_count == 1
示例#4
0
def ProcessOptions(options, document):
    context = document.context
    tpl = PackageTemplateDir(renderers='html5', package='subcaption')
    context.newcounter('subfigure',
                       resetby='figure',
                       format='${thefigure}${subfigure.alph}')
    context.newcounter('subtable',
                       resetby='table',
                       format='${thetable}${subtable.alph}')
    document.addPackageResource([tpl])
示例#5
0
def ProcessOptions(options, document):
    css = PackageCss(renderers='html5', data='test.css', package='mypkg')
    js = PackageJs(renderers='html5', data='test.js', package='mypkg')
    tpl = PackageTemplateDir(renderers='html5', package='mypkg')

    def cb(document):
        document.userdata['testing'] = 'test'
        return []

    callback = PackageResource(renderers='html5',
                               key='preCleanupCallbacks',
                               data=cb)
    document.addPackageResource([css, js, tpl, callback])
示例#6
0
def ProcessOptions(options, document):
    context = document.context
    # Load graphicx
    context.loadPackage(TeX, 'graphicx', {})

    # Lists
    context.newcounter('enumi')
    context.newcounter('enumii', resetby='enumi')
    context.newcounter('enumiii', resetby='enumii')
    context.newcounter('enumiv', resetby='enumiii')

    tpl = PackageTemplateDir(renderers='html5', package='beamer')
    document.addPackageResource([tpl])
示例#7
0
def ProcessOptions(options, document):
    css = PackageCss(renderers='html5',
                     path=Path(__file__).parent / 'mypkg' / 'test.css')
    js = PackageJs(renderers='html5',
                   path=Path(__file__).parent / 'mypkg' / 'test.js')
    tpl = PackageTemplateDir(renderers='html5',
                             path=Path(__file__).parent / 'mypkg')

    def cb(document):
        document.userdata['testing'] = 'test'
        return []

    callback = PackagePreCleanupCB(renderers='html5', data=cb)
    document.addPackageResource([css, js, tpl, callback])
示例#8
0
def ProcessOptions(options, document):
    context = document.context
    context.newcounter('section')
    context.newcounter('question')
    context['theenumi'].format = '${section.Alph}${thequestion}(${enumi.alph})'
    context['theenumii'].format = '${theenumi}(${enumii.roman})'
    context['theenumiii'].format = '${theenumii}${enumii.Alph}.'

    document.userdata['variant'] = 1
    document.userdata['modulecodes'] = {0: 'MAS0000', 1: 'MAS0000', 2: 'MAS0000', 3: 'MAS0000', 4: 'MAS0000'}
    document.userdata['submarks'] = 0
    document.userdata['calculatorpermitted'] = True
    document.userdata['examyear'] = ''
    document.userdata['semestertext'] = ''

    tpl = PackageTemplateDir(renderers='html5',package='nclexam')
    document.addPackageResource([tpl])
示例#9
0
def ProcessOptions(options, document):
    # Extend the article documentclass
    from plasTeX.Packages import article
    article.ProcessOptions(options, document)
    
    # Set the numbering formatting for subsection titles
    document.context['thesection'].format = '${section.Roman}.'
    document.context['thesubsection'].format = '${subsection.Alph}.'
    document.context['thesubsubsection'].format = '${subsubsection.arabic}.'
    document.context['theparagraph'].format = '${paragraph.alph}.'
    document.context['bibliography'].counter = 'section'
    document.context['bibliography'].level = Command.SECTION_LEVEL

    # Automatically import natbib with options
    from chirun.plastex.overrides import natbib
    natbib.ProcessOptions({'numbers': True, 'sort&compress':True}, document)
    
    # Use the jinja templates in plastexRenderer/revtex4-2/
    tpl = PackageTemplateDir(renderers='html5', package='revtex4-2')
    document.addPackageResource([tpl])
示例#10
0
def ProcessOptions(options, document):
    tpl = PackageTemplateDir(renderers='html5', package='cancel')
    document.addPackageResource([tpl])
示例#11
0
def ProcessOptions(options, document):
    tpl = PackageTemplateDir(renderers='html5', package='appendixnumberbeamer')
    document.addPackageResource([tpl])