def test_rstdemo(tmpdir): configuration = Article.Configuration(stylesheet=sphinx_base14, abstract_location='title', table_of_contents=False) configuration('title_page', top_margin=2 * CM) with open(os.path.join(TEST_DIR, 'demo.txt')) as file: parser = ReStructuredTextReader() flowables = parser.parse(file) document = Article(flowables, configuration=configuration, backend=pdf) os.chdir(tmpdir.strpath) document.render('demo') _, _, _, badlinks, _, _ = check_pdf_links('demo.pdf') pytest.assume(badlinks == ['table-of-contents']) if not diff_pdf(os.path.join(TEST_DIR, 'reference/demo.pdf'), 'demo.pdf'): pytest.fail('The generated PDF is different from the reference PDF.\n' 'Generated files can be found in {}'.format( tmpdir.strpath))
from rinoh.backend import pdf from rinoh.frontend.commonmark import CommonMarkReader from rinoh.templates import Article if __name__ == '__main__': reader = CommonMarkReader() for name in ('README', ): with open(name + '.md', 'rb') as file: document_tree = reader.parse(file) document = Article(document_tree, backend=pdf) document.render(name)