vnotex / vnote

A pleasant note-taking platform in native C++.
https://app.vnote.fun
GNU Lesser General Public License v3.0
11.78k stars 1.21k forks source link

Magic words not replaced correctly #1197

Open mikepyne opened 4 years ago

mikepyne commented 4 years ago

OS Version (操作系统): Windows 10 (1809, build 17763.973)

VNote Version (Help - About VNote - Version: )(VNote版本): 2.8.2

Symptoms (表现):

I have a template containing a number of magic words such as %no%, %date%, %yyyy%. When I open a note based on the template, the magic words aren't replaced and appear 'as is' (that is, %no% is shown, instead of being replaced by the note title).

A template that only uses %no% at the end of a line works as expected, as does a template that uses %dd%/%MM%/%yyyy% in a table.

This also happens in an existing note; if the magic word is on a line with text after it, the magic word isn't replaced when using the CTRL+E,M shortcut. A magic word is correctly replaced when it is at the end of a line.

Other magic words that have similar behaviour, when in the middle of a line:

How to Repro (如何复现):

Template

  1. Create a new template with %date% in a line; for example: (A) %date% Review [Lessons Learned](../../Wiki/Lessons%20Learned.md) due:%date%
  2. Create a new note based on the template; the magic words aren't replaced and appear as %date%.

Existing Note

  1. In an existing note, add %date% at the end of a line and use CTRL+E,M to replace; the magic word is replaced correctly.
  2. Add a line with %date%, with some text after the magic word.
  3. Position the cursor after the closing % of the magic word and use CTRL+E,M; the magic word isn't replaced.
mikepyne commented 4 years ago

After some more investigation, I found that the extra % in my example messes up the replacement; if I edit my template so the link doesn't have %20 in it, the magic words are correctly replaced.

However, when editing an existing note, a magic word isn't replaced if it is in the middle of a line.