markdown-flow 0.3.2.dev1__py3-none-any.whl → 0.3.4__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 +1 -1
- markdown_flow/escaping.py +28 -2
- {markdown_flow-0.3.2.dev1.dist-info → markdown_flow-0.3.4.dist-info}/METADATA +1 -1
- {markdown_flow-0.3.2.dev1.dist-info → markdown_flow-0.3.4.dist-info}/RECORD +7 -7
- {markdown_flow-0.3.2.dev1.dist-info → markdown_flow-0.3.4.dist-info}/WHEEL +0 -0
- {markdown_flow-0.3.2.dev1.dist-info → markdown_flow-0.3.4.dist-info}/licenses/LICENSE +0 -0
- {markdown_flow-0.3.2.dev1.dist-info → markdown_flow-0.3.4.dist-info}/top_level.txt +0 -0
markdown_flow/__init__.py
CHANGED
markdown_flow/escaping.py
CHANGED
|
@@ -30,14 +30,40 @@ def is_escape(text: str, index: int) -> bool:
|
|
|
30
30
|
def escape_interaction_text(text: str) -> str:
|
|
31
31
|
"""Make `text` safe to write inside `?[...]`, keeping every character it has.
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
A dot is escaped only inside a run of three or more, because only `...` is a delimiter and a
|
|
34
|
+
single period ends most sentences: escaping every one turns `Yes, I agree.` into
|
|
35
|
+
`Yes, I agree\\.` in everything that stores or shows the raw interaction. Two dots cannot
|
|
36
|
+
become three on their own, and the run is escaped whole so it cannot be read as one.
|
|
37
|
+
|
|
38
|
+
Bars, brackets and slashes are escaped wherever they appear. They are rare in option text,
|
|
39
|
+
and escaping them unconditionally removes the need to reason about what a neighbouring
|
|
40
|
+
character might combine with once the option is written next to a separator.
|
|
41
|
+
|
|
42
|
+
Escaping the delimiters rather than the backslashes as well is what keeps existing content
|
|
34
43
|
readable: a script that writes `$\\pi$` in an option still writes `$\\pi$` afterwards.
|
|
35
44
|
"""
|
|
36
45
|
out: list[str] = []
|
|
37
|
-
|
|
46
|
+
index = 0
|
|
47
|
+
while index < len(text):
|
|
48
|
+
char = text[index]
|
|
49
|
+
if char == ".":
|
|
50
|
+
run = len(text) - index - len(text[index:].lstrip("."))
|
|
51
|
+
# A run of three or more is the `...` delimiter. A shorter one still needs escaping
|
|
52
|
+
# when a literal backslash precedes it, because the parser would read that backslash
|
|
53
|
+
# and the dot as an escape pair and drop the backslash -- `a\\.b` would come back as
|
|
54
|
+
# `a.b`, the round trip would fail, and the question would be refused. Escaping the
|
|
55
|
+
# dot puts a second backslash in front of it, which the parser reads as one literal
|
|
56
|
+
# backslash followed by an escaped dot: exactly the text that went in.
|
|
57
|
+
if run >= 3 or (index > 0 and text[index - 1] == "\\"):
|
|
58
|
+
out.append("\\." * run)
|
|
59
|
+
else:
|
|
60
|
+
out.append("." * run)
|
|
61
|
+
index += run
|
|
62
|
+
continue
|
|
38
63
|
if char in ESCAPABLE:
|
|
39
64
|
out.append("\\")
|
|
40
65
|
out.append(char)
|
|
66
|
+
index += 1
|
|
41
67
|
return "".join(out)
|
|
42
68
|
|
|
43
69
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: markdown-flow
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.4
|
|
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,9 +1,9 @@
|
|
|
1
|
-
markdown_flow/__init__.py,sha256=
|
|
1
|
+
markdown_flow/__init__.py,sha256=zhEntuF-oODjq0T_H-SV07V5d63nOHaOD7ECKqTuxxk,3520
|
|
2
2
|
markdown_flow/constants.py,sha256=oHfTFtNoIjgRNFXwhVRqcbo5o-DY0KtVxHJLDBfcX7c,14542
|
|
3
3
|
markdown_flow/constants_system_prompt.py,sha256=hzw6Ajm_lebqnXQmQMQFqJDmPCj6wugSPNs24lckn8c,617
|
|
4
4
|
markdown_flow/core.py,sha256=7sC4kZBHWndG6zh4DM2SqYAYA7c2Y7WcgwrtmPqvYFg,70443
|
|
5
5
|
markdown_flow/enums.py,sha256=Wr41zt0Ce5b3fyLtOTE2erEVp1n92g9OVaBF_BZg_l8,820
|
|
6
|
-
markdown_flow/escaping.py,sha256=
|
|
6
|
+
markdown_flow/escaping.py,sha256=EAWTg8_2UNdl0vnJ3I_utMaD3k2JVZ01_nHdLu5kOUg,6942
|
|
7
7
|
markdown_flow/exceptions.py,sha256=9sUZ-Jd3CPLdSRqG8Pw7eMm7cv_S3VZM6jmjUU8OhIc,976
|
|
8
8
|
markdown_flow/higher_priority_prompt.md,sha256=ms6HvMK4UZYr3cpUQRyJxUkMajSJ_gnmzgeJRVjTlwk,484
|
|
9
9
|
markdown_flow/llm.py,sha256=XH27meLtwcYigAPTJaX6fQYYup5HEb7MFZKAFsKV0Qg,2888
|
|
@@ -29,8 +29,8 @@ markdown_flow/parser/variable.py,sha256=3UwDSacqlXi7zfRm2ZA5D7h8fFMIL68iV6uFNqu-
|
|
|
29
29
|
markdown_flow/providers/__init__.py,sha256=QMr8H9gxoLr6pWXoAb11oZX_She6KWPxnRips537nQ4,319
|
|
30
30
|
markdown_flow/providers/config.py,sha256=NT6Sy_8j7Yy2zYwjEQ1XsG3NC_L_ABeQg2DJnct5QsE,3356
|
|
31
31
|
markdown_flow/providers/openai.py,sha256=09w1ruYzVOavtP7uE-osfEdAr97Fyjkr8gaGLqkgUrg,12434
|
|
32
|
-
markdown_flow-0.3.
|
|
33
|
-
markdown_flow-0.3.
|
|
34
|
-
markdown_flow-0.3.
|
|
35
|
-
markdown_flow-0.3.
|
|
36
|
-
markdown_flow-0.3.
|
|
32
|
+
markdown_flow-0.3.4.dist-info/licenses/LICENSE,sha256=qz3BziejhHPd1xa5eVtYEU5Qp6L2pn4otuj194uGxmc,1069
|
|
33
|
+
markdown_flow-0.3.4.dist-info/METADATA,sha256=_KpE_53tErYXkfqY7hmaOL4mxteleVHN9S-d8Zb0yDk,22376
|
|
34
|
+
markdown_flow-0.3.4.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
35
|
+
markdown_flow-0.3.4.dist-info/top_level.txt,sha256=DpigGvQuIt2L0TTLnDU5sylhiTGiZS7MmAMa2hi-AJs,14
|
|
36
|
+
markdown_flow-0.3.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|