From c51117d2f6e559094b11390b4ee8924859757ee6 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Fri, 21 Aug 2020 17:34:23 -0400 Subject: [PATCH] Wiki-style links (#351) --- guide/2011401.md | 2 +- guide/2011402.md | 14 ++-- guide/2011403.md | 3 +- guide/2011404.md | 14 ++-- guide/2011405.md | 10 +-- guide/2011406.md | 10 +-- guide/2011407.md | 2 +- guide/2011501.md | 6 +- guide/2011502.md | 24 +++---- guide/2011503.md | 6 +- guide/2011504.md | 56 +++++++--------- guide/2011505.md | 10 +-- guide/2011506.md | 28 ++++---- guide/2012301.md | 2 +- guide/2012401.md | 2 +- guide/2014601.md | 2 +- guide/2016401.md | 2 +- guide/2017401.md | 4 +- guide/535407ad.md | 6 +- guide/5e41fd32.md | 4 +- guide/67c6f7a0.md | 2 +- guide/6f0f0bcc.md | 2 +- guide/cc1f7ecf.md | 2 +- guide/index.md | 12 ++-- neuron/neuron.cabal | 2 +- neuron/src/lib/Neuron/Reader/Markdown.hs | 82 ++++++++++++++++-------- 26 files changed, 164 insertions(+), 145 deletions(-) diff --git a/guide/2011401.md b/guide/2011401.md index ee544a761..db3c26a76 100644 --- a/guide/2011401.md +++ b/guide/2011401.md @@ -2,7 +2,7 @@ Zettelkasten is a smart note taking system created by a German sociologist, whose productivity increased to epic proportions due to it[^dclear]. -All notes in a Zettelkasten are linear, <2012101>, with links created between them, enabling a <2011407> to evolve organically, rather than having to preconceive a hierarchy ahead (as is the case with outliners like Workflowy and Dynalist). +All notes in a Zettelkasten are linear, [[[2012101]]], with links created between them, enabling a [[[2011407]]] to evolve organically, rather than having to preconceive a hierarchy ahead (as is the case with outliners like Workflowy and Dynalist). [^dclear]: To learn more, read [Zettelkasten — How One German Scholar Was So Freakishly Productive](https://writingcooperative.com/zettelkasten-how-one-german-scholar-was-so-freakishly-productive-997e4e0ca125) by David Clear. diff --git a/guide/2011402.md b/guide/2011402.md index 500d7ce3f..c70e8e696 100644 --- a/guide/2011402.md +++ b/guide/2011402.md @@ -2,11 +2,11 @@ Neuron includes a web interface for your notes that update automatically. This very site you are viewing is managed by neuron; and you may access its notes [here](https://github.com/srid/neuron/tree/master/guide). The "zettel" you are viewing currently is conceptually termed an "overview zettel", as it provides a portal into the other zettels. -Neuron also generates a complete index (at [z-index](z-index.html)) of *all* Zettels visualized as a <2017401?cf>. +Neuron also generates a complete index (at [z-index](z-index.html)) of *all* Zettels visualized as a [[2017401]]. -- <2011403> -- <2011404> -- <2011405> -- <2011406> -- <2013501> -- +- [[[2011403]]] +- [[[2011404]]] +- [[[2011405]]] +- [[[2011406]]] +- [[[2013501]]] +- [[[cc1f7ecf]]] diff --git a/guide/2011403.md b/guide/2011403.md index 0ef5d4a02..bef10fe86 100644 --- a/guide/2011403.md +++ b/guide/2011403.md @@ -11,5 +11,4 @@ specify your own as well, as long as it contains only the following characters: ## Why prefer random IDs? -Why does neuron use random alphameric IDs *by default*? Because then you are not forced to think of a suitable slug when writing a new note. A note's title may change in future, so could a slug. Generally text editors make it easier to work with this, by automatically showing the title of the linked note next to the link (see <4a6b25f1?cf>). - +Why does neuron use random alphameric IDs *by default*? Because then you are not forced to think of a suitable slug when writing a new note. A note's title may change in future, so could a slug. Generally, text editors make it easier to work with this, by automatically showing the title of the linked note next to the link (see [[4a6b25f1]]). diff --git a/guide/2011404.md b/guide/2011404.md index ac9d4be33..6c8443ed0 100644 --- a/guide/2011404.md +++ b/guide/2011404.md @@ -1,12 +1,12 @@ # Zettel Markdown -Zettel files are written using Markdown[^other], per the [CommonMark](https://commonmark.org/) specification. Neuron uses [commonmark-hs](https://github.com/jgm/commonmark-hs) to parse them into the [Pandoc AST](https://pandoc.org/using-the-pandoc-api.html), as well as provides an extention on top to handle zettel links. +Zettel files are written in Markdown[^other], per the [CommonMark](https://commonmark.org/) specification. Neuron uses [commonmark-hs](https://github.com/jgm/commonmark-hs) to parse them into the [Pandoc AST](https://pandoc.org/using-the-pandoc-api.html), as well as provides an extention on top to handle zettel links. -* <2011504> -* <2011505> -* <2013702> -* <2013701> -* <2016401> +* [[[2011504]]] +* [[[2011505]]] +* [[[2013702]]] +* [[[2013701]]] +* [[[2016401]]] * Styling elements using Semantic UI ([#176](https://github.com/srid/neuron/issues/176)) -[^other]: Neuron is designed to be extended with other markup formats as well. Org-mode is currently supported (see the `formats` setting in <2011701?cf>) but is [experimental](https://github.com/srid/neuron/issues/275). Neuron recommends Markdown, which is supported everywhere including <041726b3?cf>. +[^other]: Neuron is designed to be extended with other markup formats as well. Org-mode is currently supported (see the `formats` setting in [[2011701]]) but is [experimental](https://github.com/srid/neuron/issues/275). Neuron recommends Markdown, which is supported everywhere including [[041726b3]]. diff --git a/guide/2011405.md b/guide/2011405.md index c694c8cf1..2a45c1077 100644 --- a/guide/2011405.md +++ b/guide/2011405.md @@ -32,12 +32,12 @@ Leave this command running in one terminal, and then use `neuron open` to direct ## Publishing to the web -See <778816d3> +See [[[778816d3]]] ## Features -* <2011701> -* <2014601> -* <67c6f7a0> -* <2011503> +* [[[2011701]]] +* [[[2014601]]] +* [[[67c6f7a0]]] +* [[[2011503]]] diff --git a/guide/2011406.md b/guide/2011406.md index 27c2b0563..e4e1b3831 100644 --- a/guide/2011406.md +++ b/guide/2011406.md @@ -5,7 +5,7 @@ tags: # Creating and Editing zettels -You may use any text editor with Markdown support to edit your zettel files. Neuron provides a command to create new zettel files with the suitable <2011403?cf>: +You may use any text editor with Markdown support to edit your zettel files. Neuron provides a command to create new zettel files with the suitable [[2011403]]: ```bash neuron new "My zettel title" @@ -18,16 +18,16 @@ This command will print the path to the file created. Use `-e` to also open the neuron new "My zettel title" -e ``` -Newly created zettels will be a cluster of its own (see <2012301>) until you connect other zettels to them (see <2011504?cf>). +Newly created zettels will be a cluster of its own (see [[[2012301]]]) until you connect other zettels to them (see [[2011504]]). ## Opening a Zettel by title -See <2013501?cf>. +See [[2013501]]. ## Using a text editor -See <4a6b25f1> +See [[[4a6b25f1]]] ## Web Interface -<041726b3> provides a web interface to browse and edit your Neuron notes. +[[[041726b3]]] provides a web interface to browse and edit your Neuron notes. diff --git a/guide/2011407.md b/guide/2011407.md index d7d778b5e..4ea9fa3d8 100644 --- a/guide/2011407.md +++ b/guide/2011407.md @@ -18,4 +18,4 @@ Richard Meadows at [lesswrong](https://www.lesswrong.com/posts/NfdHG6oHBJ8Qxc26s ## See also * [Category-free notes](https://article69.art.blog/2019/12/20/how-and-why-to-create-a-zettelkasten-a-guide-in-the-vein-of-niklas-luhman/) -* <2017401> +* [[[2017401]]] diff --git a/guide/2011501.md b/guide/2011501.md index 90a0d0d08..43c00716d 100644 --- a/guide/2011501.md +++ b/guide/2011501.md @@ -44,7 +44,7 @@ nix-env -if https://github.com/srid/neuron/archive/master.tar.gz Note that this command can also *upgrade* your existing install of neuron. -For alternative mechanisms, see <2012401>. +For alternative mechanisms, see [[[2012401]]]. ## Test your install @@ -72,6 +72,6 @@ Available commands: ## What's next? -Proceed to the <2011502?cf>. +Proceed to the [[2011502]]. -[^nix]: Nix is a general package manager that you can use to manage other software and services as well. [See here](https://github.com/srid/neuron/issues/193#issuecomment-629557917). If you do not wish to install Nix, try the . If you are on Linux, you may alternatively try the static bundle `neuron-linux-bundle` from [the nightly release](https://github.com/srid/neuron/releases/tag/nightly). +[^nix]: Nix is a general package manager that you can use to manage other software and services as well. [See here](https://github.com/srid/neuron/issues/193#issuecomment-629557917). If you do not wish to install Nix, try the [[[c6176636]]]. If you are on Linux, you may alternatively try the static bundle `neuron-linux-bundle` from [the nightly release](https://github.com/srid/neuron/releases/tag/nightly). diff --git a/guide/2011502.md b/guide/2011502.md index b6c468a51..f6da51c1b 100644 --- a/guide/2011502.md +++ b/guide/2011502.md @@ -5,7 +5,7 @@ tags: # Tutorial -Make sure you have already installed neuron (see <2011501?cf>). Then follow this tutorial to get your own Zettelkasten up and running. +Make sure you have already installed neuron (see [[2011501]]). Then follow this tutorial to get your own Zettelkasten up and running. ## Test with an existing Zettelkasten @@ -18,7 +18,7 @@ git clone https://github.com/srid/neuron.git cd neuron ``` -Now run the neuron <2011405?cf> on the `./guide` Zettelkasten: +Now run the neuron [[2011405]] on the `./guide` Zettelkasten: ```bash neuron -d ./guide rib -wS @@ -31,39 +31,39 @@ It can be accessed at [localhost:8080](http://localhost:8080). It should match w There a few ways to do this. 1. Copy the `./guide` directory and work from there; or -1. Use the template repository in <778816d3?cf>; or +1. Use the template repository in [[778816d3]]; or 1. Create one from scratch. For this tutorial, we choose the last option. -Neuron expects a Zettelkasten directory to be nothing more than a list of <2011404?cf> notes. By default `~/zettelkasten` will be used as your neuron directory (which you can override using the `-d` option). Create this directory first: +Neuron expects a Zettelkasten directory to be nothing more than a list of [[2011404]] notes. By default `~/zettelkasten` will be used as your neuron directory (which you can override using the `-d` option). Create this directory first: ```bash mkdir ~/zettelkasten ``` -Now create (see <2011406?cf>) your first zettel file: +Now create (see [[2011406]]) your first zettel file: ```bash neuron new "My first zettel" -e ``` -This will open your text editor[^editor] with the newly created file and its title already filled in. Enter some text, and exit the editor. +This will open your text editor[^editor] with the newly created file (neuron uses a random filename; let's assume it is `6479cd5e.md`) and its title already filled in. Enter some text, and exit the editor. [^editor]: Your `$EDITOR` environment variable must be set pointing to the text editor for this to work. -Next, create an "overview" zettel called `index.md` --- it would be the welcoming page of our Zettelkasten web interface --- and link it (see <2011504?cf>) to your first zettel (we will assume its filename is "6479cd5e.md") in it: +Next, create an "overview" zettel called `index.md` --- it would be the welcoming page of our Zettelkasten web interface --- and link it (see [[2011504]]) to your first zettel in it: ```bash $ cat > ~/zettelkasten/index.md # Overview -* <6479cd5e> +* [[6479cd5e]] ^D $ ``` -Your Zettelkasten directory `~/zettelkasten` should now contain two zettels--named `6479cd5e.md` and `index.md`. Now it is time to run the neuron <2011405?cf>: +Your Zettelkasten directory `~/zettelkasten` should now contain two zettels--named `6479cd5e.md` and `index.md`. Now it is time to run the neuron [[2011405]]: ```bash neuron rib -wS @@ -73,12 +73,12 @@ neuron rib -wS * The `-S` option runs a HTTP server serving the generated HTML files. * You can ignore it, and use `neuron open` instead. -Access it at [localhost:8080](http://localhost:8080) (or use `neuron open`). You should expect to see the contents of your overview zettel, which should link to the first zettel created. Clicking the tree icon in the nav bar should take you to the <2011503?cf> of your Zettelkasten. +Access it at [localhost:8080](http://localhost:8080) (or use `neuron open`). You should expect to see the contents of your overview zettel, which should link to the first zettel created. Clicking the tree icon in the nav bar should take you to the [[2011503]] of your Zettelkasten. ## Growing your Zettelkasten -Congratulations, you have created your first Zettelkasten using neuron! From this moment onwards, simply use the `new` command to create new zettels, `search` command to open existing zettels (or see <4a6b25f1?cf> for editor support). As your Zettelkasten grows over time, more value will be derived from it. +Congratulations, you have created your first Zettelkasten using neuron! From this moment onwards, simply use the `new` command to create new zettels, `search` command to open existing zettels (or see [[4a6b25f1]] for editor support). As your Zettelkasten grows over time, more value will be derived from it. ## What's next? -Read <2011402?cf> next to learn all the concepts and features in Neuron. +Read [[2011402]] next to learn all the concepts and features in Neuron. diff --git a/guide/2011503.md b/guide/2011503.md index 6d083b461..c6c478807 100644 --- a/guide/2011503.md +++ b/guide/2011503.md @@ -1,11 +1,11 @@ # Graph view -A zettelkasten is a [directed graph](https://en.wikipedia.org/wiki/Directed_graph). Neuron also has the notion of <2017401>, which is a subset of this graph established by having zettels "branch off" to other zettels. +A zettelkasten is a [directed graph](https://en.wikipedia.org/wiki/Directed_graph). Neuron also has the notion of [[[2017401]]], which is a subset of this graph established by having zettels "branch off" to other zettels. ## z-index -The z-index page (at `/z-index.html`; also linked in the header) displays the zettelkasten <2017401> for all <2012301> in the zettelkasten graph. +The z-index page (at `/z-index.html`; also linked in the header) displays the zettelkasten [[[2017401]]] for all [[[2012301]]] in the zettelkasten graph. ## Uplinks and Backlinks -A backlink of a zettel is a zettel that links to it. If that link is a folgezettel link, it is called an "uplink". Each zettel has its <5e41fd32?cf> displayed at the top. +A backlink of a zettel is a zettel that links to it. If that link is a folgezettel link, it is called an "uplink". Each zettel has its [[5e41fd32]] displayed at the top. diff --git a/guide/2011504.md b/guide/2011504.md index 0e15cbed6..1dc1d108f 100644 --- a/guide/2011504.md +++ b/guide/2011504.md @@ -1,53 +1,43 @@ # Linking -To link to another zettel, put the <2011403?cf> inside angle brackets[^wikistyle]: +To link to another zettel, put the [[2011403]] inside `[[[..]]]` or `[[..]]`[^autolink]: -```markdown -This is a zettel file, which links to another zettel: +``` +This is a zettel file, which links (branches of) to another zettel: -* +* [[[ef3dke98]]] ``` -Such a link instructs neuron to automatically create a connection between the -associated zettels, which ultimately affects the <2017401?cf> of your zettel -graph. In <2011405?cf>, neuron will automatically display the title of the -linked zettel. +The 3-bracket syntax creates a special link (called a folgezettel) to the +specified zettel. When a zettel has a folgezettel relationship to another +zettel, it is said to "branch of" to the other zettel. Folgezetel relationships +define the [[2017401]] of your zettel graph. +In [[2011405]], neuron will automatically display the title of the +linked zettel. ## Non-branching links If your link is merely a reference to another zettel, and you do not wish it to -be part of the <2017401?cf> and the linked zettel's <5e41fd32?cf>, use the -`cf`[^cf] query flag (eg: ``). +be part of the [[2017401]] and the linked zettel's [[5e41fd32]], use the +2-bracket syntax: (eg: `[[ef3dke98]]`). -```markdown +``` This is a zettel file, which refers to another zettel without -strongly linking to it: +branching to it: -* +* [[ef3dke98]] ``` -Neuron will link the zettels, but the link would be ignored from <2017401?cf> -as well as the <5e41fd32?cf> of zettel with ID "ef3dke98". +Neuron will link the zettels, but the link would be ignored from [[2017401]] +as well as the [[5e41fd32]] of the zettel. ## Advanced linking -* <2011506> - -[^cf]: - > The abbreviation cf. (short for the Latin: *confer/conferatur*, both meaning "compare") is used in writing to refer the reader to other material to make a comparison with the topic being discussed. [Wikipedia](https://en.wikipedia.org/wiki/Cf.) - -[^wikistyle]: - Neuron additionally supports "wiki-style" linking. `[[ef3dke98]]` is the - same as ``. - - NOTE: This is an **experimental** feature; it will be changed when - the [Flexible links](https://github.com/srid/neuron/issues/312) proposal - gets implemented. - - Wiki-style linking was added to allow users to edit their neuron - notes in existing Zettelkasten software like Zettlr. Note that those software - may not recognize the full range of Neuron links. See - [#229](https://github.com/srid/neuron/issues/229#issuecomment-645756080) for - details. +* [[[2011506]]] +[^autolink]: + Neuron used to use "autolink" style linking. `` is the + same as `[[[ef3dke98]]]`; and `` is the same as + `[[ef3dke98]]`. Autolinks are supported for backwards compatibility only; + users are recommended to use the new wiki-style links. diff --git a/guide/2011505.md b/guide/2011505.md index 259f48b5d..dab285b10 100644 --- a/guide/2011505.md +++ b/guide/2011505.md @@ -13,24 +13,24 @@ tags: --- ``` -Tags can be also be nested; see <535407ad>. +Tags can be also be nested; see [[[535407ad]]]. -[^kw]: For interoperability with other Zettelkasten apps, neuron accepts "keywords" as an alternative to "tags" in the YAML frontmatter. +[^kw]: For interoperability with other Zettelkasten apps, neuron also accepts "keywords" as an alternative to "tags" in the YAML frontmatter. ::: ## Date -The creation date of the zettels can be specified in the "date" metadata field (`neuron new` automatically fills in this field): +The date of the zettels can be specified in the "date" metadata field (`neuron new` automatically fills in this field): ```markdown --- -date: 2020-04-07 +date: 2020-08-21T13:06 tags: - journal --- ``` -The creation date can be made to display in a query result by using the `timeline` flag (see <2011506?cf>). +This date can be made to display in a query result by using the `timeline` flag (see [[2011506]]). ## Pinning diff --git a/guide/2011506.md b/guide/2011506.md index 19dcc679b..2b9f9796c 100644 --- a/guide/2011506.md +++ b/guide/2011506.md @@ -1,39 +1,41 @@ # Automatic links using queries -Neuron supports special link syntax that will query the Zettelkasten (eg: by tag) and insert the links using the query results. +Neuron supports special link syntax that will query the Zettelkasten (eg: by +tag) and create links based on the query results. ## Linking to multiple zettels by tag You may create a query that will link to (and display) the matching zettels automatically. For example, to link to a list of a zettels with the "science" tag (from the example -at <2011505?cf>): +at [[2011505]]): -```markdown - +``` +[[z:zettels?tag=science&timeline]] ``` You can use the CLI to see which zettels will be included in a given query; see -<2013501?cf>. +[[2013501]]. ### Example -As an example here is a list of zettels tagged "walkthrough" on this very +For example, here is a list of zettels tagged "walkthrough" on this very Zettelkasten: - +[[z:zettels?tag=walkthrough]] -It was created by ``. Note that here we -use the `cf` flag to not affect the <2017401?cf> of the graph; whereas without -it, it will form the appropriate new category connections to the listed notes. +It was created by `[[z:zettels?tag=walkthrough]]`. Note that here we +use `[[..]]` to not affect the [[2017401]] of the graph; whereas if we had used +`[[[...]]]`, it will form the appropriate folgezettel connections to the listed +notes. ### Hierarchical tags -Queries can also link to zettels whose <535407ad?cf> match a glob pattern. For -instance, `` will link to all zettels tagged +Queries can also link to zettels whose [[535407ad]] match a glob pattern. For +instance, `[[z:zettels?tag=science/*]]` will link to all zettels tagged "science/physics" and "science/biology". Recursive globs are supported too, so if you want to include deeper nested tags, -`` will also match them (e.g. +`[[z:zettels?tag=science/**]]` will also match them (e.g. "science/physics/kinematics"). This will also include zettels that are tagged "science" only, though this behavior can be avoided by querying "science/\*/\*\*" instead. diff --git a/guide/2012301.md b/guide/2012301.md index 8833a4ed9..bbef4c149 100644 --- a/guide/2012301.md +++ b/guide/2012301.md @@ -1,4 +1,4 @@ # Clusters -Your Zettelkasten may have two or more clusters, not [connected](https://en.wikipedia.org/wiki/Connected_graph) to one another. The z-index will display these clusters, with each cluster's <2017401?cf> rendered as a [forest](https://tinyurl.com/wikipedia-forest), whose roots (aka "[mother](https://www.geeksforgeeks.org/find-a-mother-vertex-in-a-graph/) zettels") could be considered as a portal zettel into that sub-Zettelkasten. +Your Zettelkasten may have two or more clusters, not [connected](https://en.wikipedia.org/wiki/Connected_graph) to one another. The z-index will display these clusters, with each cluster's [[2017401]] rendered as a [forest](https://tinyurl.com/wikipedia-forest), whose roots (aka "[mother](https://www.geeksforgeeks.org/find-a-mother-vertex-in-a-graph/) zettels") could be considered as a portal zettel into that sub-Zettelkasten. diff --git a/guide/2012401.md b/guide/2012401.md index 17dcceaf5..299bbea2e 100644 --- a/guide/2012401.md +++ b/guide/2012401.md @@ -26,4 +26,4 @@ In the future if you decide to upgrade neuron, simply change the revision hash t ## Systemd service If you use [home-manager](https://github.com/rycee/home-manager), you can also -run neuron as a systemd service; see <6479cd5e>. +run neuron as a systemd service; see [[[6479cd5e]]]. diff --git a/guide/2014601.md b/guide/2014601.md index d05a09997..9175704bb 100644 --- a/guide/2014601.md +++ b/guide/2014601.md @@ -1,6 +1,6 @@ # Color Scheme -Color scheme can be specified in the <2011701?cf> file. Value must be [one of the color names](https://semantic-ui.com/usage/theming.html#sitewide-defaults) supported by SemanticUI. +Color scheme can be specified in the [[2011701]] file. Value must be [one of the color names](https://semantic-ui.com/usage/theming.html#sitewide-defaults) supported by SemanticUI. ## Theme Previews diff --git a/guide/2016401.md b/guide/2016401.md index fd3d7ee22..ec21d2780 100644 --- a/guide/2016401.md +++ b/guide/2016401.md @@ -13,4 +13,4 @@ folder, you can then include it in your Markdown as: ## Special files -Neuron treats certain files as special. See <67c6f7a0> +Neuron treats certain files as special. See [[[67c6f7a0]]] diff --git a/guide/2017401.md b/guide/2017401.md index fba3c5392..00376c511 100644 --- a/guide/2017401.md +++ b/guide/2017401.md @@ -1,6 +1,6 @@ # Folgezettel Heterarchy -Neuron allows you to organically build a <2011407?cf> out of your Zettelkasten over time. When a zettel links (see <2011504?cf>) to another, it "branches off"[^folge] to that zettel ... unless `cf` is used (in which case it is not a branch off). +Neuron allows you to organically build a [[2011407]] out of your Zettelkasten over time. When a zettel links (see [[2011504]]) to another, it "branches off"[^folge] to that zettel ... using `[[[...]]]` (i.e, three brackets, instead of two). A folgezettel heterarchy differs from a traditional "category tree" in two key ways: @@ -10,7 +10,7 @@ A folgezettel heterarchy differs from a traditional "category tree" in two key w The heterarchy is displayed in the following places * z-index: Full folgezettel heterarchy of the zettelkasten. -* <5e41fd32>: Subset of the above, branching off to the zettel. +* [[[5e41fd32]]]: Subset of the above, branching off to the zettel. ## See also diff --git a/guide/535407ad.md b/guide/535407ad.md index cf8868788..2a655de8e 100644 --- a/guide/535407ad.md +++ b/guide/535407ad.md @@ -1,6 +1,6 @@ # Hierarchical tags -Tags can be nested using a "tag/subtag" syntax, to allow a more fine-grained organization of your Zettelkasten, especially when using advanced queries as shown in <2011506?cf>. +Tags can be nested using a "tag/subtag" syntax, to allow a more fine-grained organization of your Zettelkasten, especially when using advanced queries as shown in [[2011506]]. For example, the following zettel is tagged "math/calculus/definition" @@ -20,8 +20,8 @@ It will be included in the following tag queries: - `math/calculus/definition` - `**/definition` -See <2011506?cf> to understand how to link zettels automatically based on tag patterns as above. +See [[2011506]] to understand how to link zettels automatically based on tag patterns as above. ## Tag trees -Use ` to render your entire tags set as a tree. Note that this only *renders* the tags; whereas `` of <2011506?cf> exists to *link* to the zettels tagged with matching tags. +Use `[[z:tags?filter=**]]` to render your entire tags set as a tree. Note that this only *renders* the tags; whereas `[[z:zettels?tag=...]]` of [[2011506]] exists to *link* to the zettels tagged with matching tags. diff --git a/guide/5e41fd32.md b/guide/5e41fd32.md index cb02bf551..340d089d7 100644 --- a/guide/5e41fd32.md +++ b/guide/5e41fd32.md @@ -4,6 +4,6 @@ date: 2020-07-24 # Uplink Tree -An **uplink tree** of a zettel is the subset of the <2017401?cf> which branch off to the zettel. Uplink tree is displayed above the zettel; other backlinks are displayed below. +An **uplink tree** of a zettel is the subset of the [[2017401]] which branch off to the zettel. Uplink tree is displayed above the zettel; other backlinks are displayed below. -Use `?cf` (see <2011504?cf>) to eject something out of a zettel's uplink tree. +Link using `[[...]]` (see [[2011504]]) to eject something out of a zettel's uplink tree. diff --git a/guide/67c6f7a0.md b/guide/67c6f7a0.md index f1e5f5458..a522825a8 100644 --- a/guide/67c6f7a0.md +++ b/guide/67c6f7a0.md @@ -1,6 +1,6 @@ # Icons and manifests -A custom [favicon](https://en.wikipedia.org/wiki/Favicon) for your site can be specified by copying it to the `static` directory (see <2016401?cf>). Neuron recognizes the following file names: +A custom [favicon](https://en.wikipedia.org/wiki/Favicon) for your site can be specified by copying it to the `static` directory (see [[2016401]]). Neuron recognizes the following file names: * `static/favicon.svg` * `static/favicon.png` diff --git a/guide/6f0f0bcc.md b/guide/6f0f0bcc.md index 9f2ebcb1b..93788c469 100644 --- a/guide/6f0f0bcc.md +++ b/guide/6f0f0bcc.md @@ -8,5 +8,5 @@ Neuron was designed with these criteria in mind: * Remain as simple to use as possible [^plain]: Store your notes however you want. We recommend [Git](https://guides.github.com/introduction/git-handbook/), which enables full revision history of your notes for lifetime. -[^editor]: Text editors should ideally be *decoupled*, integrating via something like [LSP](https://github.com/srid/neuron/issues/213). Both Emacs and Vim have extensions for neuron (see <4a6b25f1?cf>). Also see <041726b3?cf>. +[^editor]: Text editors should ideally be *decoupled*, integrating via something like [LSP](https://github.com/srid/neuron/issues/213). Both Emacs and Vim have extensions for neuron (see [[4a6b25f1]]). Also see [[041726b3]]. [^cerveau]: The upcoming app [Cerveau](http://www.cerveau.app/) provides a web interface for editing your Neuron notes on Git. diff --git a/guide/cc1f7ecf.md b/guide/cc1f7ecf.md index befc308ac..b52fa5db9 100644 --- a/guide/cc1f7ecf.md +++ b/guide/cc1f7ecf.md @@ -12,7 +12,7 @@ neuron query neuron query -t science ``` -You may also pass the same URI you use in <2011506>: +You may also pass the same URI you use in [[[2011506]]]: ```bash # Search using link URI diff --git a/guide/index.md b/guide/index.md index 10e95c8e2..834446997 100644 --- a/guide/index.md +++ b/guide/index.md @@ -2,14 +2,14 @@ ![Neuron logo](https://raw.githubusercontent.com/srid/neuron/master/assets/neuron.svg){.ui .tiny .right .floated .image} -[Neuron](https://github.com/srid/neuron) is a future-proof open-source app[^web] for managing your plain-text notes in <2011401> style, as well as for publishing them on the web. Read its <6f0f0bcc>. +[Neuron](https://github.com/srid/neuron) is a future-proof open-source app[^web] for managing your plain-text notes in [[[2011401]]] style, as well as for publishing them on the web. Read its [[[6f0f0bcc]]]. ## Getting started -* <2011501> -* <2011502> -* <2011402> -* <2013101> +* [[[2011501]]] +* [[[2011502]]] +* [[[2011402]]] +* [[[2013101]]] ## External links @@ -18,4 +18,4 @@ * [Project Discussion Chat](https://github.com/srid/neuron#discussion) * [Sponsor the project](https://github.com/sponsors/srid) -[^web]: For a web interface to your neuron notes, see <041726b3> +[^web]: For a web interface to your neuron notes, see [[[041726b3]]] diff --git a/neuron/neuron.cabal b/neuron/neuron.cabal index 2fc96c480..2b54caa51 100644 --- a/neuron/neuron.cabal +++ b/neuron/neuron.cabal @@ -1,7 +1,7 @@ cabal-version: 2.4 name: neuron -- This version must be in sync with what's in Default.dhall -version: 0.6.4.0 +version: 0.6.5.0 license: AGPL-3.0-only copyright: 2020 Sridhar Ratnakumar maintainer: srid@srid.ca diff --git a/neuron/src/lib/Neuron/Reader/Markdown.hs b/neuron/src/lib/Neuron/Reader/Markdown.hs index ec5d9ebf6..60c0bcaa3 100644 --- a/neuron/src/lib/Neuron/Reader/Markdown.hs +++ b/neuron/src/lib/Neuron/Reader/Markdown.hs @@ -15,12 +15,12 @@ import qualified Commonmark.Blocks as CM import qualified Commonmark.Extensions as CE import qualified Commonmark.Inlines as CM import qualified Commonmark.Pandoc as CP -import qualified Commonmark.Tag import Commonmark.TokParsers (noneOfToks, symbol) import Commonmark.Tokens (TokType (..)) import Control.Monad.Combinators (manyTill) import Control.Monad.Except import Data.Tagged (Tagged (..)) +import qualified Data.Text as T import qualified Data.YAML as YAML import Neuron.Orphans () import Neuron.Reader.Type (ZettelParseError, ZettelReader) @@ -103,8 +103,8 @@ neuronSpec :: CM.SyntaxSpec m il bl neuronSpec = mconcat - [ wrappedLinkSpec angleBracketLinkP, - wrappedLinkSpec wikiLinkP, + [ autoLinkSpec, + wikiLinkSpec, gfmExtensionsSansEmoji, CE.fancyListSpec, CE.footnoteSpec, @@ -125,41 +125,57 @@ neuronSpec = <> CE.taskListSpec -- | Convert the given wrapped link to a `B.Link`. -wrappedLinkSpec :: +autoLinkSpec :: (Monad m, CM.IsBlock il bl, CM.IsInline il) => - P.ParsecT [CM.Tok] (CM.IPState m) (StateT Commonmark.Tag.Enders m) [CM.Tok] -> CM.SyntaxSpec m il bl -wrappedLinkSpec linkP = +autoLinkSpec = mempty - { CM.syntaxInlineParsers = [pLink linkP] + { CM.syntaxInlineParsers = [pLink] } where pLink :: (Monad m, CM.IsInline il) => - P.ParsecT [CM.Tok] (CM.IPState m) (StateT Commonmark.Tag.Enders m) [CM.Tok] -> CM.InlineParser m il - pLink p = P.try $ do - x <- p + pLink = P.try $ do + x <- angleBracketLinkP let url = CM.untokenize x title = "" pure $! CM.link url title $ CM.str url -angleBracketLinkP :: Monad m => P.ParsecT [CM.Tok] s m [CM.Tok] -angleBracketLinkP = do - void $ symbol '<' - -- NOTE: Intentionally be lenient to support `` style - -- queries. FIXME: Should fail on `` though (HTML end tags). TODO: - -- Add unit tests before modifying this matching any further. - x <- some (noneOfToks [Symbol '>', Spaces, UnicodeSpace, LineEnd]) - void $ symbol '>' - pure x - -wikiLinkP :: Monad m => P.ParsecT [CM.Tok] s m [CM.Tok] -wikiLinkP = do - void $ symbol '[' >> symbol '[' - x <- some (noneOfToks [Symbol ']', Spaces, UnicodeSpace, LineEnd]) - void $ symbol ']' >> symbol ']' - pure x +wikiLinkSpec :: + (Monad m, CM.IsBlock il bl, CM.IsInline il) => + CM.SyntaxSpec m il bl +wikiLinkSpec = + mempty + { CM.syntaxInlineParsers = [pLink] + } + where + pLink :: + (Monad m, CM.IsInline il) => + CM.InlineParser m il + pLink = P.try $ do + url <- + P.choice + [ -- Folgezettel link: [[[...]]] + P.try (CM.untokenize <$> wikiLinkP 3), + -- Cf link: [[...]] + addCfToURI . CM.untokenize <$> wikiLinkP 2 + ] + let title = "" + pure $! CM.link url title $ CM.str url + -- Add "cf" flag to the URI, without parsing and re-rendering it. + addCfToURI :: Text -> Text + addCfToURI s = + -- This is kind of a HACK, but it works. + if isJust (T.find (== '?') s) + then s <> "&cf" + else s <> "?cf" + wikiLinkP :: Monad m => Int -> P.ParsecT [CM.Tok] s m [CM.Tok] + wikiLinkP n = do + void $ M.count n $ symbol '[' + x <- some (noneOfToks [Symbol ']', Spaces, UnicodeSpace, LineEnd]) + void $ M.count n $ symbol ']' + pure x -- rawHtmlSpec eats angle bracket links as html tags defaultBlockSpecsSansRawHtml :: (Monad m, CM.IsBlock il bl) => [CM.BlockSpec m il bl] @@ -182,4 +198,16 @@ myRawHtmlSpec :: myRawHtmlSpec = -- TODO: Ideally we should use a more restrictive parsers; one that allows known safe HTML tags -- Although, this prevents the user from naming their zettels say "div.md" - CM.rawHtmlSpec {CM.blockStart = P.notFollowedBy angleBracketLinkP >> CM.blockStart CM.rawHtmlSpec} + CM.rawHtmlSpec + { CM.blockStart = P.notFollowedBy angleBracketLinkP >> CM.blockStart CM.rawHtmlSpec + } + +angleBracketLinkP :: Monad m => P.ParsecT [CM.Tok] s m [CM.Tok] +angleBracketLinkP = do + void $ symbol '<' + -- NOTE: Intentionally be lenient to support `` style + -- queries. FIXME: Should fail on `` though (HTML end tags). TODO: + -- Add unit tests before modifying this matching any further. + x <- some (noneOfToks [Symbol '>', Spaces, UnicodeSpace, LineEnd]) + void $ symbol '>' + pure x