diff --git a/.ai_cache/service_config.json b/.ai_cache/service_config.json index b0a4a59..7915dfa 100644 --- a/.ai_cache/service_config.json +++ b/.ai_cache/service_config.json @@ -6,5 +6,5 @@ "gemini" ], "summary_language": "zh", - "check_time": "2025-06-04T11:03:04.808361" + "check_time": "2025-06-06T19:19:56.275939" } \ No newline at end of file diff --git a/.cache/plugin/git-committers/page-authors.json b/.cache/plugin/git-committers/page-authors.json index d6004e2..363e1af 100644 --- a/.cache/plugin/git-committers/page-authors.json +++ b/.cache/plugin/git-committers/page-authors.json @@ -1 +1 @@ -{"cache_date": "2025-06-04", "page_authors": {}} \ No newline at end of file +{"cache_date": "2025-06-06", "page_authors": {}} \ No newline at end of file diff --git a/docs/about/test.md b/docs/about/test.md index e9f7197..a60f133 100644 --- a/docs/about/test.md +++ b/docs/about/test.md @@ -1,6 +1,15 @@ +--- +title: 测试小组件 +# status: new +--- + +# 测试小组件 + !!!info 测试中的小组件,可看源代码自行取用 + +
@@ -26,7 +28,6 @@ status: new


