view-source pygments feedback pass
This commit is contained in:
parent
f7bcdfc818
commit
40364ce774
@ -150,15 +150,15 @@ class AbstractAction:
|
|||||||
raise WebTabError("{} is not a valid web action!".format(name))
|
raise WebTabError("{} is not a valid web action!".format(name))
|
||||||
self._widget.triggerPageAction(member)
|
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."""
|
"""Show the source of the current page in a new tab."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def _show_source_pygment(self):
|
def _show_source_pygments(self):
|
||||||
|
|
||||||
def show_source_cb(source):
|
def show_source_cb(source):
|
||||||
"""show source as soon as it's ready."""
|
"""Show source as soon as it's ready."""
|
||||||
# workaround for https://github.com/pycqa/pylint/issues/491
|
# WORKAROUND for https://github.com/PyCQA/pylint/issues/491
|
||||||
# pylint: disable=no-member
|
# pylint: disable=no-member
|
||||||
lexer = pygments.lexers.HtmlLexer()
|
lexer = pygments.lexers.HtmlLexer()
|
||||||
formatter = pygments.formatters.HtmlFormatter(
|
formatter = pygments.formatters.HtmlFormatter(
|
||||||
|
@ -1513,12 +1513,15 @@ class CommandDispatcher:
|
|||||||
)
|
)
|
||||||
|
|
||||||
@cmdutils.register(instance='command-dispatcher', scope='window')
|
@cmdutils.register(instance='command-dispatcher', scope='window')
|
||||||
@cmdutils.argument('pygment')
|
def view_source(self, edit=False, pygments=False):
|
||||||
def view_source(self, edit=False, pygment=False):
|
|
||||||
"""Show the source of the current page in a new tab.
|
"""Show the source of the current page in a new tab.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
edit: Edit the source in the editor instead of opening a tab.
|
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()
|
tab = self._current_widget()
|
||||||
try:
|
try:
|
||||||
@ -1533,7 +1536,7 @@ class CommandDispatcher:
|
|||||||
ed = editor.ExternalEditor(self._tabbed_browser)
|
ed = editor.ExternalEditor(self._tabbed_browser)
|
||||||
tab.dump_async(ed.edit)
|
tab.dump_async(ed.edit)
|
||||||
else:
|
else:
|
||||||
tab.action.show_source(pygment)
|
tab.action.show_source(pygments)
|
||||||
|
|
||||||
@cmdutils.register(instance='command-dispatcher', scope='window',
|
@cmdutils.register(instance='command-dispatcher', scope='window',
|
||||||
debug=True)
|
debug=True)
|
||||||
|
@ -100,9 +100,9 @@ class WebEngineAction(browsertab.AbstractAction):
|
|||||||
"""Save the current page."""
|
"""Save the current page."""
|
||||||
self._widget.triggerPageAction(QWebEnginePage.SavePage)
|
self._widget.triggerPageAction(QWebEnginePage.SavePage)
|
||||||
|
|
||||||
def show_source(self, pygment):
|
def show_source(self, pygments=False):
|
||||||
if pygment:
|
if pygments:
|
||||||
self._show_source_pygment()
|
self._show_source_pygments()
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -23,10 +23,6 @@ import re
|
|||||||
import functools
|
import functools
|
||||||
import xml.etree.ElementTree
|
import xml.etree.ElementTree
|
||||||
|
|
||||||
import pygments
|
|
||||||
import pygments.lexers
|
|
||||||
import pygments.formatters
|
|
||||||
|
|
||||||
import sip
|
import sip
|
||||||
from PyQt5.QtCore import (pyqtSlot, Qt, QEvent, QUrl, QPoint, QTimer, QSizeF,
|
from PyQt5.QtCore import (pyqtSlot, Qt, QEvent, QUrl, QPoint, QTimer, QSizeF,
|
||||||
QSize)
|
QSize)
|
||||||
@ -55,8 +51,8 @@ class WebKitAction(browsertab.AbstractAction):
|
|||||||
"""Save the current page."""
|
"""Save the current page."""
|
||||||
raise browsertab.UnsupportedOperationError
|
raise browsertab.UnsupportedOperationError
|
||||||
|
|
||||||
def show_source(self, pygment):
|
def show_source(self, pygments=False):
|
||||||
self._show_source_pygment()
|
self._show_source_pygments()
|
||||||
|
|
||||||
|
|
||||||
class WebKitPrinting(browsertab.AbstractPrinting):
|
class WebKitPrinting(browsertab.AbstractPrinting):
|
||||||
|
Loading…
Reference in New Issue
Block a user