Merge pull request #123 from Dpeta/alternian
Add alternian font tags (<alt></alt>)
This commit is contained in:
commit
829d981424
7 changed files with 58 additions and 21 deletions
32
dataobjs.py
32
dataobjs.py
|
@ -1,4 +1,8 @@
|
||||||
|
import re
|
||||||
|
import random
|
||||||
|
import itertools
|
||||||
import logging
|
import logging
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
PchumLog = logging.getLogger("pchumLogger")
|
PchumLog = logging.getLogger("pchumLogger")
|
||||||
try:
|
try:
|
||||||
|
@ -6,9 +10,6 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("PyQt5 fallback (dataobjs.py)")
|
print("PyQt5 fallback (dataobjs.py)")
|
||||||
from PyQt5 import QtGui
|
from PyQt5 import QtGui
|
||||||
from datetime import datetime
|
|
||||||
import re
|
|
||||||
import random
|
|
||||||
|
|
||||||
from mood import Mood
|
from mood import Mood
|
||||||
from parsetools import (
|
from parsetools import (
|
||||||
|
@ -31,6 +32,7 @@ _ctagre = re.compile("(</?c=?.*?>)", re.I)
|
||||||
_smilere = re.compile("|".join(list(smiledict.keys())))
|
_smilere = re.compile("|".join(list(smiledict.keys())))
|
||||||
_memore = re.compile(r"(\s|^)(#[A-Za-z0-9_]+)")
|
_memore = re.compile(r"(\s|^)(#[A-Za-z0-9_]+)")
|
||||||
_handlere = re.compile(r"(\s|^)(@[A-Za-z0-9_]+)")
|
_handlere = re.compile(r"(\s|^)(@[A-Za-z0-9_]+)")
|
||||||
|
_alternian = re.compile(r"<alt>.*?</alt>")
|
||||||
|
|
||||||
|
|
||||||
class pesterQuirk:
|
class pesterQuirk:
|
||||||
|
@ -167,20 +169,18 @@ class pesterQuirks:
|
||||||
if checkstate == 2:
|
if checkstate == 2:
|
||||||
# Check for substring that should be excluded.
|
# Check for substring that should be excluded.
|
||||||
excludes = []
|
excludes = []
|
||||||
# Check for links, store in list.
|
# Return matches for links, smilies, handles, memos.
|
||||||
for match in re.finditer(_urlre, string):
|
# Chain the iterators and add to excludes list.
|
||||||
excludes.append(match)
|
matches = itertools.chain(
|
||||||
# Check for smilies, store in list.
|
re.finditer(_urlre, string),
|
||||||
for match in re.finditer(_smilere, string):
|
re.finditer(_smilere, string),
|
||||||
excludes.append(match)
|
re.finditer(_handlere, string),
|
||||||
# Check for @handles, store in list.
|
re.finditer(_memore, string),
|
||||||
for match in re.finditer(_handlere, string):
|
re.finditer(_alternian, string),
|
||||||
excludes.append(match)
|
)
|
||||||
# Check for #memos, store in list.
|
excludes.extend(matches)
|
||||||
for match in re.finditer(_memore, string):
|
|
||||||
excludes.append(match)
|
|
||||||
|
|
||||||
if len(excludes) >= 1:
|
if excludes:
|
||||||
# SORT !!!
|
# SORT !!!
|
||||||
excludes.sort(key=lambda exclude: exclude.start())
|
excludes.sort(key=lambda exclude: exclude.start())
|
||||||
# Recursion check.
|
# Recursion check.
|
||||||
|
|
BIN
fonts/alternian/AllisDaedric-VYWz.otf
Normal file
BIN
fonts/alternian/AllisDaedric-VYWz.otf
Normal file
Binary file not shown.
2
fonts/alternian/info.txt
Normal file
2
fonts/alternian/info.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
license: Public Domain
|
||||||
|
link: https://www.fontspace.com/allis-daedric-font-f20263
|
|
@ -40,6 +40,8 @@ _oocre = re.compile(r"([\[(\{])\1.*([\])\}])\2")
|
||||||
# _format_end = re.compile(r"(?i)</([ibu])>")
|
# _format_end = re.compile(r"(?i)</([ibu])>")
|
||||||
_honk = re.compile(r"(?i)\bhonk\b")
|
_honk = re.compile(r"(?i)\bhonk\b")
|
||||||
_groupre = re.compile(r"\\([0-9]+)")
|
_groupre = re.compile(r"\\([0-9]+)")
|
||||||
|
_alternian_begin = re.compile(r"<alt>") # Matches get set to alternian font
|
||||||
|
_alternian_end = re.compile(r"</alt>")
|
||||||
|
|
||||||
quirkloader = ScriptQuirks()
|
quirkloader = ScriptQuirks()
|
||||||
_functionre = None
|
_functionre = None
|
||||||
|
@ -169,9 +171,9 @@ class hyperlink(lexercon.Chunk):
|
||||||
|
|
||||||
def convert(self, format):
|
def convert(self, format):
|
||||||
if format == "html":
|
if format == "html":
|
||||||
return "<a href='{}'>{}</a>".format(self.string, self.string)
|
return f"<a href='{self.string}'>{self.string}</a>"
|
||||||
elif format == "bbcode":
|
elif format == "bbcode":
|
||||||
return "[url]%s[/url]" % (self.string)
|
return f"[url]{self.string}[/url]"
|
||||||
else:
|
else:
|
||||||
return self.string
|
return self.string
|
||||||
|
|
||||||
|
@ -184,6 +186,30 @@ class hyperlink_lazy(hyperlink):
|
||||||
self.string = "http://" + string
|
self.string = "http://" + string
|
||||||
|
|
||||||
|
|
||||||
|
class alternianTagBegin(lexercon.Chunk):
|
||||||
|
def __init__(self, string):
|
||||||
|
self.string = string
|
||||||
|
|
||||||
|
def convert(self, format):
|
||||||
|
if format == "html":
|
||||||
|
return "<em style=\"font-family:'AllisDaedric'\">"
|
||||||
|
elif format == "text":
|
||||||
|
return ""
|
||||||
|
return self.string
|
||||||
|
|
||||||
|
|
||||||
|
class alternianTagEnd(lexercon.Chunk):
|
||||||
|
def __init__(self, string):
|
||||||
|
self.string = string
|
||||||
|
|
||||||
|
def convert(self, format):
|
||||||
|
if format == "html":
|
||||||
|
return "</em>"
|
||||||
|
elif format == "text":
|
||||||
|
return ""
|
||||||
|
return self.string
|
||||||
|
|
||||||
|
|
||||||
class imagelink(lexercon.Chunk):
|
class imagelink(lexercon.Chunk):
|
||||||
def __init__(self, string, img):
|
def __init__(self, string, img):
|
||||||
self.string = string
|
self.string = string
|
||||||
|
@ -285,6 +311,8 @@ def kxlexMsg(msg: str):
|
||||||
def lexMessage(string: str):
|
def lexMessage(string: str):
|
||||||
lexlist = [
|
lexlist = [
|
||||||
(mecmd, _mecmdre),
|
(mecmd, _mecmdre),
|
||||||
|
(alternianTagBegin, _alternian_begin),
|
||||||
|
(alternianTagEnd, _alternian_end),
|
||||||
(colorBegin, _ctag_begin),
|
(colorBegin, _ctag_begin),
|
||||||
# (colorBegin, _gtag_begin),
|
# (colorBegin, _gtag_begin),
|
||||||
(colorEnd, _ctag_end),
|
(colorEnd, _ctag_end),
|
||||||
|
|
|
@ -1653,9 +1653,10 @@ class PesterWindow(MovingWindow):
|
||||||
if not self.config.defaultprofile():
|
if not self.config.defaultprofile():
|
||||||
self.changeProfile()
|
self.changeProfile()
|
||||||
|
|
||||||
# Fuck you some more OSX leopard! >:(
|
# Load font
|
||||||
# if not ostools.isOSXLeopard():
|
QtGui.QFontDatabase.addApplicationFont(
|
||||||
# QtCore.QTimer.singleShot(1000, self.mspacheck)
|
os.path.join("fonts", "alternian", "AllisDaedric-VYWz.otf")
|
||||||
|
)
|
||||||
|
|
||||||
self.pcUpdate[str, str].connect(self.updateMsg)
|
self.pcUpdate[str, str].connect(self.updateMsg)
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ add_data = [
|
||||||
"smilies;smilies",
|
"smilies;smilies",
|
||||||
"themes;themes",
|
"themes;themes",
|
||||||
"docs;docs",
|
"docs;docs",
|
||||||
|
"fonts;fonts",
|
||||||
"README.md;.",
|
"README.md;.",
|
||||||
"LICENSE;.",
|
"LICENSE;.",
|
||||||
"CHANGELOG.md;.",
|
"CHANGELOG.md;.",
|
||||||
|
@ -28,6 +29,7 @@ data_folders = {
|
||||||
"smilies": "smilies",
|
"smilies": "smilies",
|
||||||
"themes": "themes",
|
"themes": "themes",
|
||||||
"docs": "docs",
|
"docs": "docs",
|
||||||
|
"fonts": "fonts",
|
||||||
}
|
}
|
||||||
data_files = {
|
data_files = {
|
||||||
"README.md": "README.md.txt",
|
"README.md": "README.md.txt",
|
||||||
|
|
|
@ -56,6 +56,8 @@ def rainbow(text):
|
||||||
re.finditer(_smilere, text),
|
re.finditer(_smilere, text),
|
||||||
re.finditer(_memore, text),
|
re.finditer(_memore, text),
|
||||||
re.finditer(_handlere, text),
|
re.finditer(_handlere, text),
|
||||||
|
re.finditer(_alternian_begin, text),
|
||||||
|
re.finditer(_alternian_end, text),
|
||||||
)
|
)
|
||||||
for match in match_chain:
|
for match in match_chain:
|
||||||
for color_and_position in colors_and_positions:
|
for color_and_position in colors_and_positions:
|
||||||
|
@ -161,3 +163,5 @@ _smilere = re.compile("|".join(list(smiledict.keys())))
|
||||||
_urlre = re.compile(r"(?i)(?:^|(?<=\s))(?:(?:https?|ftp)://|magnet:)[^\s]+")
|
_urlre = re.compile(r"(?i)(?:^|(?<=\s))(?:(?:https?|ftp)://|magnet:)[^\s]+")
|
||||||
_memore = re.compile(r"(\s|^)(#[A-Za-z0-9_]+)")
|
_memore = re.compile(r"(\s|^)(#[A-Za-z0-9_]+)")
|
||||||
_handlere = re.compile(r"(\s|^)(@[A-Za-z0-9_]+)")
|
_handlere = re.compile(r"(\s|^)(@[A-Za-z0-9_]+)")
|
||||||
|
_alternian_begin = re.compile(r"<alt>") # Matches get set to alternian font
|
||||||
|
_alternian_end = re.compile(r"</alt>")
|
||||||
|
|
Loading…
Reference in a new issue