refactor
This commit is contained in:
parent
1076040316
commit
869714f926
@ -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
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user