Block deletion
#1299
Replies: 1 comment
-
|
Hi! This issue has been fixed in mq v0.5.16. When outputting Markdown, blank lines that appeared after deletion operations are no longer emitted. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
I`m asking for help!
We're building a set of bash scripts to manipulate .md documentation files using mq. The core operations needed:
Insert works perfectly via find_index + insert. Extract works via find_index + slice. The problem is deletion.
What we tried:
slice(0, blk_start) + slice(blk_end, len) — logically correct, but produces 8–10 blank lines at the deletion site instead of 1.
nodes | filter_sections(fn(s): title(s) != block_title;) | collect() — cleaner approach, same result.
nodes | sections() | filter(...) | collect() — same.
Root cause identified (maybe): mq stores source file positions inside node objects. When two nodes that were originally far apart (e.g. line 20 and line 38) become
adjacent after deletion, the renderer fills the gap with blank lines. This happens regardless of whether we use slice+concat, del, or filter_sections.
What doesn't help: filter, del, map, all_nodes + flatten — all preserve original positions.
Question: Is there a way to "normalize" node positions after deletion, so the renderer doesn't insert blank lines? For example, a way to re-parse the result, or a
flag/function that strips position metadata from nodes?
My final goal is to move section from "Curreont work" to "Completed". Maybe there is another approach to achieve this instead of extract-delete-insert.
mq version: 0.5.15
Beta Was this translation helpful? Give feedback.
All reactions