From 40a4cb0b62c264260dc17b53b3ad7de2bfdaf14a Mon Sep 17 00:00:00 2001 From: xunbu Date: Mon, 26 May 2025 13:15:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B7=AF=E5=BE=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/workspace.xml | 124 ++++++++++++++++++------------------ docutranslate/__init__.py | 2 +- docutranslate/translater.py | 9 +-- 3 files changed, 69 insertions(+), 66 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index aff4e90..400a685 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -6,7 +6,8 @@ - + + - { + "keyToString": { + "DefaultHtmlFileTemplate": "HTML File", + "JavaScript 调试.output.html (1).executor": "Run", + "JavaScript 调试.output.html.executor": "Run", + "JavaScript 调试.regex.md_中文.html.executor": "Run", + "JavaScript 调试.regex_中文.html.executor": "Run", + "JavaScript 调试.test.html.executor": "Run", + "JavaScript 调试.test2.html.executor": "Run", + "JavaScript 调试.test2_英文.html.executor": "Run", + "JavaScript 调试.test4-1_中文.html.executor": "Run", + "JavaScript 调试.互联网认证授权机制.html.executor": "Run", + "JavaScript 调试.互联网认证授权机制_英文.html.executor": "Run", + "JavaScript 调试.毕业论文_英文.html.executor": "Run", + "ModuleVcsDetector.initialDetectionPerformed": "true", + "Python 测试.Python 测试 (markdown_mask.py 内).executor": "Run", + "Python 测试.markdown_mask.Test.test_basic_link_masking 的 Python 测试.executor": "Run", + "Python 测试.pytest (test_html.py 内).executor": "Run", + "Python.1test.executor": "Run", + "Python.2test2 (1).executor": "Run", + "Python.PDFtranslater (1).executor": "Run", + "Python.PDFtranslater (2).executor": "Run", + "Python.agent.executor": "Debug", + "Python.agent_utils.executor": "Run", + "Python.app (1).executor": "Run", + "Python.app.executor": "Run", + "Python.app2.executor": "Run", + "Python.app_test (1).executor": "Run", + "Python.convert.executor": "Run", + "Python.converter_docling.executor": "Run", + "Python.converter_mineru.executor": "Run", + "Python.markdown_splitter.executor": "Debug", + "Python.markdown_utils.executor": "Run", + "Python.test.executor": "Run", + "Python.test1.executor": "Run", + "Python.test2.executor": "Run", + "Python.test3.executor": "Run", + "Python.test4.executor": "Run", + "Python.testhtml.executor": "Run", + "Python.translater.executor": "Run", + "Python.切分测试.executor": "Run", + "RunOnceActivity.ShowReadmeOnStart": "true", + "RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager": "true", + "RunOnceActivity.git.unshallow": "true", + "git-widget-placeholder": "main", + "last_opened_file_path": "C:/Users/jxgm/Desktop/translate/docutranslate", + "list.type.of.created.stylesheet": "CSS", + "node.js.detected.package.eslint": "true", + "node.js.detected.package.tslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "node.js.selected.package.tslint": "(autodetect)", + "nodejs_package_manager_path": "npm", + "settings.editor.selected.configurable": "preferences.pluginManager", + "vue.rearranger.settings.migration": "true" } -}]]> +} @@ -109,7 +110,7 @@ - + - + @@ -610,6 +611,7 @@ + @@ -632,14 +634,14 @@ file://$PROJECT_DIR$/docutranslate/translater.py - 240 + 241 - + @@ -658,7 +660,7 @@ - + diff --git a/docutranslate/__init__.py b/docutranslate/__init__.py index 933f19a..d6b6710 100644 --- a/docutranslate/__init__.py +++ b/docutranslate/__init__.py @@ -1,4 +1,4 @@ -__version__="0.2.26" +__version__="0.2.27" diff --git a/docutranslate/translater.py b/docutranslate/translater.py index 3f32d63..e819e91 100644 --- a/docutranslate/translater.py +++ b/docutranslate/translater.py @@ -10,6 +10,7 @@ from docutranslate.utils.markdown_splitter import split_markdown_text, join_mark from docutranslate.utils.markdown_utils import uris2placeholder, placeholder2_uris, MaskDict from docutranslate.logger import translater_logger from docutranslate.global_values import available_packages +from docutranslate.utils.resource_utils import resource_path DOCLING_FLAG = True if available_packages.get("docling") else False if DOCLING_FLAG: @@ -296,10 +297,10 @@ class FileTranslater: def export_to_html(self, title="title") -> str: markdowner = markdown2.Markdown(extras=['tables', 'fenced-code-blocks', 'mermaid', "code-friendly"]) # language=html - pico=Path(__file__).parent / "static" / "pico.css" - html = Path(__file__).parent / "template" / "markdown.html" - MathJax=Path(__file__).parent / "static" / "MathJax.js" - mermaid=Path(__file__).parent / "static" / "mermaid.js" + pico=resource_path("static/pico.css") + html = resource_path("template/markdown.html") + MathJax=resource_path( "static/MathJax.js") + mermaid=resource_path( "static/mermaid.js") #TODO:实现MathJax本地化 render = jinja2.Template(html.read_text()).render( title=title,