markdown-flow 0.4.2.dev1__py3-none-any.whl → 0.4.2.dev3__py3-none-any.whl

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.
markdown_flow/__init__.py CHANGED
@@ -118,4 +118,4 @@ __all__ = [
118
118
  "format_variable_assignment",
119
119
  ]
120
120
 
121
- __version__ = "0.4.2.dev1"
121
+ __version__ = "0.4.2.dev3"
@@ -345,6 +345,7 @@ class DocumentBlocks:
345
345
  self.text = text
346
346
  self.html_pattern = html
347
347
  self._html_token_ends: dict[tuple[int, bool], int | None] = {}
348
+ self._container_ends: dict[tuple[int, bool], int] = {}
348
349
  self._html_last_ends: dict[str, int] | None = None
349
350
  self.lines = physical_lines(text)
350
351
  self.closed_fence_lines: set[int] = set()
@@ -414,15 +415,29 @@ class DocumentBlocks:
414
415
  steps = self.container_steps[index]
415
416
  if not steps:
416
417
  return len(self.text)
417
- for line in self.lines[index + 1 :]:
418
+ key = (index, final)
419
+ if key in self._container_ends:
420
+ return self._container_ends[key]
421
+ covered = [index]
422
+ end = len(self.text)
423
+ for following in range(index + 1, len(self.lines)):
424
+ line = self.lines[following]
418
425
  value = self.text[line.start : line.content_end]
419
426
  if container_content_start(value, steps) is None and value.strip(" \t"):
420
- if container_content_start(value, steps, partial=True) == len(value):
421
- continue
422
- if not final and line.end == line.content_end == len(self.text) and container_content_start(value, steps, partial=True) is not None:
423
- continue
424
- return line.start
425
- return len(self.text)
427
+ partial = container_content_start(value, steps, partial=True)
428
+ if not (partial == len(value) or not final and line.end == line.content_end == len(self.text) and partial is not None):
429
+ end = line.start
430
+ break
431
+ if self.container_steps[following] == steps:
432
+ following_key = (following, final)
433
+ if following_key in self._container_ends:
434
+ # The cached query excludes its own line, which was checked above.
435
+ end = self._container_ends[following_key]
436
+ break
437
+ covered.append(following)
438
+ for following in covered:
439
+ self._container_ends[(following, final)] = end
440
+ return end
426
441
 
427
442
  def fence(self, start: int, *, final: bool = True) -> BlockSpan | None:
428
443
  """Read plain or quote/list-contained fenced code."""
@@ -410,7 +410,8 @@ def _document_units(text: str) -> Iterator[tuple[int, int, bool]]:
410
410
  continue
411
411
  if text.startswith("?[", at):
412
412
  limit, closed = reader.blocks.interaction_limit(at + 2, lambda position: marker.end if (marker := read_variable_marker(text, position)) is not None else None)
413
- interaction_until = limit if closed else limit - 1
413
+ if not (closed and text[limit + 1 : limit + 2] == "("):
414
+ interaction_until = limit if closed else limit - 1
414
415
  if text.startswith("{{", at):
415
416
  marker = read_variable_marker(text, at)
416
417
  end = marker.end if marker is not None else len(text)
@@ -459,8 +460,11 @@ def find_document_interaction_spans(text: str) -> Iterator[tuple[int, int]]:
459
460
  if not closed:
460
461
  at = end
461
462
  continue
462
- if text[end + 1 : end + 2] != "(":
463
- yield at, end + 1
463
+ if text[end + 1 : end + 2] == "(":
464
+ # Replay the native label instead of losing its resource state.
465
+ at += 1
466
+ continue
467
+ yield at, end + 1
464
468
  at = end + 1
465
469
  else:
466
470
  at += 1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: markdown-flow
3
- Version: 0.4.2.dev1
3
+ Version: 0.4.2.dev3
4
4
  Summary: An agent library designed to parse and process MarkdownFlow documents
5
5
  Project-URL: Homepage, https://github.com/ai-shifu/markdown-flow-agent-py
6
6
  Project-URL: Bug Tracker, https://github.com/ai-shifu/markdown-flow-agent-py/issues
@@ -1,4 +1,4 @@
1
- markdown_flow/__init__.py,sha256=XSfhemi5Cti2orByhof6iK76QscSuCH0G0jlPaz2A4E,3857
1
+ markdown_flow/__init__.py,sha256=omKhFLfzW4zOrjQS9dqf_rDQEOn38m6vKBTiWhkqGrU,3857
2
2
  markdown_flow/constants.py,sha256=qRo3839u5PmAuHqhnTmbpwonE9cUg_A6ScnidZi_pP0,16546
