예제 #1
0
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"
예제 #2
0
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
예제 #3
0
 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))
예제 #4
0
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")
예제 #5
0
def test_triple_question(input, expected):
    output = typographeur(input)
    assert output == expected
예제 #6
0
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
예제 #7
0
def test_double_quotes():
    input = '"hello"'
    output = typographeur(input, fix_double_quote=False)
    assert output == input
예제 #8
0
def test_ellipsis():
    input = 'hello...'
    output = typographeur(input, fix_ellipsis=False)
    assert output == input
예제 #9
0
def test_interrogation():
    input = 'hello?'
    output = typographeur(input, fix_interrogation=False)
    assert output == input
예제 #10
0
def test_triple_point(input, expected):
    output = typographeur(input)
    assert output == expected
예제 #11
0
def test_parenthesis(input, expected):
    output = typographeur(input)
    assert output == expected
예제 #12
0
def test_dont_convert_html_attributes(input, expected):
    output = typographeur(input)
    assert output == expected
예제 #13
0
def test_semicolon(input, expected):
    output = typographeur(input)
    assert output == expected
예제 #14
0
def test_exclamation(input, expected):
    output = typographeur(input)
    assert output == expected
예제 #15
0
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
예제 #16
0
def test_ae(input):
    output = typographeur(input, fix_ae=False)
    assert output == input
예제 #17
0
def test_ae(input, expected):
    output = typographeur(input)
    assert output == expected
예제 #18
0
def test_auto_closed(input, expected):
    output = typographeur(input)
    assert output == expected
예제 #19
0
def test_exclamation():
    input = 'hello!'
    output = typographeur(input, fix_exclamation=False)
    assert output == input
예제 #20
0
def test_skip_then_no_skip(input, expected):
    output = typographeur(input)
    assert output == expected
예제 #21
0
def test_semicolon():
    input = 'hello;'
    output = typographeur(input, fix_semicolon=False)
    assert output == input
예제 #22
0
def test_skip_tags_option(options, input, expected):
    output = typographeur(input, skip_tags=options)
    assert output == expected, options
예제 #23
0
def test_parenthesis():
    input = '( hello )'
    output = typographeur(input, fix_parenthesis=False)
    assert output == input
예제 #24
0
def test_skip_simple(input, expected):
    output = typographeur(input)
    assert output == expected
예제 #25
0
def test_comma_space():
    input = 'hello ,'
    output = typographeur(input, fix_comma_space=False)
    assert output == input
예제 #26
0
def typographeur_func(s):
    """
    Return the input string, typographée.
    """
    return typographeur(s, fix_nbsp=False)
예제 #27
0
def test_apostrophes():
    input = "l'éléphant"
    output = typographeur(input, fix_apostrophes=False)
    assert output == input
예제 #28
0
def test_title_points(input, expected):
    output = typographeur(input, fix_title_points=False)
    assert output == expected
예제 #29
0
def test_nuples(input, expected):
    output = typographeur(input, fix_nuples=False)
    assert output == expected
예제 #30
0
def test_heading_points(input, expected):
    output = typographeur(input)
    assert output == expected