helpers.prettify()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nop 1
1
from re import sub
2
3
from .illustrations.illustration import Illustration  # type: ignore
4
from .questions.helpers import format_latex_as_wikitext  # type: ignore
5
from .quiz_element import QuizElement  # type: ignore
6
from .illustrations.state_of_illustrations import StateOfIllustrations  # type: ignore
7
from .questions.question import Question  # type: ignore
8
from .questions.question_types import QuestionType  # type: ignore
9
10
11
def prettify(text: str) -> str:
12
    text = strip_whitespaces(text)
13
    text = format_latex_as_wikitext(text)
14
    return text
15
16
17
def strip_whitespaces(text: str) -> str:
18
    text = text.strip("., \n")
19
    text = sub(r" \n|\r\n|\s{2}", " ", text)
20
    return text
21