def test_hide_from_toc_setting_from_latex_injection(self): textblock = self.stub() self.set_parent(textblock, self.stub_interface(IBook)) self.expect(textblock.pretty_title_or_id()).result('My Textblock') layout = self.stub_interface(ILaTeXLayout) self.expect(layout.get_converter().convert('My Textblock')).result( 'My Textblock') with self.mocker.order(): self.mock_inject_settings(textblock, hideFromTOC=True) self.mock_inject_settings(textblock, hideFromTOC=True) self.mock_inject_settings(textblock, hideFromTOC=False) self.replay() self.assertEquals(get_latex_heading(textblock, layout), '\\chapter*{My Textblock}\n') # Passed "toc" argument should take precedence self.assertEquals(get_latex_heading(textblock, layout, toc=True), '\\chapter{My Textblock}\n') self.assertEquals(get_latex_heading(textblock, layout, toc=False), '\\chapter*{My Textblock}\n')
def render(self): latex = [] if self.context.getShowTitle(): latex.append(utils.get_latex_heading(self.context, self.layout)) latex.append(self.table_latex()) return '\n'.join(latex)
def render(self): latex = [] if self.context.getShowTitle(): latex.append(utils.get_latex_heading(self.context, self.layout)) text = self.context.getText().strip() if len(text) > 0: latex.append(self.convert(text)) latex.append('') return '\n'.join(latex)
def render(self): latex = [] if self.context.getShowTitle(): latex.append(utils.get_latex_heading(self.context, self.layout)) text_latex = self.get_text_latex() floatable = text_latex and True or False image_latex = self.get_image_latex(floatable) latex.append(image_latex) latex.append(text_latex) return '\n'.join(latex)
def test_latex_heading_of_primary_chapter_without_toc(self): chapter = self.mocker.mock() self.set_parent(chapter, self.stub_interface(IBook)) self.expect(chapter.pretty_title_or_id()).result('My Chapter') self.mock_inject_settings(chapter) layout = self.stub_interface(ILaTeXLayout) self.expect(layout.get_converter().convert('My Chapter') ).result('My Chapter') self.replay() self.assertEquals(get_latex_heading(chapter, layout, toc=False), '\\chapter*{My Chapter}\n')
def test_not_within_book(self): chapter = self.mocker.mock() self.set_parent(chapter, self.stub_interface(INavigationRoot)) self.expect(chapter.pretty_title_or_id()).result('Any chapter') self.mock_inject_settings(chapter) layout = self.stub_interface(ILaTeXLayout) self.expect(layout.get_converter().convert('Any chapter') ).result('Any chapter') self.replay() self.assertEquals(get_latex_heading(chapter, layout), '\\section{Any chapter}\n')
def test_latex_heading_of_primary_chapter_without_toc(self): book = self.create_dummy() directlyProvides(book, IBook) chapter = self.mocker.mock() self.expect(aq_parent(aq_inner(chapter))).result(book) self.expect(chapter.pretty_title_or_id()).result('My Chapter') layout = self.mocker.mock() self.expect(layout.get_converter().convert('My Chapter') ).result('My Chapter') self.mocker.replay() self.assertEquals(get_latex_heading(chapter, layout, toc=False), '\\chapter*{My Chapter}\n')
def test_not_within_book(self): platform = self.create_dummy() directlyProvides(platform, INavigationRoot) chapter = self.mocker.mock() self.expect(aq_parent(aq_inner(chapter))).result(platform) self.expect(chapter.pretty_title_or_id()).result('Any chapter') layout = self.mocker.mock() self.expect(layout.get_converter().convert('Any chapter') ).result('Any chapter') self.mocker.replay() self.assertEquals(get_latex_heading(chapter, layout), '\\section{Any chapter}\n')
def test_latex_heading_of_third_level_chapter(self): chapter1 = self.mocker.mock() self.set_parent(chapter1, self.stub_interface(IBook)) chapter2 = self.mocker.mock() self.set_parent(chapter2, chapter1) chapter3 = self.mocker.mock() self.set_parent(chapter3, chapter2) self.expect(chapter3.pretty_title_or_id()).result('Sub chapter') self.mock_inject_settings(chapter3) layout = self.stub_interface(ILaTeXLayout) self.expect(layout.get_converter().convert('Sub chapter') ).result('Sub chapter') self.replay() self.assertEquals(get_latex_heading(chapter3, layout), '\\subsection{Sub chapter}\n')
def test_latex_heading_with_max_level_exceeded(self): book = self.providing_stub([IBook]) # create 10 objects and use the last one obj = None previous = book for i in range(10): obj = self.mocker.mock() self.set_parent(obj, previous) previous = obj self.expect(obj.pretty_title_or_id()).result('the title') layout = self.mocker.mock() self.expect(layout.get_converter().convert('the title') ).result('the title') self.mocker.replay() # subparagraph is the "smallest" heading.. self.assertEquals(get_latex_heading(obj, layout), '\\subparagraph{the title}\n')
def test_latex_heading_of_third_level_chapter(self): book = self.create_dummy() directlyProvides(book, IBook) chapter1 = self.mocker.mock() self.expect(aq_parent(aq_inner(chapter1))).result(book) chapter2 = self.mocker.mock() self.expect(aq_parent(aq_inner(chapter2))).result(chapter1) chapter3 = self.mocker.mock() self.expect(aq_parent(aq_inner(chapter3))).result(chapter2) self.expect(chapter3.pretty_title_or_id()).result('Sub chapter') layout = self.mocker.mock() self.expect(layout.get_converter().convert('Sub chapter') ).result('Sub chapter') self.mocker.replay() self.assertEquals(get_latex_heading(chapter3, layout), '\\subsection{Sub chapter}\n')
def test_latex_heading_with_max_level_exceeded(self): book = self.providing_stub([IBook]) # create 10 objects and use the last one obj = None previous = book for i in range(10): obj = self.mocker.mock() self.set_parent(obj, previous) previous = obj self.expect(obj.pretty_title_or_id()).result('the title') self.mock_inject_settings(obj) layout = self.stub_interface(ILaTeXLayout) self.expect(layout.get_converter().convert('the title') ).result('the title') self.replay() # subparagraph is the "smallest" heading.. self.assertEquals(get_latex_heading(obj, layout), '\\subparagraph{the title}\n')
def render(self): latex = self.get_heading_counters_latex() latex += utils.get_latex_heading(self.context, self.layout) latex += self.render_children() return latex
def render(self): latex = self.get_heading_counters_latex() latex += utils.get_latex_heading(self.context, self.layout) latex += utils.get_latex_chapter_author(self.context) #Only Chapter in the first level have "author" field latex += self.render_children() return latex