def test_ligature_classique(): # the word "angstrœm" is not in 'classique', but is in 'reforme1990' result = typographeur("angstroem", ligature_variant="classique") assert result == "angstroem" result = typographeur("angstroem", ligature_variant="reforme1990") assert result == "angstrœm"
def test_point_space(): input = 'hello …' output = typographeur(input, fix_point_space=False) assert output == input input = 'hello . world' output = typographeur(input, fix_point_space=False) assert output == input
def write(self): date = self.post.get('date_event') if not date: date = self.post.get('date').strftime("%Y-%m-%d") if self.post.get('date') else None post = frontmatter.load(self.post.get('source')) context = self.env.make_context(self.post.get('target')) folder_name = "{}-{}".format(date, slugify(self.post.get('title'))) content = markdown.markdown( post.content, extensions=[ ImageProcessorExtension( ImageProcessor( folder_name, self.env.folder, context ) ) ] ) typo_content = typographeur(content) tpl = self.env.make_tpl_env(context) single_tpl = tpl.get_template(self.env.SINGLE_TPL) # Shallow copy "post" so that "content" is not added to bucket data = { "post": copy.copy(self.post), "prev": self.prev, "site": self.env.get_config() } data["post"]["content"] = markupsafe.Markup(typo_content) self.post.get('target').parent.mkdir(parents=True, exist_ok=True) with open(self.post.get('target'), "w", encoding="utf-8") as fout: fout.write(single_tpl.render(**data))
def test_ligature_variant(): with pytest.raises(ValueError): typographeur("", ligature_variant="unknown") with pytest.raises(ValueError): typographeur("", fix_ae=False, ligature_variant="unknown") with pytest.raises(ValueError): typographeur("", fix_oe=False, ligature_variant="unknown") try: typographeur("", fix_ae=False, fix_oe=False, ligature_variant="unknown") except ValueError: pytest.fail("Should not raise any exception")
def test_triple_question(input, expected): output = typographeur(input) assert output == expected
def test_nbsp(input, expected): output = typographeur(input, fix_nbsp=False) # spaces are replaced by insecable spaces, # insecable spaces are not replaced by ` ` assert output == expected
def test_double_quotes(): input = '"hello"' output = typographeur(input, fix_double_quote=False) assert output == input
def test_ellipsis(): input = 'hello...' output = typographeur(input, fix_ellipsis=False) assert output == input
def test_interrogation(): input = 'hello?' output = typographeur(input, fix_interrogation=False) assert output == input
def test_triple_point(input, expected): output = typographeur(input) assert output == expected
def test_parenthesis(input, expected): output = typographeur(input) assert output == expected
def test_dont_convert_html_attributes(input, expected): output = typographeur(input) assert output == expected
def test_semicolon(input, expected): output = typographeur(input) assert output == expected
def test_exclamation(input, expected): output = typographeur(input) assert output == expected
def test_full(): _input = open(join(root, 'examples/input.html')).read() expected = open(join(root, 'examples/expected.html')).read() output = typographeur(_input) assert output == expected
def test_ae(input): output = typographeur(input, fix_ae=False) assert output == input
def test_ae(input, expected): output = typographeur(input) assert output == expected
def test_auto_closed(input, expected): output = typographeur(input) assert output == expected
def test_exclamation(): input = 'hello!' output = typographeur(input, fix_exclamation=False) assert output == input
def test_skip_then_no_skip(input, expected): output = typographeur(input) assert output == expected
def test_semicolon(): input = 'hello;' output = typographeur(input, fix_semicolon=False) assert output == input
def test_skip_tags_option(options, input, expected): output = typographeur(input, skip_tags=options) assert output == expected, options
def test_parenthesis(): input = '( hello )' output = typographeur(input, fix_parenthesis=False) assert output == input
def test_skip_simple(input, expected): output = typographeur(input) assert output == expected
def test_comma_space(): input = 'hello ,' output = typographeur(input, fix_comma_space=False) assert output == input
def typographeur_func(s): """ Return the input string, typographée. """ return typographeur(s, fix_nbsp=False)
def test_apostrophes(): input = "l'éléphant" output = typographeur(input, fix_apostrophes=False) assert output == input
def test_title_points(input, expected): output = typographeur(input, fix_title_points=False) assert output == expected
def test_nuples(input, expected): output = typographeur(input, fix_nuples=False) assert output == expected
def test_heading_points(input, expected): output = typographeur(input) assert output == expected