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