Clean up deprecated code and fix multiple issues

- Remove deprecated markdown_preview plugin and re-wrote
- Renamed alt_provider.py under words completer
- Fix words completion provider logic and cache handling
- Fix container orientations (VERTICAL -> HORIZONTAL) and add Separators
- Remove unused Gtk imports from search_replace plugin
- Fix event creation parameter order in source_file.py
- Fix typo in source_view.py (_load_pretify_json -> _load_prettify_json)
- Refactor webkit_ui with new load methods and enhanced settings
This commit is contained in:
2026-02-20 00:10:15 -06:00
parent 3e920291a0
commit aaadba3812
58 changed files with 366 additions and 275 deletions

View File

@@ -0,0 +1,3 @@
"""
Pligin Module Mixins
"""

View File

@@ -0,0 +1,38 @@
# Python imports
# Lib imports
# Application imports
from .markdown_template_mixin import MarkdownTemplateMixin
from .. import markdown
class MarkdownPreviewMixin(MarkdownTemplateMixin):
def _do_markdown_translate(self, buffer):
if self.is_preview_paused: return
if not self.is_markdown(buffer):
data = self.wrap_html_to_body("<h1>Not a Markdown file...</h1>")
self._load_html(data)
return
data = self.get_rendered_markdown(buffer)
self._load_html(data)
def _load_html(self, data: str):
self._markdown_view.load_html(
content = data, base_uri = None
)
def get_rendered_markdown(self, buffer) -> str:
start_itr = buffer.get_start_iter()
end_itr = buffer.get_end_iter()
text = buffer.get_text(start_itr, end_itr, include_hidden_chars = False)
html = markdown.markdown(text)
return self.wrap_html_to_body(html)
def is_markdown(self, buffer) -> bool:
return buffer.get_language() and buffer.get_language().get_id() == "markdown"

View File

@@ -0,0 +1,43 @@
# Python imports
# Lib imports
# Application imports
class MarkdownTemplateMixin:
def wrap_html_to_body(self, html: str):
return f"""\
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Markdown View</title>
<style media="screen">
html, body {{
display: block;
// background-color: #32383e64;
background-color: #32383e;
color: #ffffff;
text-wrap: wrap;
}}
img {{
width: 100%;
height: auto;
}}
code {{
border: 1px solid #32383e;
background-color: #32383e;
padding: 4px;
}}
</style>
</head>
<body>
{html}
</body>
</html>
"""