pajoma / vscode-journal

Lightweight journal and simple notes support for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=pajoma.vscode-journal
GNU General Public License v3.0
233 stars 40 forks source link

[Question/Possibly Bug] Templates not working #52

Closed theprateik closed 2 years ago

theprateik commented 4 years ago

I want to have the memo saved as following format, which is basically with the time the memo was created: MEMO 2:55 PM : This is wonderful memo

So, as per my understanding this is where the Templates come into play. So, I followed following steps to setup my template for the Memo. But, the result I received was not what I was expecting.

Steps

  1. Open user settings for the vscode.
  2. Update the Journal: Tpl-memo setting value to - MEMO ${localTime}: ${input}.
  3. Restart the vscode.
  4. Using Ctrl+Shit+J command, enter This is a wonderful memo.
  5. Vscode opens the corresponding md file with the memo entered as MEMO ${localTime}: This is a wonderful memo.

Expectation (with the time when the memo was added)

MEMO 3:55 PM : This is wonderful memo

Result

MEMO ${localTime}: This is a wonderful memo

Am I missing any step here?

joefrancia commented 4 years ago

I believe I'm hitting the same bug

Setting

"journal.tpl-entry": "# ${d:dddd, MMMM DD YYYY}\n\n## Tasks\n\n## Notes\n\n"

Expected

# Thursday, 19 December 2019

## Tasks

## Notes

Actual

# ${d:dddd, MMMM DD YYYY}

## Tasks

## Notes
pajoma commented 4 years ago

I am looking into it

meaninginuse commented 4 years ago

I am looking into it

Any updates here? Same problem as above.

jugge83 commented 4 years ago

I'm hitting the same issue as scaba, every format seems to work except the custom one.

jugge83 commented 4 years ago

@pajoma, The fix is simple, just change the following lines in \out\src\ext\conf.js:

// around line 50
// this.regExpDateFormats = new RegExp(/\$\{(?:(year|month|day|localTime|localDate|weekday)|(d:\w+))\}/g);
this.regExpDateFormats = new RegExp(/\$\{(?:(year|month|day|localTime|localDate|weekday)|(d:[\s\S]+?))\}/g);
// in the switch case of replaceDateformats(st, date), around line 200
default:
    // check if custom format
    if (match.startsWith("${d:")) {
         let modifier = match.substring(match.indexOf("d:") + 2, match.length - 1); // includes } at the end
         // st.template = st.template.replace(match, mom.format(modifier));
         st.value = st.value.replace(match, mom.format(modifier));
     }
     break;
pajoma commented 4 years ago

I have added the current prerelease to this project, can you please download it from here and test it?

To test, use the option "Install from VSIX..." in the Extension View of Visual Studio Code.

jugge83 commented 4 years ago

This works like a charm for me with the following setting:

"journal.tpl-entry": "# W${d:WW dddd, YYYY-MM-DD}\n| In    | Out   |\n|  ---  |  ---  |\n| ${d:HH:mm} | HH:mm |\n\n## Tasks\n\n## Notes\n\n## Inline notes\n\n",

Thanks for the link and the install description and the quick response.

pajoma commented 2 years ago

Has been fixed in previous release