mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-29 19:50:43 +12:00
This is the story of a guy who discovers enumerate.
This commit is contained in:
parent
d1c4633cee
commit
625b66ec74
|
@ -109,9 +109,9 @@ def loadStandardItemModelXML(mdl, xml, fromString=False):
|
||||||
#mdl.setHorizontalHeaderLabels(hLabels)
|
#mdl.setHorizontalHeaderLabels(hLabels)
|
||||||
|
|
||||||
# Populates with empty items
|
# Populates with empty items
|
||||||
for i in range(len(vLabels)):
|
for i in enumerate(vLabels):
|
||||||
row = []
|
row = []
|
||||||
for r in range(len(hLabels)):
|
for r in enumerate(hLabels):
|
||||||
row.append(QStandardItem())
|
row.append(QStandardItem())
|
||||||
mdl.appendRow(row)
|
mdl.appendRow(row)
|
||||||
|
|
||||||
|
|
|
@ -77,8 +77,8 @@ class persosProxyModel(QSortFilterProxyModel):
|
||||||
|
|
||||||
self._map = []
|
self._map = []
|
||||||
|
|
||||||
for i in range(len(self._cats)):
|
for i, cat in enumerate(self._cats):
|
||||||
self._map.append(self._cats[i])
|
self._map.append(cat)
|
||||||
|
|
||||||
for p in range(src.rowCount()):
|
for p in range(src.rowCount()):
|
||||||
item = src.item(p, Perso.importance.value)
|
item = src.item(p, Perso.importance.value)
|
||||||
|
|
|
@ -383,19 +383,20 @@ def linkifyAllRefs(text):
|
||||||
def basicT2TFormat(text, formatting=True, EOL=True, titles=True):
|
def basicT2TFormat(text, formatting=True, EOL=True, titles=True):
|
||||||
"A very basic t2t formatter to display notes and texts."
|
"A very basic t2t formatter to display notes and texts."
|
||||||
text = text.splitlines()
|
text = text.splitlines()
|
||||||
for n in range(len(text)):
|
for n, line in enumerate(text):
|
||||||
if formatting:
|
if formatting:
|
||||||
text[n] = re.sub("\*\*(.*?)\*\*", "<b>\\1</b>", text[n])
|
line = re.sub("\*\*(.*?)\*\*", "<b>\\1</b>", line)
|
||||||
text[n] = re.sub("//(.*?)//", "<i>\\1</i>", text[n])
|
line = re.sub("//(.*?)//", "<i>\\1</i>", line)
|
||||||
text[n] = re.sub("__(.*?)__", "<u>\\1</u>", text[n])
|
line = re.sub("__(.*?)__", "<u>\\1</u>", line)
|
||||||
|
|
||||||
if titles:
|
if titles:
|
||||||
for i in range(1, 6):
|
for i in range(1, 6):
|
||||||
r1 = '^\s*{s}([^=].*[^=]){s}\s*$'.format(s="=" * i)
|
r1 = '^\s*{s}([^=].*[^=]){s}\s*$'.format(s="=" * i)
|
||||||
r2 = '^\s*{s}([^\+].*[^\+]){s}\s*$'.format(s="\\+" * i)
|
r2 = '^\s*{s}([^\+].*[^\+]){s}\s*$'.format(s="\\+" * i)
|
||||||
t = "<h{n}>\\1</h{n}>".format(n=i)
|
t = "<h{n}>\\1</h{n}>".format(n=i)
|
||||||
text[n] = re.sub(r1, t, text[n])
|
line = re.sub(r1, t, line)
|
||||||
text[n] = re.sub(r2, t, text[n])
|
line = re.sub(r2, t, line)
|
||||||
|
text[n] = line
|
||||||
text = "\n".join(text)
|
text = "\n".join(text)
|
||||||
if EOL:
|
if EOL:
|
||||||
text = text.replace("\n", "<br>")
|
text = text.replace("\n", "<br>")
|
||||||
|
|
|
@ -230,12 +230,12 @@ def reformatText(text, markupArray):
|
||||||
rText = ""
|
rText = ""
|
||||||
markup = ["**", "//", "__", "--", "``", "''"]
|
markup = ["**", "//", "__", "--", "``", "''"]
|
||||||
|
|
||||||
for k in range(len(markupArray)):
|
for k, m in enumerate(markupArray):
|
||||||
m = markupArray[k]
|
#m = markupArray[k]
|
||||||
_open = False # Are we in an _openned markup
|
_open = False # Are we in an _openned markup
|
||||||
d = 0
|
d = 0
|
||||||
alreadySeen = []
|
alreadySeen = []
|
||||||
for i in range(len(text)):
|
for i, t in enumerate(text):
|
||||||
insert = False
|
insert = False
|
||||||
if not _open and m[i] == 1:
|
if not _open and m[i] == 1:
|
||||||
insert = True
|
insert = True
|
||||||
|
@ -253,23 +253,23 @@ def reformatText(text, markupArray):
|
||||||
alreadySeen.append(m[i])
|
alreadySeen.append(m[i])
|
||||||
if insert:
|
if insert:
|
||||||
rText += markup[k]
|
rText += markup[k]
|
||||||
for j in range(len(markupArray)):
|
for j, m2 in enumerate(markupArray):
|
||||||
# The other array still have the same length
|
# The other array still have the same length
|
||||||
if j > k:
|
if j > k:
|
||||||
#Insert 2 for bold, 3 for italic, etc.
|
#Insert 2 for bold, 3 for italic, etc.
|
||||||
markupArray[j].insert(i + d, k + 2)
|
m2.insert(i + d, k + 2)
|
||||||
markupArray[j].insert(i + d, k + 2)
|
m2.insert(i + d, k + 2)
|
||||||
alreadySeen = []
|
alreadySeen = []
|
||||||
d += 2
|
d += 2
|
||||||
rText += text[i]
|
rText += t
|
||||||
if _open:
|
if _open:
|
||||||
rText += markup[k]
|
rText += markup[k]
|
||||||
for j in range(len(markupArray)):
|
for j, m2 in enumerate(markupArray):
|
||||||
# The other array still have the same length
|
# The other array still have the same length
|
||||||
if j > k:
|
if j > k:
|
||||||
#Insert 2 for bold, 3 for italic, etc.
|
#Insert 2 for bold, 3 for italic, etc.
|
||||||
markupArray[j].insert(i + d, k + 2)
|
m2.insert(i + d, k + 2)
|
||||||
markupArray[j].insert(i + d, k + 2)
|
m2.insert(i + d, k + 2)
|
||||||
text = rText
|
text = rText
|
||||||
rText = ""
|
rText = ""
|
||||||
|
|
||||||
|
|
|
@ -154,8 +154,8 @@ class t2tHighlighter (basicHighlighter):
|
||||||
# Tables
|
# Tables
|
||||||
for lineState in [State.TABLE_LINE, State.TABLE_HEADER]:
|
for lineState in [State.TABLE_LINE, State.TABLE_HEADER]:
|
||||||
if state == lineState:
|
if state == lineState:
|
||||||
for i in range(len(text)):
|
for i, t in enumerate(text):
|
||||||
if text[i] == "|":
|
if t == "|":
|
||||||
self.setFormat(i, 1, op)
|
self.setFormat(i, 1, op)
|
||||||
else:
|
else:
|
||||||
self.setFormat(i, 1, self.style.format(lineState))
|
self.setFormat(i, 1, self.style.format(lineState))
|
||||||
|
@ -273,7 +273,7 @@ class t2tHighlighter (basicHighlighter):
|
||||||
pos = r.indexIn(text, pos + 1)
|
pos = r.indexIn(text, pos + 1)
|
||||||
|
|
||||||
# Bold, Italic, Underline, Code, Tagged, Strikeout
|
# Bold, Italic, Underline, Code, Tagged, Strikeout
|
||||||
for i in range(len(text)):
|
for i, t in enumerate(text):
|
||||||
f = self.format(i)
|
f = self.format(i)
|
||||||
beautifiers = [k[i] for k in formatArray]
|
beautifiers = [k[i] for k in formatArray]
|
||||||
self.setFormat(i, 1, self.style.beautifyFormat(f, beautifiers))
|
self.setFormat(i, 1, self.style.beautifyFormat(f, beautifiers))
|
||||||
|
|
|
@ -148,7 +148,7 @@ class revisions(QWidget, Ui_revisions):
|
||||||
diff = [d for d in diff if d and not d[:2] == "? "]
|
diff = [d for d in diff if d and not d[:2] == "? "]
|
||||||
mydiff = ""
|
mydiff = ""
|
||||||
skip = False
|
skip = False
|
||||||
for n in range(len(diff)):
|
for n, l in enumerate(diff):
|
||||||
l = diff[n]
|
l = diff[n]
|
||||||
op = l[:2]
|
op = l[:2]
|
||||||
txt = l[2:]
|
txt = l[2:]
|
||||||
|
|
Loading…
Reference in a new issue