Make URLs in check book help text clickable

This commit is contained in:
Kovid Goyal 2020-01-08 19:00:09 +05:30
parent 850b2b8a9d
commit 86d75fcc83
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 7 additions and 3 deletions

View File

@ -63,7 +63,7 @@ def message_to_error(message, name, line_offset=0):
ans.HELP = rule.get('desc') or ''
ans.css_rule_id = rule_id
if ans.HELP and 'url' in rule:
ans.HELP += ' ' + _('See {}').format(rule['url'])
ans.HELP += ' ' + _('See <a href="{}">detailed description</a>.').format(rule['url'])
return ans
@ -237,8 +237,10 @@ def create_job(name, css, line_offset=0, is_declaration=False):
def check_css(jobs):
results = pool.check_css([j.css for j in jobs])
errors = []
if not jobs:
return errors
results = pool.check_css([j.css for j in jobs])
for job, result in zip(jobs, results):
if isinstance(result, dict):
for msg in result['messages']:

View File

@ -13,7 +13,7 @@ from PyQt5.Qt import (
from calibre.ebooks.oeb.polish.check.base import WARN, INFO, DEBUG, ERROR, CRITICAL
from calibre.ebooks.oeb.polish.check.main import run_checks, fix_errors
from calibre.gui2 import NO_URL_FORMATTING
from calibre.gui2 import NO_URL_FORMATTING, safe_open_url
from calibre.gui2.tweak_book import tprefs
from calibre.gui2.tweak_book.widgets import BusyCursor
from polyglot.builtins import unicode_type, range
@ -131,6 +131,8 @@ class Check(QSplitter):
elif url.startswith('activate:item:'):
index = int(url.rpartition(':')[-1])
self.location_activated(index)
elif url.startswith('https://'):
safe_open_url(url)
def next_error(self, delta=1):
row = self.items.currentRow()