-🌐 **在线演示**: https://wcowin.work/mkdocs-ai-hooks/
---
diff --git a/docs/blog/websitebeauty/reading_time.md b/docs/blog/websitebeauty/reading_time.md
new file mode 100644
index 0000000..4a23047
--- /dev/null
+++ b/docs/blog/websitebeauty/reading_time.md
@@ -0,0 +1,374 @@
+---
+title: Mkdocs 阅读时间插件
+tags:
+ - Mkdocs
+status: new
+---
+
+## 1. 基础配置
+
+### **步骤1**
+
+创建reading_time.py
+
+??? note "reading_time.py"
+ ```python
+ import re
+ import threading
+ import time
+ from functools import lru_cache
+ from collections import OrderedDict
+ import hashlib
+
+ # 预编译正则表达式(性能优化版本)
+ EXCLUDE_PATTERNS = [
+ re.compile(r'^index\.md$'),
+ re.compile(r'^trip/index\.md$'),
+ re.compile(r'^relax/index\.md$'),
+ re.compile(r'^blog/indexblog\.md$'),
+ re.compile(r'^blog/posts\.md$'),
+ re.compile(r'^develop/index\.md$'),
+ re.compile(r'waline\.md$'),
+ re.compile(r'link\.md$'),
+ re.compile(r'404\.md$'),
+ ]
+
+ # 高度优化的正则表达式(一次性编译)
+ CHINESE_CHARS_PATTERN = re.compile(r'[\u4e00-\u9fff\u3400-\u4dbf]')
+ CODE_BLOCK_PATTERN = re.compile(r'```.*?```', re.DOTALL)
+ INLINE_CODE_PATTERN = re.compile(r'`[^`]+`')
+ YAML_FRONT_PATTERN = re.compile(r'^---.*?---\s*', re.DOTALL)
+ HTML_TAG_PATTERN = re.compile(r'<[^>]+>')
+ IMAGE_PATTERN = re.compile(r'!\[.*?\]\([^)]+\)')
+ LINK_PATTERN = re.compile(r'\[([^\]]+)\]\([^)]+\)')
+
+ # 预定义排除类型
+ EXCLUDE_TYPES = frozenset({'landing', 'special', 'widget'})
+
+ # 扩展非编程行内代码词汇(更全面的过滤)
+ NON_CODE_WORDS = frozenset({
+ 'markdown', 'target', 'blank', 'lg', 'middle', 'small', 'large',
+ 'left', 'right', 'center', 'top', 'bottom', 'primary', 'secondary',
+ 'success', 'warning', 'danger', 'info', 'light', 'dark', 'grid',
+ 'cards', 'octicons', 'bookmark', 'div', 'class', 'img', 'src',
+ 'alt', 'width', 'height', 'style', 'id', 'data', 'href', 'title'
+ })
+
+ # 支持的编程和标记语言(扩展版本)
+ PROGRAMMING_LANGUAGES = frozenset({
+ # 编程语言
+ 'python', 'py', 'javascript', 'js', 'typescript', 'ts', 'java', 'cpp', 'c',
+ 'go', 'rust', 'php', 'ruby', 'swift', 'kotlin', 'csharp', 'cs',
+ # 脚本语言
+ 'bash', 'sh', 'powershell', 'ps1', 'zsh', 'fish', 'bat', 'cmd',
+ # 标记和配置语言
+ 'html', 'css', 'scss', 'sass', 'less', 'yaml', 'yml', 'json', 'xml',
+ 'toml', 'ini', 'conf', 'dockerfile', 'makefile',
+ # 数据库和查询
+ 'sql', 'mysql', 'postgresql', 'sqlite', 'mongodb',
+ # 其他
+ 'r', 'matlab', 'scala', 'perl', 'lua', 'dart', 'tex', 'latex',
+ # 数据格式
+ 'csv', 'properties',
+ # 无标识符(空字符串也算作有效语言)
+ ''
+ })
+
+ @lru_cache(maxsize=256)
+ def clean_markdown_content_for_chinese(content_hash, markdown):
+ """清理Markdown内容,只保留中文文本用于统计(添加缓存)"""
+ content = markdown
+
+ # 使用预编译的正则表达式
+ content = YAML_FRONT_PATTERN.sub('', content)
+ content = HTML_TAG_PATTERN.sub('', content)
+ content = IMAGE_PATTERN.sub('', content)
+ content = LINK_PATTERN.sub(r'\1', content)
+ content = CODE_BLOCK_PATTERN.sub('', content)
+ content = INLINE_CODE_PATTERN.sub('', content)
+
+ return content
+
+ def count_code_lines(markdown):
+ """统计代码行数(修复版本 - 正确处理所有代码行)"""
+ code_blocks = CODE_BLOCK_PATTERN.findall(markdown)
+ total_code_lines = 0
+
+ for i, block in enumerate(code_blocks):
+ # 提取语言标识
+ lang_match = re.match(r'^```(\w*)', block)
+ language = lang_match.group(1).lower() if lang_match else ''
+
+ # 移除开头的语言标识和结尾的```
+ code_content = re.sub(r'^```\w*\n?', '', block)
+ code_content = re.sub(r'\n?```$', '', code_content)
+
+ # 过滤空代码块
+ if not code_content.strip():
+ continue
+
+ # 计算有效行数(包含所有非空行,包括注释行)
+ lines = [line for line in code_content.split('\n') if line.strip()]
+ line_count = len(lines)
+
+ # 如果有明确的编程语言标识,直接统计
+ if language and language in PROGRAMMING_LANGUAGES:
+ total_code_lines += line_count
+ continue
+
+ # 增强的检测策略 - 更宽松的判断
+ is_code = False
+
+ # 1. 命令行检测
+ command_indicators = [
+ 'sudo ', 'npm ', 'pip ', 'git ', 'cd ', 'ls ', 'mkdir ', 'rm ', 'cp ', 'mv ',
+ 'chmod ', 'chown ', 'grep ', 'find ', 'ps ', 'kill ', 'top ', 'cat ', 'echo ',
+ 'wget ', 'curl ', 'tar ', 'zip ', 'unzip ', 'ssh ', 'scp ', 'rsync ',
+ 'xattr ', 'codesign ', 'xcode-select ', 'spctl ', 'launchctl ',
+ 'brew ', 'defaults ', 'ditto ', 'hdiutil ', 'diskutil ',
+ 'dir ', 'copy ', 'xcopy ', 'del ', 'rd ', 'md ', 'type ', 'attrib ',
+ '$ ', '# ', '% ', '> ', 'C:\\>', 'PS>',
+ '--', '-r', '-d', '-f', '-v', '-h', '--help', '--version',
+ '--force', '--deep', '--sign', '--master-disable',
+ '/Applications/', '/usr/', '/etc/', '/var/', '/home/', '~/',
+ 'C:\\', 'D:\\', '.app', '.exe', '.pkg', '.dmg', '.zip', '.tar',
+ '#!/',
+ ]
+
+ if any(indicator in code_content for indicator in command_indicators):
+ is_code = True
+
+ # 2. 编程语法检测(增强版)
+ if not is_code:
+ programming_indicators = [
+ # Python语法特征
+ 'def ', 'class ', 'import ', 'from ', 'return ', 'yield ', 'lambda ',
+ 'with ', 'as ', 'try:', 'except:', 'finally:', 'elif ', 'if __name__',
+ 'print(', '.append(', '.extend(', '.remove(', '.sort(', '.reverse(',
+ 'range(', 'len(', 'str(', 'int(', 'float(', 'list(', 'dict(',
+ # JavaScript/TypeScript语法
+ 'function', 'var ', 'let ', 'const ', 'async ', 'await ', '=>',
+ 'console.log', 'document.', 'window.', 'require(',
+ # 通用编程语法
+ 'public ', 'private ', 'protected ', 'static ', 'void ', 'int ',
+ 'string ', 'boolean ', 'float ', 'double ', 'char ',
+ # 操作符和结构
+ '==', '!=', '<=', '>=', '&&', '||', '++', '--', '+=', '-=', '**',
+ # 特殊结构
+ 'while ', 'for ', 'if ', 'else:', 'switch ', 'case ',
+ # HTML/XML语法
+ '',
+ '