marcusolsson / obsidian-pipe-tricks

Adds support for Wikilink pipe tricks in Obsidian.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pipe tricks for Obsidian

Build Obsidian plugin Buy me a coffee

This plugin is unmaintained: While I've been hoping that I'd be able to update this for Obsidian 1.0, I've chosen to focus on my other plugin, Projects. I don't know when (or if) I'll be able to get back to this plugin.

If you're interested in stepping in as a maintainer, please let me know!

An Obsidian plugin that adds pipe tricks to the Wikilink format used by Obsidian.

From Wikipedia:

The pipe trick uses the pipe character ("|") to save typing the label of a piped link for several kinds of wiki links. This can avoid potentially making an error while typing the label.

When the last character of a link is the pipe character, the pipe trick will automatically generate the text that displays for that link. Its processing removes the parenthesized part of the link title, handles commas in the title, and removes namespace prefixes. The described processing happens at the point of saving the page data, and the generated text is saved with the rest of the page's wiki markup – thus, it is merely an aid to editing.

An even better way to save keystrokes that doesn't need any additional characters is by simply attaching text to the link, as in [[train]]s.

Known limitations

  • The plugin doesn't remove namespace prefixes. Mostly because I haven't seen the need for it yet. Let me know if you'd find it useful.

Examples from Wikipedia

These examples are also used as test cases:

  • [[Pipe (computing)|]] -> [[Pipe (computing)|Pipe]]
  • [[Phoenix, Arizona|]] -> [[Phoenix, Arizona|Phoenix]]
  • [[pipe (computing)|]]s -> [[pipe (computing)|pipes]]
  • [[pipe (computing)|]]mill -> [[pipe (computing)|pipemill]]
  • [[Yours, Mine and Ours (1968 film)|]] -> [[Yours, Mine and Ours (1968 film)|Yours, Mine and Ours]]
  • [[Il Buono, il Brutto, il Cattivo|]] -> [[Il Buono, il Brutto, il Cattivo|Il Buono]]
  • [[pipe (computing)|]]! -> [[pipe (computing)|pipe]]!

Pipe functions

You can also transform link text using pipe functions.

Your links must still end in |, but an additional | before that transforms your text using built-in pipe functions.

For example: [[Brewster Angle|_|]]s[[brewster angles]]

These can also be chained (current this is not very useful...): [[Brewster Angle|_|^|swap|]]s

The symbols and strings in between the pipes are the pipe function names.

List of built-in pipe functions:

  • lower: Hello Worldhello world
  • _: alias for lower
  • upperFirst: hello worldHello world
  • upper_first: alias for upperFirst
  • upperfirst: alias for upperFirst
  • ^: alias for upperFirst
  • capital: hello of worldHello Of World
  • ^^: alias for capital
  • upper: hello worldHELLO WORLD
  • ^^^: alias for upper
  • title: hello of worldHello of World
  • #: alias for title

About

Adds support for Wikilink pipe tricks in Obsidian.

License:MIT License


Languages

Language:TypeScript 76.8%Language:JavaScript 23.2%