Bad instructions in front-matter when applying template
Please select the area your bug applies to. (Multiple selections are Possible. You can leave blank if you're not sure.)
- [ ] Workspace. VSCode workspace, vaults, Intellisense/autocomplete, Dendron settings
- [ ] Lookup. Dendron's Lookup Command
- [ ] Views. Dendron Preview, Tree View, Side Panels in the UI
- [ ] Schema. Dendron Schemas
- [ ] Pod. Data import from / export to Dendron
- [ ] Publish. External Site Publish
- [x] Markdown. Markdown features, such as syntax support and features
Describe the bug
First bug : when a template is applied in a note, the order of the instructions in the front-matter is no longer the same as in the template. Second bug: when a template is applied in a note, all comment are gone, as well as line breaks.
For example, my template is:
---
# --- base ---
id: qzmv9fiafd3lmvinuk619s8
title: Software template
desc: ''
updated: 1669150683170
created: 1668586189311
# --- template.article.software ---
template: 'article.software'
tags : [software]
name: '-'
developer: '-'
repository: '-'
programmingLanguage: '-'
platform: '-'
website: '-'
---
## Informations
- **Name :** {{ fm.name }}
- **Developer :** {{ fm.developer }}
- **Repo :** <{{ fm.repository }}>
- **Written in :** {{ fm.programmingLanguage }}
- **OS :** {{ fm.platform }}
- **Web site :** <{{ fm.website }}>
## Installation
after applying, the result is:
---
id: lgfub757uo2lr4lz414wx30
title: Test
desc: ''
updated: 1669151371834
created: 1669151371834
tags:
- software
template: article.software
name: '-'
developer: '-'
repository: '-'
programmingLanguage: '-'
platform: '-'
website: '-'
---
## Informations
- **Name :** -
- **Developer :** -
- **Repo :** <->
- **Written in :** -
- **OS :** -
- **Web site :** <->
## Installation
As you can see, the tags property has been reversed with template, all comment and line breaks are gone, and even the tags has changed.
To Reproduce
Steps to reproduce the behavior:
- Create a template
- Execute the command :
Apply Template - See the result
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information)
- OS: [e.g. iOS]
- Browser (if with published websites; include version): [e.g. chrome, safari]
- Versions (all that apply to bug):
- Dendron Extension: 0.118.0 (the last version)
- VS Code version: 1.73.1 (the last one)
- Dendron CLI:
Additional context
Add any other context about the problem here.
Dendron Log file
Please attach the output of > Dendron:Dev: Open Logs here
hey @josephgarnier, thank you for the report.
This happens because yaml is a map and the order does not matter in yaml.
For the case of tags being altered, the altered form is actually a standard way yaml arrays are formatted.
To ensure we are not introducing duplicate frontmatter entries when applying a template, we first parse the template's frontmatter and then process the note that we are applying the template to.
In this process, all non-standard formatting is being stripped out and altered as in your case. (including comments and line breaks)
I would say this is working as intended, though in a way that is a bit inconvenient for the user. I can understand your frustration; the frontmatter is something a user would manually write and alter, and the expectation would be to have it consistent across the board.
We'll look into this to see if we can do a better job at preserving the frontmatter formatting as an enhancement.
Would you be okay with the idea of marking this as a type.enhancement instead of a bug?
Thank you for your answer. No problem for me to label this post as enhancement.
is there a way to preserve custom frontmatter with preserveCustomFrontmatter: true ?
@ericmolitor I don't know, I've migrated to another tool since development of Dendron was stopped.