diff options
author | Matthäus G. Chajdas <dev@anteru.net> | 2022-04-24 15:24:31 +0200 |
---|---|---|
committer | Matthäus G. Chajdas <dev@anteru.net> | 2022-04-24 15:24:31 +0200 |
commit | 94b4c6ba09b57882fefd1e02080cd76b12d226b5 (patch) | |
tree | c217e30a13cb292bce3c7eafeb814068eba529a0 /scripts | |
parent | 8ad1bea2a285b33778aa38eb274ddea9a6afc0b9 (diff) | |
download | pygments-git-94b4c6ba09b57882fefd1e02080cd76b12d226b5.tar.gz |
Add more CSS property names (fixes #2113).
This change also adds a script to regenerate the list of CSS properties
from the W3C source if needed.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/get_css_properties.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/scripts/get_css_properties.py b/scripts/get_css_properties.py new file mode 100644 index 00000000..3afe98e1 --- /dev/null +++ b/scripts/get_css_properties.py @@ -0,0 +1,33 @@ +""" + get_css_properties + ~~~~~~~~~~~~~~~~~~ + + :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + + +from pygments.util import format_lines +import json +import urllib.request + +HEADER = '''\ +""" + pygments.lexers._css_builtins + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + This file is autogenerated by scripts/get_css_properties.py + + :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" +''' + +if __name__ == "__main__": + data_request = urllib.request.urlopen('https://www.w3.org/Style/CSS/all-properties.en.json') + data = json.load(data_request) + names = set([p['property'] for p in data if p['property'] != '--*']) + + with open('../pygments/lexers/_css_builtins.py', 'w') as builtin_file: + builtin_file.write(HEADER) + builtin_file.write(format_lines('_css_properties', sorted(names))) |