mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
GPM Templates: allow comments to start in any column, not just the first.
This commit is contained in:
parent
bb64863046
commit
3fc1bc2c2c
@ -293,7 +293,7 @@ Notes:
|
|||||||
* In a logical context, any non-empty value is ``True``
|
* In a logical context, any non-empty value is ``True``
|
||||||
* In a logical context, the empty value is ``False``
|
* In a logical context, the empty value is ``False``
|
||||||
* Strings and numbers can be used interchangeably. For example, ``10`` and ``'10'`` are the same thing.
|
* Strings and numbers can be used interchangeably. For example, ``10`` and ``'10'`` are the same thing.
|
||||||
* Comments are lines starting with a '#' character. Comments beginning later in a line are not supported.
|
* Comments are lines starting with blanks or tabs then a '#' character.
|
||||||
|
|
||||||
**Operator precedence**
|
**Operator precedence**
|
||||||
|
|
||||||
|
@ -348,7 +348,9 @@ class TemplateHighlighter(QSyntaxHighlighter):
|
|||||||
|
|
||||||
if not text:
|
if not text:
|
||||||
pass
|
pass
|
||||||
elif text[0] == '#':
|
elif re.match(r'[ \t]*#', text):
|
||||||
|
# Line with only a comment possibly preceded with spaces or tabs
|
||||||
|
# This works in both GPM and python
|
||||||
self.setFormat(0, textLength, self.Formats['comment'])
|
self.setFormat(0, textLength, self.Formats['comment'])
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -1715,7 +1715,7 @@ class TemplateFormatter(string.Formatter):
|
|||||||
(r'\w+', lambda x,t: (_Parser.LEX_ID, t)),
|
(r'\w+', lambda x,t: (_Parser.LEX_ID, t)),
|
||||||
(r'".*?((?<!\\)")', lambda x,t: (_Parser.LEX_CONST, t[1:-1])),
|
(r'".*?((?<!\\)")', lambda x,t: (_Parser.LEX_CONST, t[1:-1])),
|
||||||
(r'\'.*?((?<!\\)\')', lambda x,t: (_Parser.LEX_CONST, t[1:-1])),
|
(r'\'.*?((?<!\\)\')', lambda x,t: (_Parser.LEX_CONST, t[1:-1])),
|
||||||
(r'\n#.*?(?:(?=\n)|$)', lambda x,t: _Parser.LEX_NEWLINE),
|
(r'\n[ \t]*#.*?(?:(?=\n)|$)',lambda x,t: _Parser.LEX_NEWLINE),
|
||||||
(r'\s', lambda x,t: _Parser.LEX_NEWLINE if t == '\n' else None),
|
(r'\s', lambda x,t: _Parser.LEX_NEWLINE if t == '\n' else None),
|
||||||
], flags=re.DOTALL)
|
], flags=re.DOTALL)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user