Skip to content

Commit

Permalink
Change rules of quotes replacement for the 'typographer' module
Browse files Browse the repository at this point in the history
See https://t.me/kozaloru/165 for more information.
  • Loading branch information
kozalosev committed Nov 10, 2018
1 parent d660be9 commit 8c3d294
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/strconv/typographer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

class TypographerConverter(TextProcessor):
replacements = [
(r"\"(.*)\"", r"«\1»"),
("<<", "«"),
(">>", "»"),
("!=", "≠"),
("~=", "≈"),
("<=", "≤"),
Expand Down
5 changes: 3 additions & 2 deletions tests/test_strconv/test_typographer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ def converter() -> TypographerConverter:

def test_matcher(converter):
assert not converter.can_process("hello world")
assert converter.can_process('Leonid "SadBot" Kozarin')
assert not converter.can_process('Leonid "SadBot" Kozarin')
assert converter.can_process('Leonid <<SadBot>> Kozarin')
assert converter.can_process("C++ != C#")
assert converter.can_process("Java ~= C#")
assert converter.can_process("Java <= Kotlin")
Expand All @@ -20,7 +21,7 @@ def test_matcher(converter):


def test_converter(converter):
assert converter.process('Leonid "SadBot" Kozarin') == "Leonid «SadBot» Kozarin"
assert converter.process('Leonid <<SadBot>> Kozarin') == "Leonid «SadBot» Kozarin"
assert converter.process("C++ != C#") == "C++ ≠ C#"
assert converter.process("Java ~= C#") == "Java ≈ C#"
assert converter.process("Java <= Kotlin") == "Java ≤ Kotlin"
Expand Down

0 comments on commit 8c3d294

Please sign in to comment.