Add text alignment tags
This commit is contained in:
+26
-1
@@ -436,6 +436,31 @@ class Tokenizer():
|
|||||||
# Skip all body text
|
# Skip all body text
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Check Alignment
|
||||||
|
tagLeft = False
|
||||||
|
tagRight = False
|
||||||
|
if aLine.startswith(">>"):
|
||||||
|
tagRight = True
|
||||||
|
aLine = aLine[2:].lstrip()
|
||||||
|
elif aLine.startswith(">>"):
|
||||||
|
tagRight = True
|
||||||
|
aLine = aLine[8:].lstrip()
|
||||||
|
|
||||||
|
if aLine.endswith("<<"):
|
||||||
|
tagLeft = True
|
||||||
|
aLine = aLine[:-2].rstrip()
|
||||||
|
elif aLine.endswith("<<"):
|
||||||
|
tagLeft = True
|
||||||
|
aLine = aLine[:-8].rstrip()
|
||||||
|
|
||||||
|
textAlign = self.A_NONE
|
||||||
|
if tagLeft and tagRight:
|
||||||
|
textAlign = self.A_CENTRE
|
||||||
|
elif tagLeft:
|
||||||
|
textAlign = self.A_LEFT
|
||||||
|
elif tagRight:
|
||||||
|
textAlign = self.A_RIGHT
|
||||||
|
|
||||||
# Otherwise we use RegEx to find formatting tags within a line of text
|
# Otherwise we use RegEx to find formatting tags within a line of text
|
||||||
fmtPos = []
|
fmtPos = []
|
||||||
for theRX, theKeys in rxFormats:
|
for theRX, theKeys in rxFormats:
|
||||||
@@ -452,7 +477,7 @@ class Tokenizer():
|
|||||||
# sorted by position
|
# sorted by position
|
||||||
fmtPos = sorted(fmtPos, key=itemgetter(0))
|
fmtPos = sorted(fmtPos, key=itemgetter(0))
|
||||||
self.theTokens.append((
|
self.theTokens.append((
|
||||||
self.T_TEXT, nLine, aLine, fmtPos, self.A_NONE
|
self.T_TEXT, nLine, aLine, fmtPos, textAlign
|
||||||
))
|
))
|
||||||
if self.keepMarkdown:
|
if self.keepMarkdown:
|
||||||
tmpMarkdown.append("%s\n" % aLine)
|
tmpMarkdown.append("%s\n" % aLine)
|
||||||
|
|||||||
@@ -198,6 +198,13 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
|||||||
}
|
}
|
||||||
))
|
))
|
||||||
|
|
||||||
|
# Alignment Tags
|
||||||
|
self.hRules.append((
|
||||||
|
r"(^>{1,2}|<{1,2}$)", {
|
||||||
|
1 : self.hStyles["hidden"],
|
||||||
|
}
|
||||||
|
))
|
||||||
|
|
||||||
# Auto-Replace Tags
|
# Auto-Replace Tags
|
||||||
self.hRules.append((
|
self.hRules.append((
|
||||||
r"<(\S+?)>", {
|
r"<(\S+?)>", {
|
||||||
|
|||||||
@@ -24,3 +24,13 @@ Thin spaces and thin non-breaking spaces are also supported from the Insert menu
|
|||||||
If you need to split a scene file up into further pieces, you can do so with the level four heading, like above. This is referred to as a section.
|
If you need to split a scene file up into further pieces, you can do so with the level four heading, like above. This is referred to as a section.
|
||||||
|
|
||||||
Both scene and section titles can be left out of the final exported document. The formatting of titles can be selected from the Build Novel Project dialog. You can also have them replaced with scene separators like “* * *”.
|
Both scene and section titles can be left out of the final exported document. The formatting of titles can be selected from the Build Novel Project dialog. You can also have them replaced with scene separators like “* * *”.
|
||||||
|
|
||||||
|
#### Text Alignment
|
||||||
|
|
||||||
|
The text by default will have the left or justified alignment. You can also specify alignment for a specific paragraph by “pushing” it away from an edge with a set of ‘>>’ or ‘<<’ symbols, like so:
|
||||||
|
|
||||||
|
This text is left-aligned. <<
|
||||||
|
|
||||||
|
>> This text is right-aligned.
|
||||||
|
|
||||||
|
>> This text is centred. <<
|
||||||
+11
-11
@@ -1,13 +1,13 @@
|
|||||||
<?xml version='1.0' encoding='utf-8'?>
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
<novelWriterXML appVersion="1.3.2" hexVersion="0x010302f0" fileVersion="1.2" timeStamp="2021-05-30 12:14:18">
|
<novelWriterXML appVersion="1.4a0" hexVersion="0x010400a0" fileVersion="1.2" timeStamp="2021-06-09 22:06:41">
|
||||||
<project>
|
<project>
|
||||||
<name>Sample Project</name>
|
<name>Sample Project</name>
|
||||||
<title>Sample Project</title>
|
<title>Sample Project</title>
|
||||||
<author>Jane Smith</author>
|
<author>Jane Smith</author>
|
||||||
<author>Jay Doh</author>
|
<author>Jay Doh</author>
|
||||||
<saveCount>1062</saveCount>
|
<saveCount>1083</saveCount>
|
||||||
<autoCount>166</autoCount>
|
<autoCount>172</autoCount>
|
||||||
<editTime>49870</editTime>
|
<editTime>50790</editTime>
|
||||||
</project>
|
</project>
|
||||||
<settings>
|
<settings>
|
||||||
<doBackup>False</doBackup>
|
<doBackup>False</doBackup>
|
||||||
@@ -17,8 +17,8 @@
|
|||||||
<autoOutline>True</autoOutline>
|
<autoOutline>True</autoOutline>
|
||||||
<lastEdited>636b6aa9b697b</lastEdited>
|
<lastEdited>636b6aa9b697b</lastEdited>
|
||||||
<lastViewed>636b6aa9b697b</lastViewed>
|
<lastViewed>636b6aa9b697b</lastViewed>
|
||||||
<lastWordCount>1077</lastWordCount>
|
<lastWordCount>1132</lastWordCount>
|
||||||
<novelWordCount>701</novelWordCount>
|
<novelWordCount>756</novelWordCount>
|
||||||
<notesWordCount>376</notesWordCount>
|
<notesWordCount>376</notesWordCount>
|
||||||
<autoReplace>
|
<autoReplace>
|
||||||
<entry key="A">B</entry>
|
<entry key="A">B</entry>
|
||||||
@@ -118,10 +118,10 @@
|
|||||||
<status>1st Draft</status>
|
<status>1st Draft</status>
|
||||||
<exported>True</exported>
|
<exported>True</exported>
|
||||||
<layout>SCENE</layout>
|
<layout>SCENE</layout>
|
||||||
<charCount>1810</charCount>
|
<charCount>2107</charCount>
|
||||||
<wordCount>318</wordCount>
|
<wordCount>373</wordCount>
|
||||||
<paraCount>8</paraCount>
|
<paraCount>12</paraCount>
|
||||||
<cursorPos>1505</cursorPos>
|
<cursorPos>2049</cursorPos>
|
||||||
</item>
|
</item>
|
||||||
<item handle="bc0cbd2a407f3" order="2" parent="e7ded148d6e4a">
|
<item handle="bc0cbd2a407f3" order="2" parent="e7ded148d6e4a">
|
||||||
<name>Another Scene</name>
|
<name>Another Scene</name>
|
||||||
@@ -145,7 +145,7 @@
|
|||||||
<charCount>633</charCount>
|
<charCount>633</charCount>
|
||||||
<wordCount>101</wordCount>
|
<wordCount>101</wordCount>
|
||||||
<paraCount>3</paraCount>
|
<paraCount>3</paraCount>
|
||||||
<cursorPos>0</cursorPos>
|
<cursorPos>308</cursorPos>
|
||||||
</item>
|
</item>
|
||||||
<item handle="96b68994dfa3d" order="4" parent="e7ded148d6e4a">
|
<item handle="96b68994dfa3d" order="4" parent="e7ded148d6e4a">
|
||||||
<name>A Note on Structure</name>
|
<name>A Note on Structure</name>
|
||||||
|
|||||||
Reference in New Issue
Block a user