diff --git a/qutebrowser/browser/browsertab.py b/qutebrowser/browser/browsertab.py index 0d45f4ceb..133f891de 100644 --- a/qutebrowser/browser/browsertab.py +++ b/qutebrowser/browser/browsertab.py @@ -150,15 +150,15 @@ class AbstractAction: raise WebTabError("{} is not a valid web action!".format(name)) self._widget.triggerPageAction(member) - def show_source(self, pygment=False): + def show_source(self, pygments=False): """Show the source of the current page in a new tab.""" raise NotImplementedError - def _show_source_pygment(self): + def _show_source_pygments(self): def show_source_cb(source): - """show source as soon as it's ready.""" - # workaround for https://github.com/pycqa/pylint/issues/491 + """Show source as soon as it's ready.""" + # WORKAROUND for https://github.com/PyCQA/pylint/issues/491 # pylint: disable=no-member lexer = pygments.lexers.HtmlLexer() formatter = pygments.formatters.HtmlFormatter( diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 4c5e14213..41e078d37 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1513,12 +1513,15 @@ class CommandDispatcher: ) @cmdutils.register(instance='command-dispatcher', scope='window') - @cmdutils.argument('pygment') - def view_source(self, edit=False, pygment=False): + def view_source(self, edit=False, pygments=False): """Show the source of the current page in a new tab. Args: edit: Edit the source in the editor instead of opening a tab. + pygments: Use pygments to generate the view. This is always + the case for QtWebKit. For QtWebEngine it may display + slightly different source. + Some JavaScript processing may be applied. """ tab = self._current_widget() try: @@ -1533,7 +1536,7 @@ class CommandDispatcher: ed = editor.ExternalEditor(self._tabbed_browser) tab.dump_async(ed.edit) else: - tab.action.show_source(pygment) + tab.action.show_source(pygments) @cmdutils.register(instance='command-dispatcher', scope='window', debug=True) diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py index 7b62305b5..390ee2958 100644 --- a/qutebrowser/browser/webengine/webenginetab.py +++ b/qutebrowser/browser/webengine/webenginetab.py @@ -100,9 +100,9 @@ class WebEngineAction(browsertab.AbstractAction): """Save the current page.""" self._widget.triggerPageAction(QWebEnginePage.SavePage) - def show_source(self, pygment): - if pygment: - self._show_source_pygment() + def show_source(self, pygments=False): + if pygments: + self._show_source_pygments() return try: diff --git a/qutebrowser/browser/webkit/webkittab.py b/qutebrowser/browser/webkit/webkittab.py index 07ae39748..bd7e09282 100644 --- a/qutebrowser/browser/webkit/webkittab.py +++ b/qutebrowser/browser/webkit/webkittab.py @@ -23,10 +23,6 @@ import re import functools import xml.etree.ElementTree -import pygments -import pygments.lexers -import pygments.formatters - import sip from PyQt5.QtCore import (pyqtSlot, Qt, QEvent, QUrl, QPoint, QTimer, QSizeF, QSize) @@ -55,8 +51,8 @@ class WebKitAction(browsertab.AbstractAction): """Save the current page.""" raise browsertab.UnsupportedOperationError - def show_source(self, pygment): - self._show_source_pygment() + def show_source(self, pygments=False): + self._show_source_pygments() class WebKitPrinting(browsertab.AbstractPrinting):