Skip to content

Commit 9a6d309

Browse files
deploy: 18b4fa1
0 parents  commit 9a6d309

38 files changed

Lines changed: 17343 additions & 0 deletions

.nojekyll

Whitespace-only changes.

04_exhash.html

Lines changed: 670 additions & 0 deletions
Large diffs are not rendered by default.

04_exhash.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
2+
3+
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
4+
5+
The quick brown fox jumps over the lazy dog. Jackdaws love my big sphinx
6+
of quartz. Pack my box with five dozen liquor jugs. How vexingly quick
7+
daft zebras jump! The five boxing wizards jump quickly. Sphinx of black
8+
quartz, judge my vow. Two driven jocks help fax my big quiz. Bright
9+
vixens jump; dozy fowl quack.
10+
11+
``` python
12+
msg = await read_msg()
13+
id_ = msg.id
14+
cts = msg.content
15+
```
16+
17+
<div class="prose" markdown="1">
18+
19+
------------------------------------------------------------------------
20+
21+
<a
22+
href="https://github.com/AnswerDotAI/dialoghelper/blob/main/dialoghelper/exhash.py#L12"
23+
target="_blank" style="float:right; font-size:smaller">source</a>
24+
25+
### lnhashview_msg
26+
27+
``` python
28+
async def lnhashview_msg(
29+
id:str, # id of message to view
30+
dname:str='', # Dialog containing message; defaults to current dialog
31+
start_line:int=None, # Starting line (1-based) to view (defaults to 1st line if None)
32+
end_line:int=None, # End line (defaults to last line if None)
33+
)->str:
34+
```
35+
36+
*Show lnhash-addressed lines of a message*
37+
38+
</div>
39+
40+
``` python
41+
await lnhashview_msg(id_, end_line=4)
42+
```
43+
44+
1|da2a|The quick brown fox jumps over the lazy dog.
45+
2|32e4|Jackdaws love my big sphinx of quartz.
46+
3|04e4|Pack my box with five dozen liquor jugs.
47+
4|025f|How vexingly quick daft zebras jump!
48+
49+
<div class="prose" markdown="1">
50+
51+
------------------------------------------------------------------------
52+
53+
<a
54+
href="https://github.com/AnswerDotAI/dialoghelper/blob/main/dialoghelper/exhash.py#L25"
55+
target="_blank" style="float:right; font-size:smaller">source</a>
56+
57+
### msg_exhash
58+
59+
``` python
60+
async def msg_exhash(
61+
id:str, # id of message to edit
62+
cmds:list, # List of exhash command tuples to apply
63+
dname:str='', # Dialog containing message; defaults to current dialog
64+
)->str:
65+
```
66+
67+
*Verified line-addressed editor. Apply command tuples to msg `id`
68+
contents, return lnhash diff.* **NB**: every command is a tuple whose
69+
first element is an address string. **NB**: hashes are checked against
70+
the current text immediately before each command runs; order commands
71+
last-\>first.
72+
73+
Use `lnhashview_msg(id)` to get hash-verified addresses before first
74+
use.
75+
76+
Address strings: Single: `12|a3f2|` Range: `12|a3f2|,15|b1c3|` Last: `$`
77+
(last line) Whole: `%` (whole file, same as `1,$`) Special: `0|0000|`
78+
targets before line 1 (only with a or i)
79+
80+
Command tuples: (addr, “s”, pattern, replacement\[, flags\]) Substitute
81+
(Rust regex syntax). Replacement supports $1, $0, ${name}. Flags: g=all,
82+
i=case-insensitive. args may contain literal / & newlines (addr, “d”)
83+
Delete line(s) (addr, “a”, text) Append payload after line (addr, “i”,
84+
text) Insert payload before line (addr, “c”, text) Change/replace with
85+
payload (addr, “j”) Join with next line; with range, joins all (addr,
86+
“m”, dest) Move line(s) after dest address (addr, “t”, dest) Copy
87+
line(s) after dest address (addr, “\>”, n) Indent n levels (default 1, 4
88+
spaces each) (addr, “\<”, n) Dedent n levels (default 1) (addr, “sort”)
89+
Sort lines alphabetically (addr, “p”) Print (include in output without
90+
changing) (addr, “g”, payload), (addr, “g!”, payload), (addr, “v”,
91+
payload) Global commands; payload uses compact ex syntax such as
92+
`/pattern/d` (addr, “y”, payload) Transliterate; payload uses compact ex
93+
syntax such as `/abc/ABC/`
94+
95+
`cmds` is a required list of command tuples. Text fields may contain
96+
newlines, including multiline a/i/c payloads and s pattern/replacement
97+
fields; payloads are inserted literally. Do NOT add a trailing `.` line
98+
— the string boundary ends the block. A trailing `.` will be inserted
99+
literally (with a warning).
100+
101+
</div>

0 commit comments

Comments
 (0)