jgclark / NotePlan-tools

This Ruby script adds functionality to the [NotePlan app](https://noteplan.co/). Particularly when run frequently, this provides a more flexible system for repeating tasks, allows for due dates to be expressed as offsets which allows for templates, and moves or files items from Daily files to Note files. It incorporates an ealier script to 'clean' or tidy up NotePlan's data files.
26 stars 6 forks source link

Rewritten /Calendar items being placed in /Notes #25

Closed BMStroh closed 3 years ago

BMStroh commented 4 years ago

Found the commonality for the files that are getting moved -

Regex on line 106 doesn't take into account the new .md extension for files. Later on, in rewrite_files (line 666), any rewritten daily note gets moved to Notes if you're using the .md extension.

# Now make a title for this file:
**if @filename =~ /\d{8}\.txt/**
  # for Calendar file, use the date from filename
  @title = @filename[0..7]
  @is_calendar = true
else
  # otherwise use first line (but take off heading characters at the start and starting and ending whitespace)
  tempTitle = @lines[0].gsub(/^#+\s*/, '')
  @title = tempTitle.gsub(/\s+$/, '')
  @is_calendar = false
end

end

jgclark commented 4 years ago

Thanks for reporting this. I'd not realised this code in initialisation of an NPNote object would affect writing out files. I've changed the regex to allow for .md as well as .txt files.

BMStroh commented 4 years ago

Got back to this a bit earlier today and this seems to work without moving the file on my side, and the app immediately recognizes the change and refreshes the daily note. CloudKit here, and I rarely update notes via iOS. I set my default extension to .md and worked through the rename/sync growing pains when the feature was first released if that’s useful from a troubleshooting standpoint.

if @filename =~ /\d{8}\.txt/ || @filename =~ /\d{8}\.md/

On Nov 2, 2020, at 5:59 PM, jgclark notifications@github.com wrote:

Thanks for reporting this. I'd not realised this code in initialisation of an NPNote object would affect writing out files. I've changed the regex to allow for .md as well as .txt files. But then NP itself seems to be ignoring .md calendar files when the default is set to .txt. I've raised this with Eduard.

On Mon, 2 Nov 2020 at 16:02, BMStroh notifications@github.com wrote:

Found the commonality for the files that are getting moved -

Regex on line 106 doesn't take into account the new .md extension for files. Later on, in rewrite_files (line 666), any rewritten daily note gets moved to Notes if you're using the .md extension.

Now make a title for this file:

if @filename =~ /\d{8}.txt/

for Calendar file, use the date from filename

@title = @filename[0..7] @is_calendar = true else

otherwise use first line (but take off heading characters at the start and starting and ending whitespace)

tempTitle = @lines[0].gsub(/^#+\s*/, '') @title = tempTitle.gsub(/\s+$/, '') @is_calendar = false end

end

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jgclark/NotePlan-tools/issues/25, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMYESSNO5LMEASWOSWUF3DSN3J3DANCNFSM4THUVTMQ .

-- -- Jonathan — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jgclark/NotePlan-tools/issues/25#issuecomment-720812115, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGKXJG4BATXDZ4237RSY5KTSN5IYZANCNFSM4THUVTMQ.

jgclark commented 4 years ago

The developer said in Discord earlier today:

NotePlan detects strictly the extension you defined for calendar notes, but non-calendar notes can be anything. Just when you create a new one it uses the defined extension.

So I've added .md as an understood option for calendar files. @BMStroh, I hope this fixes the issue, with a6461cf145565986654048a5acfc3437940523cc.