diff --git a/spip2md/iterator.py b/spip2md/articles.py similarity index 89% rename from spip2md/iterator.py rename to spip2md/articles.py index dd4f606..672378d 100644 --- a/spip2md/iterator.py +++ b/spip2md/articles.py @@ -92,23 +92,6 @@ class Article: return errors -def highlightUnknownChars(text): - # Define terminal escape sequences to stylize output, regex escaped - COLOR = "\033[91m" + "\033[1m" # Red + Bold - RESET = "\033[0m" - # Highlight in COLOR unknown chars in text - for char in unknownIso: - for match in finditer(char, text): - text = ( - text[: match.start()] - + COLOR - + match.group() - + RESET - + text[match.end() :] - ) - return text - - class Articles: exported: int = 0 diff --git a/spip2md/converter.py b/spip2md/converter.py index 69214a5..cec63b8 100644 --- a/spip2md/converter.py +++ b/spip2md/converter.py @@ -1,4 +1,4 @@ -from re import I, S, compile +from re import I, S, compile, finditer # SPIP syntax to Markdown spipToMarkdown = ( @@ -274,3 +274,19 @@ def convertMeta(spipMeta): for iso, utf in isoToUtf: text.replace(iso, utf) return text + +def highlightUnknownChars(text): + # Define terminal escape sequences to stylize output, regex escaped + COLOR = "\033[91m" + "\033[1m" # Red + Bold + RESET = "\033[0m" + # Highlight in COLOR unknown chars in text + for char in unknownIso: + for match in finditer(char, text): + text = ( + text[: match.start()] + + COLOR + + match.group() + + RESET + + text[match.end() :] + ) + return text diff --git a/spip2md/main.py b/spip2md/main.py index 2c31beb..cc108af 100755 --- a/spip2md/main.py +++ b/spip2md/main.py @@ -1,7 +1,8 @@ #!python from config import config from database import db -from iterator import Articles, highlightUnknownChars +from articles import Articles +from converter import highlightUnknownChars if __name__ != "__main__": exit()