|
4 | 4 |
|
5 | 5 | import re
|
6 | 6 | import urllib.parse
|
| 7 | +import warnings |
7 | 8 |
|
8 | 9 | import bs4
|
9 |
| -import mistune |
10 |
| -from mistune.plugins import plugin_strikethrough, plugin_table, plugin_footnotes |
| 10 | +# import mistune |
| 11 | +# from mistune.plugins import plugin_strikethrough, plugin_table, plugin_footnotes |
11 | 12 | from tld import get_fld
|
12 | 13 | from slugify import slugify
|
13 | 14 |
|
@@ -60,6 +61,9 @@ def is_in_code(elem):
|
60 | 61 |
|
61 | 62 | REDACTED_STRING = "[redacted]"
|
62 | 63 |
|
| 64 | +# prevent beautifulsoup warning on comments containing only URLs |
| 65 | +warnings.filterwarnings('ignore', category=bs4.MarkupResemblesLocatorWarning) |
| 66 | + |
63 | 67 |
|
64 | 68 | class Rewriter(GlobalMixin):
|
65 | 69 | redacted_text = "[redacted]"
|
@@ -94,10 +98,10 @@ def __init__(self):
|
94 | 98 | )
|
95 | 99 |
|
96 | 100 | self.redacted_string = bs4.NavigableString(self.redacted_text)
|
97 |
| - self.markdown = mistune.create_markdown( |
98 |
| - escape=False, |
99 |
| - plugins=[plugin_strikethrough, plugin_table, plugin_footnotes], |
100 |
| - ) |
| 101 | + # self.markdown = mistune.create_markdown( |
| 102 | + # escape=False, |
| 103 | + # plugins=[plugin_strikethrough, plugin_table, plugin_footnotes], |
| 104 | + # ) |
101 | 105 | if self.conf.censor_words_list:
|
102 | 106 | with open(self.conf.build_dir.joinpath("words.list"), "r") as fh:
|
103 | 107 | # this will actually replace occurences of ~strings matching
|
@@ -146,7 +150,8 @@ def rewrite(self, content: str, to_root: str = "", unwrap: bool = False):
|
146 | 150 | return ""
|
147 | 151 |
|
148 | 152 | try:
|
149 |
| - soup = bs4.BeautifulSoup(self.markdown(content), "lxml") |
| 153 | + # soup = bs4.BeautifulSoup(self.markdown(content), "lxml") |
| 154 | + soup = bs4.BeautifulSoup(content, "lxml") |
150 | 155 | except Exception as exc:
|
151 | 156 | logger.error(f"Unable to init soup or markdown for {content}: {exc}")
|
152 | 157 | return content
|
|
0 commit comments