Comments (4)
I'd like to avoid exposing internal utilities to keep the CLI interface simple.
However, I've been thinking of two different features that could produce a similar output. Both of these solutions assume you have a template at ~/.config/zk/templates/id.md
containing:
{{id}}
First option, a new --dry-run
flag for zk new
, which instead of writing the file would:
- Print to
stderr
the new note file path. - Print to
stdout
the content of the generated note, as it would have been written at the path.
In your case, you could use it like this:
$ zk new --dry-run --template id 2> /dev/null
a65c8b45d
The second option is similar: adding a new command dedicated to render a template. I think this could be useful to expand templates inside notes that are already existing, for example to add a YAML frontmatter.
I'm not sure exactly how it would look like, but it could be something like:
$ zk render id
a65c8b45d
What do you think? The --dry-run
flag could be faster to implement as its semantics are clear. Eventually, both solutions could be useful to have.
Also for which use case do you need this exposed in the LSP server? I guess the dry-run
flag could be exposed for zk.new
and the returned value could be a JSON with keys path
and content
.
from zk.
Adding --dry-run
to new
would solve my use case, so that would be nice.
Adding a render
command would be very interesting. Either solution solves my use case, so I'd leave it to you to decide which path to pursue first.
Also for which use case do you need this exposed in the LSP server?
Thinking about it some more, it's not super useful to be directly exposed in the LSP server. I was thinking it would be easier to thus bind it to a keyboard shortcut; I could just as easily launch the zk CLI with whichever solution. So it's not necessary for my use case.
Also thinking about this some more, I forgot about the {{ content }}
template value, so some of this feature request is unnecessary. I do think either solution provides really useful tools for further scripting, so I'll leave this issue open for now, but feel free to close if you prefer.
from zk.
Okay, I'll go with --dry-run
for now as it would be useful to debug templates and note configuration as well.
from zk.
@nogweii It's available in main
$ cat .zk/templates/id.md
{{id}}
$ zk new --dry-run --template id.md 2> /dev/null
ymkh
You might need to strip the extra newline that is appended to every generated note to only get the ID.
from zk.
Related Issues (20)
- LSP Link doesn't support non-Markdown HOT 7
- TestCollectionDAOFindOrCreate fails HOT 3
- update brew formula HOT 1
- Switch to Pretty Upstream HOT 7
- zk list --created date, returns notes from one day after if YAML date does not have timestamp HOT 10
- glob not addressing all folders within ignore pattern HOT 3
- GitHub Pages site does not have a homepage HOT 1
- zk graph --format json is not handling note titles with inner double quotes HOT 7
- global template ignored HOT 5
- zk cli cannot search note modified or created at the same time HOT 4
- open notes in nvim quickfix from telelescope HOT 2
- zk list outputs redundant end of buffer characters
- `musl` systems not supported HOT 8
- `zk init` generates ambigous LSP section in config HOT 2
- v0.14.1 homebrew release action failed HOT 4
- `zk tag` doesn't shows numeric tags HOT 11
- Use GitHub Actions for building the project
- Links not detected when using timestamps as IDs with `link-format = "markdown"` HOT 8
- Markdown link completion for regular markdown links has stopped working
- Markdown links render as wikilinks when inserted via completion
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zk.