diff options
author | Philip Chimento <philip.chimento@gmail.com> | 2017-05-07 20:26:36 -0700 |
---|---|---|
committer | rockon999 <rockon999@users.noreply.github.com> | 2018-08-06 02:53:46 -0500 |
commit | 13635f61c8c22d33832f3e88a0d1d728a7c748b3 (patch) | |
tree | 633aa8f42bae0d74302a50a46239813fb150a154 /giscanner/docwriter.py | |
parent | fc39530d66d921331ced5a0b6607e9106c8d1647 (diff) | |
download | gobject-introspection-13635f61c8c22d33832f3e88a0d1d728a7c748b3.tar.gz |
docwriter: Handle unknown language MIME types
Add "plain" -> "text/plain" to the mapping since "plain" is used several
times in the GTK documentation. But also, fix the code that falls back to
no syntax highlighting for an unknown language - it did not check for
KeyError.
Diffstat (limited to 'giscanner/docwriter.py')
-rw-r--r-- | giscanner/docwriter.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/giscanner/docwriter.py b/giscanner/docwriter.py index 754787e3..6b14f72b 100644 --- a/giscanner/docwriter.py +++ b/giscanner/docwriter.py @@ -57,6 +57,7 @@ language_mimes = { "pascal": "text/x-pascal", "perl": "application/x-perl", "php": "application/x-php", + "plain": "text/plain", "python": "text/x-python", "ruby": "application/x-ruby", "sql": "text/x-sql", @@ -359,11 +360,12 @@ class DocFormatter(object): return '</p><pre>\n ' def _process_code_start_with_language(self, node, match, props): - mime = language_mimes[props["language_name"].lower()] self._processing_code = True - if not mime: + try: + mime = language_mimes[props["language_name"].lower()] + return '</p><pre data-mime="' + mime + '">\n ' + except KeyError: return '</p><pre>\n ' - return '</p><pre data-mime="' + mime + '">\n ' def _process_code_end(self, node, match, props): self._processing_code = False |