qparse 0.1.2__tar.gz → 0.1.4__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.
Files changed (42) hide show
  1. {qparse-0.1.2/qparse.egg-info → qparse-0.1.4}/PKG-INFO +2 -2
  2. {qparse-0.1.2 → qparse-0.1.4}/README.md +1 -1
  3. {qparse-0.1.2 → qparse-0.1.4}/pyproject.toml +1 -1
  4. {qparse-0.1.2 → qparse-0.1.4}/qparse/__init__.py +1 -1
  5. {qparse-0.1.2 → qparse-0.1.4}/qparse/markdwon_loader.py +16 -1
  6. {qparse-0.1.2 → qparse-0.1.4}/qparse/markdwon_render.py +9 -7
  7. {qparse-0.1.2 → qparse-0.1.4}/qparse/render_option/default_render_option.py +3 -0
  8. {qparse-0.1.2 → qparse-0.1.4}/qparse/render_option/theme.json +6 -0
  9. {qparse-0.1.2 → qparse-0.1.4/qparse.egg-info}/PKG-INFO +2 -2
  10. {qparse-0.1.2 → qparse-0.1.4}/LICENSE +0 -0
  11. {qparse-0.1.2 → qparse-0.1.4}/MANIFEST.in +0 -0
  12. {qparse-0.1.2 → qparse-0.1.4}/qparse/__main__.py +0 -0
  13. {qparse-0.1.2 → qparse-0.1.4}/qparse/docx_render/__init__.py +0 -0
  14. {qparse-0.1.2 → qparse-0.1.4}/qparse/docx_render/docx_render.py +0 -0
  15. {qparse-0.1.2 → qparse-0.1.4}/qparse/docx_render/write_buffer.py +0 -0
  16. {qparse-0.1.2 → qparse-0.1.4}/qparse/markdwon_document/__init__.py +0 -0
  17. {qparse-0.1.2 → qparse-0.1.4}/qparse/markdwon_document/analysis_document.py +0 -0
  18. {qparse-0.1.2 → qparse-0.1.4}/qparse/markdwon_document/base_document.py +0 -0
  19. {qparse-0.1.2 → qparse-0.1.4}/qparse/markdwon_document/markdwon_document.py +0 -0
  20. {qparse-0.1.2 → qparse-0.1.4}/qparse/markdwon_document/nodes/__init__.py +0 -0
  21. {qparse-0.1.2 → qparse-0.1.4}/qparse/markdwon_document/nodes/answer_node.py +0 -0
  22. {qparse-0.1.2 → qparse-0.1.4}/qparse/markdwon_document/nodes/base_node.py +0 -0
  23. {qparse-0.1.2 → qparse-0.1.4}/qparse/markdwon_document/nodes/img_node.py +0 -0
  24. {qparse-0.1.2 → qparse-0.1.4}/qparse/markdwon_document/nodes/text_node.py +0 -0
  25. {qparse-0.1.2 → qparse-0.1.4}/qparse/markdwon_document/question_document.py +0 -0
  26. {qparse-0.1.2 → qparse-0.1.4}/qparse/markdwon_document/stem_document.py +0 -0
  27. {qparse-0.1.2 → qparse-0.1.4}/qparse/markdwon_document/table_document.py +0 -0
  28. {qparse-0.1.2 → qparse-0.1.4}/qparse/qmd_cli.py +0 -0
  29. {qparse-0.1.2 → qparse-0.1.4}/qparse/qmd_packer.py +0 -0
  30. {qparse-0.1.2 → qparse-0.1.4}/qparse/qmd_unpacker.py +0 -0
  31. {qparse-0.1.2 → qparse-0.1.4}/qparse/render_option/__init__.py +0 -0
  32. {qparse-0.1.2 → qparse-0.1.4}/qparse/render_option/default_render_template.md +0 -0
  33. {qparse-0.1.2 → qparse-0.1.4}/qparse/render_option/referance.docx +0 -0
  34. {qparse-0.1.2 → qparse-0.1.4}/qparse/utils/__init__.py +0 -0
  35. {qparse-0.1.2 → qparse-0.1.4}/qparse/utils/html_full_protector.py +0 -0
  36. {qparse-0.1.2 → qparse-0.1.4}/qparse/utils/path_resolve.py +0 -0
  37. {qparse-0.1.2 → qparse-0.1.4}/qparse.egg-info/SOURCES.txt +0 -0
  38. {qparse-0.1.2 → qparse-0.1.4}/qparse.egg-info/dependency_links.txt +0 -0
  39. {qparse-0.1.2 → qparse-0.1.4}/qparse.egg-info/entry_points.txt +0 -0
  40. {qparse-0.1.2 → qparse-0.1.4}/qparse.egg-info/requires.txt +0 -0
  41. {qparse-0.1.2 → qparse-0.1.4}/qparse.egg-info/top_level.txt +0 -0
  42. {qparse-0.1.2 → qparse-0.1.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qparse
3
- Version: 0.1.2
3
+ Version: 0.1.4
4
4
  Summary: Structured Markdown lesson plans to DOCX, with .qmd pack/unpack tooling.
5
5
  Author: hanbuhuai
6
6
  License: MIT
@@ -278,7 +278,7 @@ Loader 会自动:
278
278
 
279
279
  生成规则:
280
280
 
281
- - 填空 / 选择 / 多选:连续客观题合并为 Markdown 表格
281
+ - 填空 / 选择 / 多选:连续客观题合并为 Markdown 表格,每行列数由 `reference-answer.table_max_columns` 控制(默认 4)
282
282
  - 简答:`题号、答案`(使用顿号,避免 Pandoc 识别为有序列表)
283
283
  - 答案只取文本,不保留原始 `<span>`
284
284
 
@@ -244,7 +244,7 @@ Loader 会自动:
244
244
 
245
245
  生成规则:
246
246
 
247
- - 填空 / 选择 / 多选:连续客观题合并为 Markdown 表格
247
+ - 填空 / 选择 / 多选:连续客观题合并为 Markdown 表格,每行列数由 `reference-answer.table_max_columns` 控制(默认 4)
248
248
  - 简答:`题号、答案`(使用顿号,避免 Pandoc 识别为有序列表)
249
249
  - 答案只取文本,不保留原始 `<span>`
250
250
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "qparse"
7
- version = "0.1.2"
7
+ version = "0.1.4"
8
8
  description = "Structured Markdown lesson plans to DOCX, with .qmd pack/unpack tooling."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -4,7 +4,7 @@ from .markdwon_render import MarkdwonRender
4
4
  from .qmd_packer import QmdPacker
5
5
  from .qmd_unpacker import QmdUnpacker
6
6
 
7
- __version__ = "0.1.2"
7
+ __version__ = "0.1.4"
8
8
 
9
9
  __all__ = [
10
10
  "MarkdownLoader",
@@ -4,6 +4,7 @@ from __future__ import annotations
4
4
  from cgitb import text
5
5
  import re,copy
6
6
  from pathlib import Path
7
+ from typing import Optional
7
8
 
8
9
  from bs4 import BeautifulSoup, element
9
10
 
@@ -133,10 +134,22 @@ class MarkdownLoader:
133
134
 
134
135
  return copy.deepcopy(soup.select_one('markdwon'))
135
136
 
136
- def get_reference_answer_markdwon(self) -> str:
137
+ def get_reference_answer_markdwon(self, render_option: dict | None = None) -> str:
137
138
  lines = []
138
139
  table_header = []
139
140
  table_answers = []
141
+ table_max_columns = 4
142
+ if render_option:
143
+ try:
144
+ table_max_columns = int(
145
+ render_option.get("reference-answer", {}).get(
146
+ "table_max_columns", 4
147
+ )
148
+ )
149
+ except (TypeError, ValueError):
150
+ table_max_columns = 4
151
+ if table_max_columns < 1:
152
+ table_max_columns = 4
140
153
 
141
154
  def flush_table():
142
155
  nonlocal table_header, table_answers
@@ -185,6 +198,8 @@ class MarkdownLoader:
185
198
 
186
199
  table_header.append(question_id)
187
200
  table_answers.append(answer)
201
+ if len(table_header) >= table_max_columns:
202
+ flush_table()
188
203
 
189
204
  flush_table()
190
205
  return "\n".join(lines).rstrip() + "\n"
@@ -7,7 +7,7 @@ from .markdwon_loader import MarkdownLoader
7
7
  from .docx_render import DocxRender
8
8
  from .markdwon_document import MarkdwonDocument
9
9
  from bs4 import BeautifulSoup,element
10
- from typing import Union
10
+ from typing import Optional, Union
11
11
  from .utils.path_resolve import resolve_resource_path
12
12
 
13
13
  class RenderToEnum(Enum):
@@ -40,7 +40,7 @@ class MarkdwonRender():
40
40
  @property
41
41
  def soup(self):
42
42
  return copy.deepcopy(self._markdwon_soup)
43
- def _parse_file_node(self,node:element.Tag):
43
+ def _parse_file_node(self,node:element.Tag, render_option: dict | None = None):
44
44
  source_soup = self.soup
45
45
  output_soup = BeautifulSoup(
46
46
  f'<markdwon src="{self._mdsrc.resolve()}"></markdwon>',
@@ -53,23 +53,25 @@ class MarkdwonRender():
53
53
  after = doc_node.find('after', recursive=False) if doc_node else None
54
54
 
55
55
  if before is not None:
56
- output.extend(self._translate_content(before))
56
+ output.extend(self._translate_content(before, render_option))
57
57
 
58
58
  output.extend(list(source_soup.contents))
59
59
 
60
60
  if after is not None:
61
- output.extend(self._translate_content(after))
61
+ output.extend(self._translate_content(after, render_option))
62
62
 
63
63
  return output
64
64
 
65
- def _translate_content(self, container:element.Tag):
65
+ def _translate_content(self, container:element.Tag, render_option: Optional[dict] = None):
66
66
  contents = []
67
67
  protector = self._markdwon_loader._protector
68
68
 
69
69
  for child in container.contents:
70
70
  if isinstance(child, element.Tag) and child.name == 'reference-answer':
71
71
  reference_answer = (
72
- self._markdwon_loader.get_reference_answer_markdwon()
72
+ self._markdwon_loader.get_reference_answer_markdwon(
73
+ render_option=render_option
74
+ )
73
75
  )
74
76
  encoded = protector.encode(reference_answer)
75
77
  decoded = protector.decode_to_html_entity(encoded)
@@ -93,7 +95,7 @@ class MarkdwonRender():
93
95
  self._theme.get(theme_name, self._theme)
94
96
  if theme_name else self._theme
95
97
  )
96
- markdown_node = self._parse_file_node(file_node)
98
+ markdown_node = self._parse_file_node(file_node, render_option)
97
99
  markdown_doc = MarkdwonDocument(
98
100
  node=markdown_node,
99
101
  render_option=render_option
@@ -26,6 +26,9 @@ def get_default_render_option():
26
26
  "cell_alignment": "center",
27
27
  }
28
28
  },
29
+ "reference-answer": {
30
+ "table_max_columns": 4,
31
+ },
29
32
  "markdown": {
30
33
  "head": {
31
34
  "downgrade_heading_level": True,
@@ -11,6 +11,9 @@
11
11
  "cell_alignment": "center"
12
12
  }
13
13
  },
14
+ "reference-answer": {
15
+ "table_max_columns": 4
16
+ },
14
17
  "markdown": {
15
18
  "head": {
16
19
  "downgrade_heading_level": true
@@ -173,6 +176,9 @@
173
176
  "cell_alignment": "center"
174
177
  }
175
178
  },
179
+ "reference-answer": {
180
+ "table_max_columns": 4
181
+ },
176
182
  "markdown": {
177
183
  "head": {
178
184
  "downgrade_heading_level": true
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qparse
3
- Version: 0.1.2
3
+ Version: 0.1.4
4
4
  Summary: Structured Markdown lesson plans to DOCX, with .qmd pack/unpack tooling.
5
5
  Author: hanbuhuai
6
6
  License: MIT
@@ -278,7 +278,7 @@ Loader 会自动:
278
278
 
279
279
  生成规则:
280
280
 
281
- - 填空 / 选择 / 多选:连续客观题合并为 Markdown 表格
281
+ - 填空 / 选择 / 多选:连续客观题合并为 Markdown 表格,每行列数由 `reference-answer.table_max_columns` 控制(默认 4)
282
282
  - 简答:`题号、答案`(使用顿号,避免 Pandoc 识别为有序列表)
283
283
  - 答案只取文本,不保留原始 `<span>`
284
284
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes