hos-m2f 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
hos_m2f-0.5.0/PKG-INFO ADDED
@@ -0,0 +1,22 @@
1
+ Metadata-Version: 2.4
2
+ Name: hos-m2f
3
+ Version: 0.5.0
4
+ Summary: HOS-M2F: Markdown to Industry Standard Format Compiler Engine
5
+ Author: HOS Team
6
+ Author-email: team@hos-m2f.com
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.8
11
+ Requires-Dist: mistune>=2.0.0
12
+ Requires-Dist: pyyaml>=6.0
13
+ Requires-Dist: click>=8.0.0
14
+ Requires-Dist: ebooklib>=0.17.0
15
+ Requires-Dist: weasyprint>=54.0
16
+ Requires-Dist: python-docx>=0.8.11
17
+ Dynamic: author
18
+ Dynamic: author-email
19
+ Dynamic: classifier
20
+ Dynamic: requires-dist
21
+ Dynamic: requires-python
22
+ Dynamic: summary
@@ -0,0 +1,130 @@
1
+ # HOS-M2F v1.0
2
+
3
+ ## 多场景结构化内容编译引擎
4
+
5
+ HOS-M2F = 面向 AI 写作与专业文档生产的 **内容编译器引擎**
6
+
7
+ Markdown 是源码,不同 Mode 是"目标行业标准"
8
+
9
+ ## 核心功能
10
+
11
+ ### 内置官方模式
12
+
13
+ | Mode | 领域 | 核心产出 |
14
+ | --------- | ----- | -------------- |
15
+ | `paper` | 技术文档 | 报告 / 论文排版 |
16
+ | `patent` | 专利申请 | 合规专利文件 |
17
+ | `book` 📚 | 电子书出版 | EPUB / KDP |
18
+ | `sop` 🛠 | 运维与实施 | 巡检 / 报错 / 实施报告 |
19
+
20
+ ### 输出支持
21
+
22
+ | 平台 | 格式 |
23
+ | ---------- | ----------- |
24
+ | Amazon KDP | EPUB / DOCX |
25
+ | Kindle | MOBI / AZW3 |
26
+ | 通用阅读器 | EPUB 3 |
27
+ | 印刷 | Print PDF |
28
+ | 企业系统 | JSON / HTML |
29
+
30
+ ## 安装
31
+
32
+ ```bash
33
+ pip install -e .
34
+ ```
35
+
36
+ ## 使用方法
37
+
38
+ ### CLI 命令
39
+
40
+ ```bash
41
+ # 构建
42
+ HOS_M2F build input.md --mode book
43
+ HOS_M2F build report.md --mode sop --format pdf
44
+
45
+ # 校验
46
+ HOS_M2F check book.md --mode book --platform kdp
47
+ HOS_M2F check report.md --mode sop
48
+
49
+ # 批量
50
+ HOS_M2F build ./reports/ --mode sop --batch
51
+ ```
52
+
53
+ ### Python SDK
54
+
55
+ ```python
56
+ from hos_m2f import Engine
57
+
58
+ engine = Engine()
59
+
60
+ result = engine.build(
61
+ content=markdown_text,
62
+ mode="book",
63
+ output_format="epub",
64
+ options={"platform": "kdp"}
65
+ )
66
+
67
+ with open("output.epub", "wb") as f:
68
+ f.write(result.binary)
69
+ ```
70
+
71
+ ## 项目结构
72
+
73
+ ```
74
+ hos_m2f/
75
+ ├── engine/ # ⭐ 对外统一引擎接口
76
+ │ └── engine.py
77
+
78
+ ├── modes/ # 内置模式
79
+ │ ├── book_mode.py
80
+ │ ├── patent_mode.py
81
+ │ ├── sop_mode.py
82
+ │ └── paper_mode.py
83
+
84
+ ├── user_modes/ # 用户自定义模式
85
+ │ └── *.yaml
86
+
87
+ ├── structure/ # 结构解析层
88
+ │ ├── semantic_parser.py
89
+ │ ├── book_parser.py
90
+ │ ├── patent_parser.py
91
+ │ └── sop_parser.py
92
+
93
+ ├── renderers/ # 渲染适配层
94
+ │ ├── epub_renderer.py
95
+ │ ├── pdf_renderer.py
96
+ │ ├── docx_renderer.py
97
+ │ └── json_renderer.py
98
+
99
+ └── ide/ # IDE 集成接口
100
+ ├── api.py
101
+ └── preview_server.py
102
+ ```
103
+
104
+ ## 扩展能力
105
+
106
+ ### 语义校验引擎
107
+ - 专利是否缺少摘要
108
+ - 书籍是否缺版权页
109
+ - SOP 是否缺结论
110
+
111
+ ### 风格主题系统
112
+ 企业可统一视觉风格:
113
+
114
+ ```yaml
115
+ theme: blue_enterprise
116
+ font: Source Han Sans
117
+ cover_style: minimal
118
+ ```
119
+
120
+ ### 增量构建能力
121
+ 只更新修改过的章节,提高大书籍或长报告构建速度
122
+
123
+ ### 结构化数据导出
124
+ SOP 报告可导出 JSON 供企业系统分析
125
+
126
+ ### AI 协同接口(未来扩展)
127
+ 让大模型直接输出符合某 Mode 的结构,而不是自由 Markdown
128
+
129
+ ## 许可证
130
+ MIT License
@@ -0,0 +1,8 @@
1
+ """HOS-M2F: Markdown to Industry Standard Format Compiler Engine"""
2
+
3
+ __version__ = "1.0.0"
4
+ __author__ = "HOS Team"
5
+
6
+ from hos_m2f.engine.engine import Engine
7
+
8
+ __all__ = ["Engine"]
@@ -0,0 +1,5 @@
1
+ """CLI模块"""
2
+
3
+ from hos_m2f.cli.cli import CLI
4
+
5
+ __all__ = ['CLI']
@@ -0,0 +1,278 @@
1
+ """CLI命令体系模块"""
2
+
3
+ import argparse
4
+ import json
5
+ import sys
6
+ from typing import Dict, Any, Optional
7
+ from hos_m2f.engine.engine import Engine
8
+ from hos_m2f.ide.preview_server import PreviewServer
9
+
10
+
11
+ class CLI:
12
+ """命令行接口"""
13
+
14
+ def __init__(self):
15
+ self.engine = Engine()
16
+ self.parser = argparse.ArgumentParser(
17
+ prog='hos-m2f',
18
+ description='HOS-M2F v1.0 - Content Compiler Engine for AI Writing and Professional Document Production',
19
+ epilog='For more information, visit the project documentation.'
20
+ )
21
+ self.subparsers = self.parser.add_subparsers(dest='command', help='Available commands')
22
+ self._setup_commands()
23
+
24
+ def _setup_commands(self):
25
+ """设置命令"""
26
+ # build命令
27
+ build_parser = self.subparsers.add_parser('build', help='Build document from Markdown')
28
+ build_parser.add_argument('input', help='Input Markdown file')
29
+ build_parser.add_argument('output', help='Output file path')
30
+ build_parser.add_argument('--mode', choices=['book', 'patent', 'sop', 'paper'], default='paper', help='Document mode')
31
+ build_parser.add_argument('--format', choices=['epub', 'pdf', 'docx', 'json'], default='epub', help='Output format')
32
+ build_parser.add_argument('--options', type=str, default='{}', help='Additional options as JSON string')
33
+
34
+ # check命令
35
+ check_parser = self.subparsers.add_parser('check', help='Check document structure and compliance')
36
+ check_parser.add_argument('input', help='Input Markdown file')
37
+ check_parser.add_argument('--mode', choices=['book', 'patent', 'sop', 'paper'], default='paper', help='Document mode')
38
+ check_parser.add_argument('--options', type=str, default='{}', help='Additional options as JSON string')
39
+
40
+ # parse命令
41
+ parse_parser = self.subparsers.add_parser('parse', help='Parse Markdown content and output structured data')
42
+ parse_parser.add_argument('input', help='Input Markdown file')
43
+ parse_parser.add_argument('--mode', choices=['book', 'patent', 'sop', 'paper'], default='paper', help='Document mode')
44
+ parse_parser.add_argument('--output', help='Output JSON file (default: stdout)')
45
+ parse_parser.add_argument('--options', type=str, default='{}', help='Additional options as JSON string')
46
+
47
+ # preview命令
48
+ preview_parser = self.subparsers.add_parser('preview', help='Start preview server')
49
+ preview_parser.add_argument('--port', type=int, default=8000, help='Port to run the server on')
50
+
51
+ # info命令
52
+ info_parser = self.subparsers.add_parser('info', help='Show information about supported modes and formats')
53
+ info_parser.add_argument('--detail', action='store_true', help='Show detailed information')
54
+
55
+ # validate命令
56
+ validate_parser = self.subparsers.add_parser('validate', help='Validate options for a specific mode')
57
+ validate_parser.add_argument('--mode', choices=['book', 'patent', 'sop', 'paper'], required=True, help='Document mode')
58
+ validate_parser.add_argument('--options', type=str, required=True, help='Options to validate as JSON string')
59
+
60
+ def run(self, args=None):
61
+ """运行命令
62
+
63
+ Args:
64
+ args: 命令行参数
65
+
66
+ Returns:
67
+ int: 退出码
68
+ """
69
+ if args is None:
70
+ args = sys.argv[1:]
71
+
72
+ parsed_args = self.parser.parse_args(args)
73
+
74
+ if not parsed_args.command:
75
+ self.parser.print_help()
76
+ return 1
77
+
78
+ try:
79
+ if parsed_args.command == 'build':
80
+ return self._run_build(parsed_args)
81
+ elif parsed_args.command == 'check':
82
+ return self._run_check(parsed_args)
83
+ elif parsed_args.command == 'parse':
84
+ return self._run_parse(parsed_args)
85
+ elif parsed_args.command == 'preview':
86
+ return self._run_preview(parsed_args)
87
+ elif parsed_args.command == 'info':
88
+ return self._run_info(parsed_args)
89
+ elif parsed_args.command == 'validate':
90
+ return self._run_validate(parsed_args)
91
+ else:
92
+ self.parser.print_help()
93
+ return 1
94
+ except Exception as e:
95
+ print(f'Error: {e}', file=sys.stderr)
96
+ return 1
97
+
98
+ def _run_build(self, args):
99
+ """运行build命令"""
100
+ # 读取输入文件
101
+ with open(args.input, 'r', encoding='utf-8') as f:
102
+ content = f.read()
103
+
104
+ # 解析选项
105
+ options = json.loads(args.options)
106
+
107
+ # 构建文档
108
+ result = self.engine.build(content, args.mode, args.format, options)
109
+
110
+ # 写入输出文件
111
+ with open(args.output, 'wb') as f:
112
+ f.write(result.binary)
113
+
114
+ print(f'Successfully built {args.output}')
115
+ print(f'Output format: {result.output_format}')
116
+ if result.metadata:
117
+ print('Metadata:', json.dumps(result.metadata, ensure_ascii=False, indent=2))
118
+
119
+ return 0
120
+
121
+ def _run_check(self, args):
122
+ """运行check命令"""
123
+ # 读取输入文件
124
+ with open(args.input, 'r', encoding='utf-8') as f:
125
+ content = f.read()
126
+
127
+ # 解析选项
128
+ options = json.loads(args.options)
129
+
130
+ # 检查文档
131
+ result = self.engine.check(content, args.mode, options)
132
+
133
+ # 输出结果
134
+ print('Check result:')
135
+ print(json.dumps(result, ensure_ascii=False, indent=2))
136
+
137
+ # 检查是否有问题
138
+ if 'compliance' in result and not result['compliance'].get('compliant', True):
139
+ print('\nIssues found:', file=sys.stderr)
140
+ for issue in result['compliance'].get('issues', []):
141
+ print(f' - {issue}', file=sys.stderr)
142
+ return 1
143
+
144
+ print('\nNo issues found!')
145
+ return 0
146
+
147
+ def _run_parse(self, args):
148
+ """运行parse命令"""
149
+ # 读取输入文件
150
+ with open(args.input, 'r', encoding='utf-8') as f:
151
+ content = f.read()
152
+
153
+ # 解析选项
154
+ options = json.loads(args.options)
155
+
156
+ # 根据模式选择解析器
157
+ if args.mode == 'book':
158
+ from hos_m2f.structure.book_parser import BookParser
159
+ parser = BookParser()
160
+ elif args.mode == 'patent':
161
+ from hos_m2f.structure.patent_parser import PatentParser
162
+ parser = PatentParser()
163
+ elif args.mode == 'sop':
164
+ from hos_m2f.structure.sop_parser import SOPParser
165
+ parser = SOPParser()
166
+ else:
167
+ from hos_m2f.structure.semantic_parser import SemanticParser
168
+ parser = SemanticParser()
169
+
170
+ # 解析内容
171
+ result = parser.parse(content, options)
172
+
173
+ # 输出结果
174
+ output_data = json.dumps(result, ensure_ascii=False, indent=2)
175
+
176
+ if args.output:
177
+ with open(args.output, 'w', encoding='utf-8') as f:
178
+ f.write(output_data)
179
+ print(f'Successfully parsed to {args.output}')
180
+ else:
181
+ print(output_data)
182
+
183
+ return 0
184
+
185
+ def _run_preview(self, args):
186
+ """运行preview命令"""
187
+ server = PreviewServer(port=args.port)
188
+ result = server.start()
189
+
190
+ if result['success']:
191
+ print(f'Preview server started on port {args.port}')
192
+ print(f'Access at: http://localhost:{args.port}')
193
+ print('Press Ctrl+C to stop the server')
194
+
195
+ # 保持运行
196
+ try:
197
+ import time
198
+ while True:
199
+ time.sleep(1)
200
+ except KeyboardInterrupt:
201
+ print('\nStopping server...')
202
+ server.stop()
203
+ print('Server stopped')
204
+ else:
205
+ print(f'Failed to start server: {result["error"]}', file=sys.stderr)
206
+ return 1
207
+
208
+ return 0
209
+
210
+ def _run_info(self, args):
211
+ """运行info命令"""
212
+ print('HOS-M2F v1.0 - Content Compiler Engine')
213
+ print('=====================================')
214
+
215
+ # 显示支持的模式
216
+ print('\nSupported modes:')
217
+ modes = self.engine.get_supported_modes()
218
+ for mode, description in modes.items():
219
+ print(f' - {mode}: {description}')
220
+
221
+ # 显示支持的格式
222
+ print('\nSupported output formats:')
223
+ formats = self.engine.get_supported_formats()
224
+ for fmt, description in formats.items():
225
+ print(f' - {fmt}: {description}')
226
+
227
+ if args.detail:
228
+ print('\nDetailed information:')
229
+ print('\nBook mode:')
230
+ print(' Description: Supports chapter structure recognition, TOC generation, metadata packaging, cover recognition')
231
+ print(' Output formats: epub, pdf, docx, json')
232
+
233
+ print('\nPatent mode:')
234
+ print(' Description: Supports automatic claim numbering, patent paragraph indentation, figure numbering')
235
+ print(' Output formats: pdf, docx, json')
236
+
237
+ print('\nSOP mode:')
238
+ print(' Description: Supports step numbering, checklist tabularization, risk level identification')
239
+ print(' Output formats: pdf, docx, json')
240
+
241
+ print('\nPaper mode:')
242
+ print(' Description: Supports technical documents and paper formatting')
243
+ print(' Output formats: pdf, docx, json')
244
+
245
+ return 0
246
+
247
+ def _run_validate(self, args):
248
+ """运行validate命令"""
249
+ # 解析选项
250
+ options = json.loads(args.options)
251
+
252
+ # 验证选项
253
+ from hos_m2f.ide.api import IDEAPI
254
+ api = IDEAPI()
255
+ result = api.validate_options(args.mode, options)
256
+
257
+ # 输出结果
258
+ print('Validation result:')
259
+ print(json.dumps(result, ensure_ascii=False, indent=2))
260
+
261
+ if not result['valid']:
262
+ print('\nValidation failed:', file=sys.stderr)
263
+ for error in result['errors']:
264
+ print(f' - {error}', file=sys.stderr)
265
+ return 1
266
+
267
+ print('\nValidation passed!')
268
+ return 0
269
+
270
+
271
+ def main():
272
+ """CLI命令入口点"""
273
+ cli = CLI()
274
+ sys.exit(cli.run())
275
+
276
+ # 命令行入口
277
+ if __name__ == '__main__':
278
+ main()
@@ -0,0 +1,22 @@
1
+ Metadata-Version: 2.4
2
+ Name: hos-m2f
3
+ Version: 0.5.0
4
+ Summary: HOS-M2F: Markdown to Industry Standard Format Compiler Engine
5
+ Author: HOS Team
6
+ Author-email: team@hos-m2f.com
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.8
11
+ Requires-Dist: mistune>=2.0.0
12
+ Requires-Dist: pyyaml>=6.0
13
+ Requires-Dist: click>=8.0.0
14
+ Requires-Dist: ebooklib>=0.17.0
15
+ Requires-Dist: weasyprint>=54.0
16
+ Requires-Dist: python-docx>=0.8.11
17
+ Dynamic: author
18
+ Dynamic: author-email
19
+ Dynamic: classifier
20
+ Dynamic: requires-dist
21
+ Dynamic: requires-python
22
+ Dynamic: summary
@@ -0,0 +1,11 @@
1
+ README.md
2
+ setup.py
3
+ hos_m2f/__init__.py
4
+ hos_m2f.egg-info/PKG-INFO
5
+ hos_m2f.egg-info/SOURCES.txt
6
+ hos_m2f.egg-info/dependency_links.txt
7
+ hos_m2f.egg-info/entry_points.txt
8
+ hos_m2f.egg-info/requires.txt
9
+ hos_m2f.egg-info/top_level.txt
10
+ hos_m2f/cli/__init__.py
11
+ hos_m2f/cli/cli.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ hos-m2f = hos_m2f.cli.cli:main
@@ -0,0 +1,6 @@
1
+ mistune>=2.0.0
2
+ pyyaml>=6.0
3
+ click>=8.0.0
4
+ ebooklib>=0.17.0
5
+ weasyprint>=54.0
6
+ python-docx>=0.8.11
@@ -0,0 +1 @@
1
+ hos_m2f
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
hos_m2f-0.5.0/setup.py ADDED
@@ -0,0 +1,30 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="hos-m2f",
5
+ version="0.5.0",
6
+ description="HOS-M2F: Markdown to Industry Standard Format Compiler Engine",
7
+ author="HOS Team",
8
+ author_email="team@hos-m2f.com",
9
+ packages=find_packages(),
10
+ include_package_data=True,
11
+ install_requires=[
12
+ "mistune>=2.0.0",
13
+ "pyyaml>=6.0",
14
+ "click>=8.0.0",
15
+ "ebooklib>=0.17.0",
16
+ "weasyprint>=54.0",
17
+ "python-docx>=0.8.11"
18
+ ],
19
+ entry_points={
20
+ "console_scripts": [
21
+ "hos-m2f=hos_m2f.cli.cli:main"
22
+ ]
23
+ },
24
+ classifiers=[
25
+ "Programming Language :: Python :: 3",
26
+ "License :: OSI Approved :: MIT License",
27
+ "Operating System :: OS Independent",
28
+ ],
29
+ python_requires='>=3.8'
30
+ )