3
3
  markdown_flow/constants_system_prompt.py,sha256=hzw6Ajm_lebqnXQmQMQFqJDmPCj6wugSPNs24lckn8c,617
4
4
  markdown_flow/core.py,sha256=LRU_0Dw8QPAe6LDo96lOzTI-jWv6HXHhAyulrlF2ruw,76190
@@ -20,8 +20,8 @@ markdown_flow/formatter/stream.py,sha256=TpGJKpht0Cm7j4p0lLvpbl_uTAq7dZ_gS7VEVF5
20
20
  markdown_flow/formatter/types.py,sha256=d92iTBZK8r7hir5dIv1vIGzX6YE7-pb1fh6DIT7FfnE,1329
21
21
  markdown_flow/parser/__init__.py,sha256=UtezItde4BC3g2b06SCxiBI-F8yhgj01lc_iPIzARPo,1184
22
22
  markdown_flow/parser/code_fence_utils.py,sha256=evpl9GL91PkU6r5sshgZay93x6qRs3TMbPrRyo5-_WI,5248
23
- markdown_flow/parser/document_blocks.py,sha256=srQN6wy_KNheG1rJiLFXJDGJhxqo0y8cWV-A8a8escg,29968
24
- markdown_flow/parser/document_context.py,sha256=3ePJl7__u0zucd8L5mJj4SriAJp_vIqvNJSMfR3SpJQ,19485
23
+ markdown_flow/parser/document_blocks.py,sha256=_AZzG9K9iRkP_H8VKnJalCkpvePlQNxLC_3_vGIKu_U,30671
24
+ markdown_flow/parser/document_context.py,sha256=bPQzFm7sgK2weGuptvMr6ipfr6W1iWu8BBh1jVaN1LU,19686
25
25
  markdown_flow/parser/html_comment_utils.py,sha256=-5OhYFVeHGB_fjEAHXCgyT-A3B3_zI2kkf0O4aXLHq4,3109
26
26
  markdown_flow/parser/interaction.py,sha256=PbS-XaRcyMDYLyzjApy6VTYQT4m2MjuPzS2W_ajpHGg,14501
27
27
  markdown_flow/parser/json_parser.py,sha256=7PLCj3rMn15kv7r6BC5mRizUWqSkpmpF9uLa9CY72NI,1633
@@ -32,8 +32,8 @@ markdown_flow/parser/variable.py,sha256=2W6KyfkUYsxPmhKvynvktgkQNvzmikVWVmZ7s7d5
32
32
  markdown_flow/providers/__init__.py,sha256=QMr8H9gxoLr6pWXoAb11oZX_She6KWPxnRips537nQ4,319
33
33
  markdown_flow/providers/config.py,sha256=NT6Sy_8j7Yy2zYwjEQ1XsG3NC_L_ABeQg2DJnct5QsE,3356
34
34
  markdown_flow/providers/openai.py,sha256=09w1ruYzVOavtP7uE-osfEdAr97Fyjkr8gaGLqkgUrg,12434
35
- markdown_flow-0.4.2.dev1.dist-info/licenses/LICENSE,sha256=qz3BziejhHPd1xa5eVtYEU5Qp6L2pn4otuj194uGxmc,1069
36
- markdown_flow-0.4.2.dev1.dist-info/METADATA,sha256=YmjE-852HzO-SJk1J449nZYFj_ohInATtJrEo3OG4JQ,24718
37
- markdown_flow-0.4.2.dev1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
38
- markdown_flow-0.4.2.dev1.dist-info/top_level.txt,sha256=DpigGvQuIt2L0TTLnDU5sylhiTGiZS7MmAMa2hi-AJs,14
39
- markdown_flow-0.4.2.dev1.dist-info/RECORD,,
35
+ markdown_flow-0.4.2.dev3.dist-info/licenses/LICENSE,sha256=qz3BziejhHPd1xa5eVtYEU5Qp6L2pn4otuj194uGxmc,1069
36
+ markdown_flow-0.4.2.dev3.dist-info/METADATA,sha256=tMKInG4hurVLS-zKm3icn-5j6SJYDr8gWRjcPXW5P0Y,24718
37
+ markdown_flow-0.4.2.dev3.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
38
+ markdown_flow-0.4.2.dev3.dist-info/top_level.txt,sha256=DpigGvQuIt2L0TTLnDU5sylhiTGiZS7MmAMa2hi-AJs,14
39
+ markdown_flow-0.4.2.dev3.dist-info/RECORD,,