Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi line notes don't play nice #39

Open
ioanniswd opened this issue May 1, 2020 · 7 comments
Open

Multi line notes don't play nice #39

ioanniswd opened this issue May 1, 2020 · 7 comments
Assignees
Labels
Improvement Improvements and refactoring

Comments

@ioanniswd
Copy link
Collaborator

$ stup add -n 'Multi                                                
quote> line            
quote> note'             
Successfully added 1 notes in category personal for Friday May 01, 2020
$ stup add -n 'Single line note'
Successfully added 1 notes in category personal for Friday May 01, 2020
$ stup show today
Displaying notes added for Friday May 01, 2020.

 # Notes in category: personal

  • Multi
  line
  note
  • Single line note

Mentioned in this issue comment by @tiosgz :

I'm quite curious how this could be done simply with multi-line notes (yes I use them a lot)… (OK, some more y or n<Enter wouldn't be so difficult)

Applies to both add and copy commands.

@iridakos iridakos changed the title Bug: Multi line notes don't play nice Multi line notes don't play nice May 1, 2020
@iridakos iridakos added the Improvement Improvements and refactoring label May 1, 2020
@iridakos
Copy link
Owner

iridakos commented May 1, 2020

Hi @ioanniswd
I can see the problem in indentation, is that what you are talking about or am I missing and something else?

@ghost
Copy link

ghost commented May 1, 2020

I don't think there is any problem at all until the notes are filtered one by one (happens with copy and I guess also search (haven't tested this yet)), except for the bullets (which don't look good IMO, anyway).

If you look at the .md file as if it was written manually: wouldn't you indent the next line so that it looks more natural? And if you add sub-lists (this is what I usually do), you have to indent them to be parsed as separate lists (and not just items of the top-level list).

@ioanniswd
Copy link
Collaborator Author

Yes, the indentation and the bullets are the issue when it comes to show.
Also, in copy, we currently treat a multi line note as separate notes:

$ stup copy --to tomorrow --from today 
About to copy notes from Friday May 01, 2020 to Saturday May 02, 2020 for category personal


- Multi


>>> Copy this note [y,n,q,a]?: n


line


>>> Copy this note [y,n,q,a]?: n


note


>>> Copy this note [y,n,q,a]?: n


- Single line note


>>> Copy this note [y,n,q,a]?: n

@iridakos
Copy link
Owner

iridakos commented May 1, 2020

Ok, this needs a little work to think of the best approach to deal with.

The fact that each note starts with a dash might be helpful to be able to group distinguish multiline notes via a regex.

I will think about possible solutions. If anyone thinks of something let's add it here for discussion.

PS: I really appreciate your contributions @ioanniswd @tiosgz, thank you very much

@ghost
Copy link

ghost commented May 1, 2020

I haven't found a way to do this using one regex-ed line, but I think this could work

  • arr=()
  • read through the file
    • if the line starts with - , append it to the array
    • otherwise append it to the array's last item (don't forget a newline)
arr=()
while IFS='' read line
do
  if [[ "$line" =~ (^- ) ]]; then
    arr+=( "$line" )
  else
    last=$((${#arr[*]} - 1))
    arr[$last]+="\n$line"
  fi
done < $notes_file

Will find all the credits if you want (though it'd mean filtering ~20 tabs)

@iridakos
Copy link
Owner

iridakos commented May 1, 2020

@tiosgz I think it'll work. I can check that tomorrow and get back to you. If you already started or you want to work on this let me know to avoid conflict.

Will find all the credits if you want (though it'd mean filtering ~20 tabs)

😆 no, I don't

@ghost
Copy link

ghost commented May 2, 2020

If you already started or you want to work on this let me know to avoid conflict.

I don't plan doing this, because (as I know myself) I would never get it done.

@iridakos iridakos self-assigned this May 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Improvements and refactoring
Projects
None yet
Development

No branches or pull requests

2 participants