1
0
mirror of https://github.com/gryf/python-syntax.git synced 2025-12-17 11:30:27 +01:00

Added support for str.format syntax

This commit is contained in:
Dmitry Vasiliev
2008-09-21 20:10:51 +04:00
parent ed21c2f0b0
commit 07c654e70d
3 changed files with 19 additions and 7 deletions

View File

@@ -11,6 +11,8 @@ Revision 2.6.1 (unknown):
- Added support for new integer literal syntax "0o" and "0b"; - Added support for new integer literal syntax "0o" and "0b";
- Added support for string.Template syntax controlled by - Added support for string.Template syntax controlled by
"python_highlight_string_templates" option; "python_highlight_string_templates" option;
- Added support for str.format syntax controlled by
"python_highlight_string_format" option;
Revision 2.5.6 (2007-02-04): Revision 2.5.6 (2007-02-04):

View File

@@ -1,8 +1,6 @@
Now Now
=== ===
- Python 3.0 string formatting
Later Later
===== =====

View File

@@ -37,7 +37,10 @@
" For highlight string formatting: " For highlight string formatting:
" python_highlight_string_formatting " python_highlight_string_formatting
" "
" For highlight string.Template templates: " For highlight str.format syntax:
" python_highlight_string_format
"
" For highlight string.Template syntax:
" python_highlight_string_templates " python_highlight_string_templates
" "
" For highlight indentation errors: " For highlight indentation errors:
@@ -78,6 +81,9 @@ if exists("python_highlight_all") && python_highlight_all != 0
if !exists("python_highlight_string_formatting") if !exists("python_highlight_string_formatting")
let python_highlight_string_formatting = 1 let python_highlight_string_formatting = 1
endif endif
if !exists("python_highlight_string_format")
let python_highlight_string_format = 1
endif
if !exists("python_highlight_string_templates") if !exists("python_highlight_string_templates")
let python_highlight_string_templates = 1 let python_highlight_string_templates = 1
endif endif
@@ -182,8 +188,13 @@ syn match pythonUniRawEscapeError "\([^\\]\(\\\\\)*\)\@<=\\u\x\{,3}\X" display
if exists("python_highlight_string_formatting") && python_highlight_string_formatting != 0 if exists("python_highlight_string_formatting") && python_highlight_string_formatting != 0
" String formatting " String formatting
syn match pythonStrFormat "%\(([^)]\+)\)\=[-#0 +]*\d*\(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString syn match pythonStrFormatting "%\(([^)]\+)\)\=[-#0 +]*\d*\(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
syn match pythonStrFormat "%[-#0 +]*\(\*\|\d\+\)\=\(\.\(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString syn match pythonStrFormatting "%[-#0 +]*\(\*\|\d\+\)\=\(\.\(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
endif
if exists("python_highlight_string_format") && python_highlight_string_format != 0
" str.format syntax
syn match pythonStrFormat "{\([a-zA-Z_][a-zA-Z0-9_]*\|\d\+\)\(\.[a-zA-Z_][a-zA-Z0-9_]*\|\[\(\d\+\|[^!:\}]\+\)\]\)*\(![rs]\)\=\(:\({\([a-zA-Z_][a-zA-Z0-9_]*\|\d\+\)}\|\([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*\(\.\d\+\)\=[bcdeEfFgGnoxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
endif endif
if exists("python_highlight_string_templates") && python_highlight_string_templates != 0 if exists("python_highlight_string_templates") && python_highlight_string_templates != 0
@@ -311,8 +322,9 @@ if version >= 508 || !exists("did_python_syn_inits")
HiLink pythonUniRawEscape Special HiLink pythonUniRawEscape Special
HiLink pythonUniRawEscapeError Error HiLink pythonUniRawEscapeError Error
HiLink pythonStrFormat Special HiLink pythonStrFormatting Special
HiLink pythonStrTemplate Special HiLink pythonStrFormat Special
HiLink pythonStrTemplate Special
HiLink pythonDocTest Special HiLink pythonDocTest Special
HiLink pythonDocTest2 Special HiLink pythonDocTest2 Special