You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DEV.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,7 +86,7 @@ Maturin's `data` option in `pyproject.toml` points to `python/exhash.data/`. Fil
86
86
87
87
The Rust core has three parsing functions:
88
88
89
-
-`parse_commands_from_strs(&[&str])` — for the Python API; each string is one command, text blocks are the remaining lines (no `.` terminator)
89
+
-`parse_commands_from_strs(&[&str])` — for the Python API; each string is one command, text blocks are the remaining lines (no `.` terminator; a trailing `.` line is literal text and the Python binding warns about this common mistake)
90
90
-`parse_commands_from_script(&str)` — for script strings; commands separated by newlines, text blocks terminated by `.`
91
91
-`parse_commands_from_args(&[String], &mut BufRead)` — for the CLI; each arg is a command, text blocks read from stdin terminated by `.`
Copy file name to clipboardExpand all lines: README.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -108,7 +108,7 @@ view = lnhashview_file("f.py") # same but reads from file
108
108
109
109
### Editing
110
110
111
-
`exhash(text, cmds, sw=4)` takes the text and a required iterable of command strings (use `[]` for no-op). `sw` controls how far `<` and `>` shift. For `a`/`i`/`c` commands, lines after the command are the text block (no `.`terminator needed):
111
+
`exhash(text, cmds, sw=4)` takes the text and a required iterable of command strings (use `[]` for no-op). `sw` controls how far `<` and `>` shift. For `a`/`i`/`c` commands, lines after the command are the text block. Do not include an ex-style trailing `.`line here: unlike CLI/script mode, `exhash(text, cmds)` does not use one, and a final `.` line is inserted literally.
112
112
113
113
```py
114
114
addr = lnhash(1, "foo") # "1|a1b2|"
@@ -126,6 +126,9 @@ res = exhash(text, [f"{a1}s/foo/FOO/", f"{a2}s/bar/BAR/"])
126
126
# Append multiline text (no dot terminator)
127
127
res = exhash(text, [f"{addr}a\nnew line 1\nnew line 2"])
128
128
129
+
# Wrong for the Python API: the trailing "." would be inserted literally
130
+
# res = exhash(text, [f"{addr}a\nnew line 1\nnew line 2\n."])
'Like ``exhash`` but reads from file at ``path``. If ``inplace``, writes back and returns diff string.'
93
+
'Like ``exhash`` but reads from file at ``path``. Uses the same no-``.``-terminator rule for a/i/c text blocks. If ``inplace``, writes back and returns diff string.'
"cmds[{i}] ends with a '.' line. In exhash(text, cmds), a/i/c text blocks do not use ex-style '.' terminators; that final '.' line will be inserted literally."
0 commit comments