def _get_standard_build_folder() -> typing.Tuple[Context, Path]: ctx = Context() pandoc = Path('pandoc') pandoc.touch() src_folder = Path('./test').absolute() src_folder.mkdir() ctx.source_folder = src_folder source_file = Path('./test/index.md') source_file.touch() ctx.source_file = source_file ctx.markdown_text = '' return ctx, pandoc
def test_markdown_preprocessor(): ctx = Context() index_file = Path('./index.md') index_file.write_text('', encoding='utf8') ctx.index_file = index_file ctx.includes = [] ctx.markdown_text = '' when(_markdown).process_aliases(ctx) when(_markdown).process_images(ctx) when(_markdown).process_references(ctx) _markdown.process_markdown(ctx) verifyStubbedInvocationsAreUsed()
def test_process_images(media): ctx = Context() ctx.image_max_width = 200 ctx.media_folders = [str(media.absolute()), '.'] pictures = list(media.iterdir()) ctx.markdown_text = f""" ![picture1](http://picture1.com) ![picture2]({pictures[0].name}) ![picture3](http://picture1.com) """ image.process_images(ctx) print(ctx.markdown_text) assert ctx.markdown_text == f"""
def test_process_references_no_ref(): ctx = Context() ctx.settings = Settings() ctx.markdown_text = """ This is some dummy markdown text. This should be ref1 //ref1. This should be ref3 //ref3. This should be ref1 //ref1 again. """ process_references(ctx) assert ctx.latex_refs == [] assert ctx.markdown_text == """
def test_process_references(): ctx = Context() ctx.settings.references = DUMMY_REFS ctx.markdown_text = """ This is some dummy markdown text. This should be ref1 //ref1. This should be ref3 //ref3. This should be ref1 //ref1 again. """ process_references(ctx) assert ctx.latex_refs == ['\\href{ref1_link}{ref1_name}', '\\href{ref3_link}{ref3_name}'] assert ctx.markdown_text == """