CopyAsHtml.py does:
cgi.escape was deprecated in Python 3.2 and removed entirely in Python 3.8. Sublime Text 4's embedded plugin_host runs Python 3.8, so this import fails immediately:
>>> from cgi import escape
ImportError: cannot import name 'escape' from 'cgi' (...\python3.8.zip\cgi.pyc)
Since this is a top-level import, the entire module fails to load and CopyAsHtmlCommand never gets registered as a command -- confirmed live: after installing the package (v2.0.1) fresh via Package Control, sublime_plugin.text_command_classes contains no CopyAsHtml-related entry at all, and invoking copy_as_html via view.run_command is a silent no-op (no exception surfaced to Sublime's dispatcher, no clipboard change) -- the package is completely non-functional out of the box on any current Sublime Text 4 install, with no error shown to the user to explain why the context-menu/command-palette entry does nothing.
This is likely also the underlying cause of #5 ("Not able to install this package on sublime's latest version").
Fix: replace from cgi import escape with from html import escape (the stdlib replacement, available since Python 3.2, with an equivalent signature for this use case -- escape(s, quote=True) HTML-escapes &, <, >, and optionally quotes).
Second, currently-masked bug that will surface once the above is fixed: the file does from sublime import * (not import sublime), so the bare name sublime is never bound. But CopyAsHtmlCommand.run() calls sublime.load_settings('Preferences.sublime-settings') -- this will raise NameError: name 'sublime' is not defined as soon as the cgi.escape ImportError above is fixed and the method actually gets a chance to execute. Confirmed via a minimal repro: exec('from sublime import *') does not bind sublime itself, only bind the individual names Sublime's API module exports (like load_settings, set_clipboard, etc. directly). Fix: either add import sublime alongside the star-import, or drop the sublime. prefix and call load_settings(...) directly (which is already in scope from the star-import).
Happy to send a PR fixing both issues if useful.
CopyAsHtml.pydoes:cgi.escapewas deprecated in Python 3.2 and removed entirely in Python 3.8. Sublime Text 4's embeddedplugin_hostruns Python 3.8, so this import fails immediately:Since this is a top-level import, the entire module fails to load and
CopyAsHtmlCommandnever gets registered as a command -- confirmed live: after installing the package (v2.0.1) fresh via Package Control,sublime_plugin.text_command_classescontains noCopyAsHtml-related entry at all, and invokingcopy_as_htmlviaview.run_commandis a silent no-op (no exception surfaced to Sublime's dispatcher, no clipboard change) -- the package is completely non-functional out of the box on any current Sublime Text 4 install, with no error shown to the user to explain why the context-menu/command-palette entry does nothing.This is likely also the underlying cause of #5 ("Not able to install this package on sublime's latest version").
Fix: replace
from cgi import escapewithfrom html import escape(the stdlib replacement, available since Python 3.2, with an equivalent signature for this use case --escape(s, quote=True)HTML-escapes&,<,>, and optionally quotes).Second, currently-masked bug that will surface once the above is fixed: the file does
from sublime import *(notimport sublime), so the bare namesublimeis never bound. ButCopyAsHtmlCommand.run()callssublime.load_settings('Preferences.sublime-settings')-- this will raiseNameError: name 'sublime' is not definedas soon as thecgi.escapeImportErrorabove is fixed and the method actually gets a chance to execute. Confirmed via a minimal repro:exec('from sublime import *')does not bindsublimeitself, only bind the individual names Sublime's API module exports (likeload_settings,set_clipboard, etc. directly). Fix: either addimport sublimealongside the star-import, or drop thesublime.prefix and callload_settings(...)directly (which is already in scope from the star-import).Happy to send a PR fixing both issues if useful.