Skip to content

Commit 55f3f6c

Browse files
committed
build: add support for python 3.8
1 parent 4fbdb01 commit 55f3f6c

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

mkdocs_embed_file_plugins/plugin.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import codecs
2+
from typing import Union, List, Tuple, Dict, Any
23
import os
34
import re
45
from glob import iglob
@@ -12,10 +13,10 @@
1213
from mkdocs.config import config_options
1314
from mkdocs.plugins import BasePlugin
1415
from mkdocs_callouts.plugin import CalloutsPlugin
15-
from custom_attributes.plugin import read_custom, convert_hashtags, convert_text_attributes
16+
from custom_attributes.plugin import convert_text_attributes
1617

1718

18-
def search_in_file(citation_part: str, contents: str):
19+
def search_in_file(citation_part: str, contents: str) -> Union[str,None]:
1920
"""
2021
Search a part in the file
2122
Args:
@@ -52,7 +53,7 @@ def search_in_file(citation_part: str, contents: str):
5253
for i in data:
5354
if citation_part in i.upper():
5455
return i.replace(citation_part, '')
55-
return []
56+
return None
5657

5758

5859
def mini_ez_links(urlo, base, end, url_whitespace, url_case):
@@ -104,7 +105,7 @@ def strip_comments(markdown):
104105
markdown = re.sub(r'%%(.*)%%', '', markdown, flags=re.DOTALL)
105106
return markdown
106107

107-
def cite(md_link_path, link, soup, citation_part, config, callouts, custom_attr):
108+
def cite(md_link_path, link, soup, citation_part, config, callouts, custom_attr) -> BeautifulSoup:
108109
"""Append the content of the founded file to the original file.
109110
110111
Args:
@@ -191,7 +192,7 @@ def create_link(link):
191192
else:
192193
return link + '.md'
193194

194-
def search_file_in_documentation(link: Path|str, config_dir: Path):
195+
def search_file_in_documentation(link: Union[Path,str], config_dir: Path) -> Union[Path, int]:
195196
file_name = os.path.basename(link)
196197
if not file_name.endswith('.md'):
197198
file_name = file_name + '.md'
@@ -200,30 +201,25 @@ def search_file_in_documentation(link: Path|str, config_dir: Path):
200201
return 0
201202

202203

203-
204-
205204
class EmbedFile(BasePlugin):
206205
config_scheme = (
207-
('callouts', config_options.Type(str|bool, default='false')),
206+
('callouts', config_options.Type(bool, default=False)),
208207
('custom-attributes', config_options.Type(str, default=''))
209208
)
210209

211210
def __init__(self):
212211
self.enabled = True
213212
self.total_time = 0
214213

215-
def on_post_page(self, output_content, page, config):
214+
def on_post_page(self, output_content, page, config) -> str:
216215
soup = BeautifulSoup(output_content, 'html.parser')
217216
docs = Path(config['docs_dir'])
218217
md_link_path = ''
219218
callout = self.config['callouts']
220-
if isinstance(callout, str):
221-
callout = ast.literal_eval(callout.title())
222-
223219
for link in soup.findAll(
224220
'img',
225221
src=lambda src: src is not None and 'favicon' not in src and not src.endswith(
226-
('png', 'jpg', 'jpeg', 'gif', 'svg')),
222+
('png', 'jpg', 'jpeg', 'gif', 'svg')) and not 'www' in src and not 'http' in src,
227223
):
228224
if len(link['src']) > 0:
229225

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def classification_dependencies():
2121

2222
setup(
2323
name="mkdocs_embed_file_plugins",
24-
python_requires=">=3.10",
24+
python_requires=">=3.8",
2525
version=version,
2626
description="A plugin to quote file from docs",
2727
author="Mara-Li",

0 commit comments

Comments
 (0)