mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Formatting (#6533)
* Removed unused imports * Replaced nested `if` statements by single one * Removed unnecessary `dict()` constructor around `dict` literal
This commit is contained in:
parent
55fe1ccc53
commit
13aa1565fb
@ -124,7 +124,7 @@ def on_page_markdown(markdown: str, *, page: Page, config: MkDocsConfig, files):
|
|||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
# Map ISO 639-1 (languages) to ISO 3166 (countries)
|
# Map ISO 639-1 (languages) to ISO 3166 (countries)
|
||||||
countries = dict({
|
countries = {
|
||||||
"af": "za",
|
"af": "za",
|
||||||
"az": "az",
|
"az": "az",
|
||||||
"ar": "ae",
|
"ar": "ae",
|
||||||
@ -191,4 +191,4 @@ countries = dict({
|
|||||||
"zh": "cn",
|
"zh": "cn",
|
||||||
"zh-Hant": "cn",
|
"zh-Hant": "cn",
|
||||||
"zh-TW": "tw"
|
"zh-TW": "tw"
|
||||||
})
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from mkdocs.config.base import Config
|
from mkdocs.config.base import Config
|
||||||
from mkdocs.config.config_options import Deprecated, DictOfItems, Type
|
from mkdocs.config.config_options import DictOfItems, Type
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Classes
|
# Classes
|
||||||
|
@ -62,11 +62,11 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]):
|
|||||||
|
|
||||||
# Initialize collections of external assets
|
# Initialize collections of external assets
|
||||||
self.assets = Files([])
|
self.assets = Files([])
|
||||||
self.assets_expr_map = dict({
|
self.assets_expr_map = {
|
||||||
".css": r"url\((\s*http?[^)]+)\)",
|
".css": r"url\((\s*http?[^)]+)\)",
|
||||||
".js": r"[\"'](http[^\"']+\.(?:css|js(?:on)?))[\"']",
|
".js": r"[\"'](http[^\"']+\.(?:css|js(?:on)?))[\"']",
|
||||||
**self.config.assets_expr_map
|
**self.config.assets_expr_map
|
||||||
})
|
}
|
||||||
|
|
||||||
# Process external style sheets and scripts (run latest) - run this after
|
# Process external style sheets and scripts (run latest) - run this after
|
||||||
# all other plugins, so they can add additional assets
|
# all other plugins, so they can add additional assets
|
||||||
@ -537,7 +537,7 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]):
|
|||||||
log = logging.getLogger("mkdocs.material.privacy")
|
log = logging.getLogger("mkdocs.material.privacy")
|
||||||
|
|
||||||
# Expected file extensions
|
# Expected file extensions
|
||||||
extensions = dict({
|
extensions = {
|
||||||
"application/javascript": ".js",
|
"application/javascript": ".js",
|
||||||
"image/avif": ".avif",
|
"image/avif": ".avif",
|
||||||
"image/gif": ".gif",
|
"image/gif": ".gif",
|
||||||
@ -547,4 +547,4 @@ extensions = dict({
|
|||||||
"image/webp": ".webp",
|
"image/webp": ".webp",
|
||||||
"text/javascript": ".js",
|
"text/javascript": ".js",
|
||||||
"text/css": ".css"
|
"text/css": ".css"
|
||||||
})
|
}
|
||||||
|
@ -450,16 +450,15 @@ class Parser(HTMLParser):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Render opening tag if kept
|
# Render opening tag if kept
|
||||||
if not self.skip.intersection(self.context):
|
if not self.skip.intersection(self.context) and tag in self.keep:
|
||||||
if tag in self.keep:
|
|
||||||
|
|
||||||
# Check whether we're inside the section title
|
# Check whether we're inside the section title
|
||||||
data = self.section.text
|
data = self.section.text
|
||||||
if self.section.el in self.context:
|
if self.section.el in self.context:
|
||||||
data = self.section.title
|
data = self.section.title
|
||||||
|
|
||||||
# Append to section title or text
|
# Append to section title or text
|
||||||
data.append(f"<{tag}>")
|
data.append(f"<{tag}>")
|
||||||
|
|
||||||
# Called at the end of every HTML tag
|
# Called at the end of every HTML tag
|
||||||
def handle_endtag(self, tag):
|
def handle_endtag(self, tag):
|
||||||
@ -488,29 +487,28 @@ class Parser(HTMLParser):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Render closing tag if kept
|
# Render closing tag if kept
|
||||||
if not self.skip.intersection(self.context):
|
if not self.skip.intersection(self.context) and tag in self.keep:
|
||||||
if tag in self.keep:
|
|
||||||
|
|
||||||
# Check whether we're inside the section title
|
# Check whether we're inside the section title
|
||||||
data = self.section.text
|
data = self.section.text
|
||||||
if self.section.el in self.context:
|
if self.section.el in self.context:
|
||||||
data = self.section.title
|
data = self.section.title
|
||||||
|
|
||||||
# Search for corresponding opening tag
|
# Search for corresponding opening tag
|
||||||
index = data.index(f"<{tag}>")
|
index = data.index(f"<{tag}>")
|
||||||
for i in range(index + 1, len(data)):
|
for i in range(index + 1, len(data)):
|
||||||
if not data[i].isspace():
|
if not data[i].isspace():
|
||||||
index = len(data)
|
index = len(data)
|
||||||
break
|
break
|
||||||
|
|
||||||
# Remove element if empty (or only whitespace)
|
# Remove element if empty (or only whitespace)
|
||||||
if len(data) > index:
|
if len(data) > index:
|
||||||
while len(data) > index:
|
while len(data) > index:
|
||||||
data.pop()
|
data.pop()
|
||||||
|
|
||||||
# Append to section title or text
|
# Append to section title or text
|
||||||
else:
|
else:
|
||||||
data.append(f"</{tag}>")
|
data.append(f"</{tag}>")
|
||||||
|
|
||||||
# Called for the text contents of each tag
|
# Called for the text contents of each tag
|
||||||
def handle_data(self, data):
|
def handle_data(self, data):
|
||||||
|
@ -491,7 +491,7 @@ log = logging.getLogger("mkdocs")
|
|||||||
log.addFilter(DuplicateFilter())
|
log.addFilter(DuplicateFilter())
|
||||||
|
|
||||||
# Color palette
|
# Color palette
|
||||||
colors = dict({
|
colors = {
|
||||||
"red": { "fill": "#ef5552", "text": "#ffffff" },
|
"red": { "fill": "#ef5552", "text": "#ffffff" },
|
||||||
"pink": { "fill": "#e92063", "text": "#ffffff" },
|
"pink": { "fill": "#e92063", "text": "#ffffff" },
|
||||||
"purple": { "fill": "#ab47bd", "text": "#ffffff" },
|
"purple": { "fill": "#ab47bd", "text": "#ffffff" },
|
||||||
@ -513,4 +513,4 @@ colors = dict({
|
|||||||
"blue-grey": { "fill": "#546d78", "text": "#ffffff" },
|
"blue-grey": { "fill": "#546d78", "text": "#ffffff" },
|
||||||
"black": { "fill": "#000000", "text": "#ffffff" },
|
"black": { "fill": "#000000", "text": "#ffffff" },
|
||||||
"white": { "fill": "#ffffff", "text": "#000000" }
|
"white": { "fill": "#ffffff", "text": "#000000" }
|
||||||
})
|
}
|
||||||
|
@ -18,12 +18,9 @@
|
|||||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
# IN THE SOFTWARE.
|
# IN THE SOFTWARE.
|
||||||
|
|
||||||
from functools import partial
|
|
||||||
from markdown.extensions.toc import slugify
|
|
||||||
from mkdocs.config.config_options import Optional, Type
|
from mkdocs.config.config_options import Optional, Type
|
||||||
from mkdocs.config.base import Config
|
from mkdocs.config.base import Config
|
||||||
|
|
||||||
from . import casefold
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Classes
|
# Classes
|
||||||
|
Loading…
Reference in New Issue
Block a user