This commit is contained in:
Ellis 2018-09-17 11:59:10 -04:00
commit 15b00cea6a
2 changed files with 20 additions and 9 deletions

View File

@ -60,6 +60,8 @@ Fixed
- Error when passing a substring with spaces to `:tab-take`.
- Greasemonkey scripts which start with an UTF-8 BOM are now handled correctly.
- When no documentation has been generated, the plaintext documentation now can
be shown for more files such as `qute://help/userscripts.html`.
Removed
~~~~~~~

View File

@ -349,6 +349,23 @@ def qute_gpl(_url):
return 'text/html', utils.read_file('html/license.html')
def _asciidoc_fallback_path(path):
"""Fall back to plaintext asciidoc if the HTML is unavailable."""
asciidoc_path = path.replace('.html', '.asciidoc')
asciidoc_paths = [asciidoc_path]
if asciidoc_path.startswith('html/doc/'):
asciidoc_paths += [asciidoc_path.replace('html/doc/', '../doc/help/'),
asciidoc_path.replace('html/doc/', '../doc/')]
for path in asciidoc_paths:
try:
return utils.read_file(path)
except OSError:
pass
return None
@add_handler('help')
def qute_help(url):
"""Handler for qute://help."""
@ -373,15 +390,7 @@ def qute_help(url):
try:
data = utils.read_file(path)
except OSError:
# No .html around, let's see if we find the asciidoc
asciidoc_path = path.replace('.html', '.asciidoc')
if asciidoc_path.startswith('html/doc/'):
asciidoc_path = asciidoc_path.replace('html/doc/', '../doc/help/')
try:
asciidoc = utils.read_file(asciidoc_path)
except OSError:
asciidoc = None
asciidoc = _asciidoc_fallback_path(path)
if asciidoc is None:
raise