README ¶
Command nt-reference
nt-reference
is an interactive CLI to generate reference files or notes already filled with metadata. Several sources are supported like Google Books, Zotero, and Wikipedia.
Configuration
The command reads the same configuration file .nt/config
as the command nt
. To use this command, declare new sections like [reference.ABC]
where each section represents one kind of generation.
For example:
[reference.books]
title = "A book"
manager = "google-books"
path = """references/books/{{index . "title" | slug}}.md"""
template = """---
title: "{{index . "title" | title}}{{ if index . "subtitle"}}:{{index . "subtitle" | title}}{{end}}"
short_title: "{{index . "title" | title}}"
name: {{index . "authors" | join ", "}}
occupation: Unknown
nationality: Unknown
{{- if index . "pageCount"}}
numPages: {{index . "pageCount"}}
{{- end -}}
{{- if index . "industryIdentifiers"}}
isbn: "{{index . "industryIdentifiers" | jq ". | first | .identifier"}}"
{{- end }}
---
# {{index . "title" | title}}
"""
Usage
$ nt-reference new
The CLI is interactive. No option or argument is expected. Simply run it and answer the different questions until your file or note is generated.
FAQ
How to determine available attributes?
You can check the online documentation for the different providers:
Provider | Implementation | Documentation |
---|---|---|
Wikipedia | Infoboxes are parsed to extract and parse attributes. It's not easy to find a list of possible attributes. | See official documentation |
Google Books | The volumeInfo attribute is extracted and exposed. |
See official documentation |
Zotero (legacy) | All attributes returned by the API are exposed. Note that Zotero defines different schemas for the different kinds of work. | See project on GitHub or check Zotero Translation Server schemas |
Another solution (even simpler to try), is to print all available attributes in your template:
[reference.book]
template = "{{ . | jsonPretty }}"
Once you know which attribute to use, edit the template and relaunch the command.
What is the supported syntax for templates?
The command uses the Go package text/template
under the hood. Please read the official documentation. In addition, the command provides additional custom functions:
Function | Description | Example |
---|---|---|
json |
Dump all attributes in compact JSON format |
Attributes:
Usage:
Output:
|
jsonPretty |
Dump all attributes in a human-readable format |
Attributes:
Usage:
Output:
|
yaml |
Dump all attributes in a human-readable format |
Attributes:
Usage:
Output:
|
jq |
Support jq expressions to extract values |
Attributes:
Usage:
Output:
|
title |
Convert using common book title case |
Attributes:
Usage:
Output:
|
slug |
Convert to a URL-compliant slug |
Attributes:
Usage:
Output:
|
Documentation ¶
There is no documentation for this package.