Zettelkasten Forum


zettel_outline script includes Zettels in draft file that weren't included in outline file

edited April 2022 in Software & Gadgets

First things first, thanks @ctietze for the script. I'm in the process of adding Structure Notes to my Zettelkasten and your script is perfect for part of the job involved.

However, I've run into the problem described in this post's title. To make sure that I'm understood and to include all potentially important information, I'll elaborate.

I have an outline whose filename is 202204091330 s2 Obsidian.md. It lists links in the same vein as the outline example from your post about the script. This file is in the home folder of my Ubuntu 21.10. The output of zettel_outline --version is zettel_outline 0.1.1 (2016-01-23). Nothing weird appears in the terminal when I run the script:

zettel_outline -f '202204091330 s2 Obsidian.md' -a /home/annabella/Archive/Zettelkasten/ -o draft.md

Everything seems fine at first in the draft. At a closer look, I find the whole content of a Zettel that wasn't linked to, spread 16 times thorough it. Unlike the other Zettels, the <!-- § --> part doesn't include its unique identifier. I checked my Zettelkasten to see if its unique identifier happened to be that of another Zettel, but it wasn't the case. The Zettels from the outline don't link to this Zettel and this Zettel doesn't link to them.

Any idea of what I could be doing wrong? I'll include any information you need on demand.

Comments

  • I'll mentally bookmark this issue. When this week, finally I get back to playing with assembling a draft based on my notes, I'll have to use the script, too :)

    If you want to play around with figuring out the issue in the meantime, here's what I'd do (in a copy of my notes, not the real ZK, of course!!11):

    • Does the script error-out in any way if you remove (rename) the note that's not supposed to be there? Does the script instead spread another random note everywhere?
    • If you replace all links to [[202204110929 Offending Note]] in your notes with a link to another note, will that other note be inserted? -- If not, then the script is stupid :) If yes, then the script gets the idea to insert this note from somewhere: What if you replace only 50% of the links? From which half does the script pick the ID to randomly insert? Then progressively reduce ("bisect") until you find the note(s) that determine which one is inserted.-

    Author at Zettelkasten.de • https://christiantietze.de/

  • @ctietze

    That's perfect! I was trying to figure out why the script did that to help you, but scripting is out of my league, haha.

    Today's my day off, so no testing today. :( But I'll gladly do that tomorrow and let you know of how it goes.

    Thanks for following up on this. :)

  • edited April 2022

    @ctietze

    Does the script error-out in any way if you remove (rename) the note that's not supposed to be there? Does the script instead spread another random note everywhere?

    Second. It does the second, every single time. I removed the troublesome Zettel, then ran the script. A different Zettel found its way in. I removed that one, then ran the script again. Same thing. I did that 10 times or so. The outcome was the same all the time. And it always was one Zettel. In Robo-Fortune's voice: Recursive villain detected.

    If you replace all links to [[202204110929 Offending Note]] in your notes with a link to another note, will that other note be inserted? -- If not, then the script is stupid :) If yes, then the script gets the idea to insert this note from somewhere: What if you replace only 50% of the links? From which half does the script pick the ID to randomly insert? Then progressively reduce ("bisect") until you find the note(s) that determine which one is inserted.-

    I replaced the links in the Zettel and the Zettel's backlinks to target different Zettels, but it made no difference. I also tried removing the whole content of the Zettel and the Zettels that linked to it. Guess what? All the same, except that now all you get is <!-- § --> followed by several empty lines.


    I hope that this helps.

  • Yeah that's good to know, thanks!

    I do wonder if there's a regularity which Zettel is being picked. Is it the N-th entry in the list of files (i.e. if you add a file with a name that's sorted above, will that affect the result)? Is it M steps away from the reference outline note? That's things I can try later this week, too, of course.

    Can you do anything to the input outline file to make this not happen, or does this also happen for empty outlines or outlines with 1 ID/link in them?

    Author at Zettelkasten.de • https://christiantietze.de/

  • @ctietze

    I've removed the Zettels that I combined into a single Zettel. Whatever caused this strange behavior may have had something to do with them. Now that they're gone, the script works as intended. I doubt that it had anything to do with missing Zettels because the script returns empty lines in their place.

    I no longer have the removed Zettels, but I'm willing to help in any way I can if you need me.

    Thank you for following up on the issue.

  • Interesting! If that's indeed the problem -- I know it's a bit much to ask --, could you reproduce a similar situation with a couple of dummy notes that contain Lorem Ipsum or some such? Then we have a reproducible test situation to improve the script against.

    Author at Zettelkasten.de • https://christiantietze.de/

  • edited April 2022

    @ctietze

    Setup

    I created 6 Markdown files containing Lorem Ipsum text. Their filenames:

    202204130802
    202204130803
    202204130804
    202204130805
    202204130806
    202204130807
    

    I also created 202204130809 Outline.md. Its content:

    [[202204130802]]
    [[202204130803]]
    [[202204130804]]
    [[202204130805]]
    [[202204130806]]
    [[202204130807]]
    

    The zettel_outline command is always run while being inside the folder containing all files. What I run is this zettel_outline -f '202204130809 Outline.md' -a ./ -o draft.md.

    After every test, the outline is back to how it was in the beginning, unless stated otherwise.

    Test 1

    The command worked as intended.

    Test 2

    I changed the outline so it didn't link to one of the files. Nothing strange hapenned.

    Test 3

    Same as test 2 regarding the outline, but the missing file is linked from one of the other files. The link appears as part of the content of the file that had it, but that's it.

    Test 4

    Two of the files contained links to one another. All good.

    Test 5

    I added the following to the content of the outline:

    # 202204130809 Outline
    #outline ##proofread
    

    In Robo-Fortune's voice: "Unintended behavior detected". The script looks at that unique identifier and thinks that I wanted to include the outline too. So, it adds <!-- § --> followed by the outline's content.

    Test 6

    I added the following to the content of the outline:

    # 202204130810 Outline
    #outline ##proofread
    

    Bear in mind that there's no file with that unique identifier.

    Bingo. >:) I get this:

    <!-- §202204130810 Outline-->
    
    
    
    
    <!-- § -->
    
    # 202204130810 Outline
    #outline ##proofread
    
    [[202204130802]]
    [[202204130803]]
    [[202204130804]]
    [[202204130805]]
    [[202204130806]]
    [[202204130807]]
    

    I don't recall if the situation was exactly the same, but this is more or less what I was getting, with the exception of <!-- §202204130810 Outline--> followed by empty lines.

  • edited April 2022

    Test 7

    I added the following to the content of the outline:

    # X Outline
    #outline ##proofread
    

    Where X is the unique identifier of one of the other files. The result is the same as that of test 6, with the exception that what follows <!-- §X Outline--> is the content of the file X.

    Test 8

    I added the following to the content of one of the other files:

    # X
    #lorem ##proofread
    

    Where X is the unique identifier of any file. Nothing happens, not even if X is the unique identifier of the outline.

  • Wow that's comprehensive, thank you! I can write a lot of regression tests like this to prevent such misbehavior in a fix :)

    Author at Zettelkasten.de • https://christiantietze.de/

  • @ctietze

    I would have liked to run more tests, but I ran out of ideas. Anyways, happy problem-solving! Let me know if you need anything else.

Sign In or Register to comment.