html-to-markdown 1.4.0__py3-none-any.whl → 1.6.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of html-to-markdown might be problematic. Click here for more details.
- html_to_markdown/__init__.py +19 -2
- html_to_markdown/cli.py +103 -25
- html_to_markdown/constants.py +1 -0
- html_to_markdown/converters.py +1646 -104
- html_to_markdown/exceptions.py +49 -0
- html_to_markdown/processing.py +720 -47
- html_to_markdown-1.6.0.dist-info/METADATA +472 -0
- html_to_markdown-1.6.0.dist-info/RECORD +15 -0
- html_to_markdown-1.4.0.dist-info/METADATA +0 -249
- html_to_markdown-1.4.0.dist-info/RECORD +0 -14
- {html_to_markdown-1.4.0.dist-info → html_to_markdown-1.6.0.dist-info}/WHEEL +0 -0
- {html_to_markdown-1.4.0.dist-info → html_to_markdown-1.6.0.dist-info}/entry_points.txt +0 -0
- {html_to_markdown-1.4.0.dist-info → html_to_markdown-1.6.0.dist-info}/licenses/LICENSE +0 -0
- {html_to_markdown-1.4.0.dist-info → html_to_markdown-1.6.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""Custom exceptions for the html-to-markdown library."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class HtmlToMarkdownError(Exception):
|
|
7
|
+
"""Base exception for all html-to-markdown errors."""
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class MissingDependencyError(HtmlToMarkdownError):
|
|
11
|
+
"""Raised when an optional dependency is required but not installed."""
|
|
12
|
+
|
|
13
|
+
def __init__(self, dependency: str, install_command: str | None = None) -> None:
|
|
14
|
+
self.dependency = dependency
|
|
15
|
+
self.install_command = install_command
|
|
16
|
+
|
|
17
|
+
message = f"{dependency} is not installed."
|
|
18
|
+
if install_command:
|
|
19
|
+
message += f" Install with: {install_command}"
|
|
20
|
+
|
|
21
|
+
super().__init__(message)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class InvalidParserError(HtmlToMarkdownError):
|
|
25
|
+
"""Raised when an invalid parser is specified."""
|
|
26
|
+
|
|
27
|
+
def __init__(self, parser: str, available_parsers: list[str]) -> None:
|
|
28
|
+
self.parser = parser
|
|
29
|
+
self.available_parsers = available_parsers
|
|
30
|
+
|
|
31
|
+
message = f"Invalid parser '{parser}'. Available parsers: {', '.join(available_parsers)}"
|
|
32
|
+
super().__init__(message)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class EmptyHtmlError(HtmlToMarkdownError):
|
|
36
|
+
"""Raised when the input HTML is empty."""
|
|
37
|
+
|
|
38
|
+
def __init__(self) -> None:
|
|
39
|
+
super().__init__("The input HTML is empty.")
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class ConflictingOptionsError(HtmlToMarkdownError):
|
|
43
|
+
"""Raised when conflicting options are specified."""
|
|
44
|
+
|
|
45
|
+
def __init__(self, option1: str, option2: str) -> None:
|
|
46
|
+
self.option1 = option1
|
|
47
|
+
self.option2 = option2
|
|
48
|
+
|
|
49
|
+
super().__init__(f"Only one of '{option1}' and '{option2}' can be specified.")
|