Code Monkey home page Code Monkey logo

obsidian-footnotes's Introduction

Obsidian Footnotes Plugin

This hotkey lets you:

  • Insert a new footnote marker (e.g. [^1]) with auto-incremented index in your text
    • Adds the footnote detail (e.g. [^1]: ) at the bottom of your text
    • Places your cursor so you can fill in the details quickly
  • Jump from your footnote TO the footnote detail
  • Jump from your footnote detail BACK to the footnote

Overview

IMPORTANT: You must to set up your footnote hotkey

After installing and activating this plugin, you still have to SET UP your hotkey. This is easy and quick:

Settings -> Hotkeys -> Search for "Footnote" -> Customize Command -> Your preferred hotkey

I personally use Command+Shift+6 because "6" on a US keyboard is where the uptick/footnote character "^" is.

Hotkey

Default Feature Details

Scenario: No previous numeric (e.g. "[^1]") footnotes exist:

  • Given my cursor is where I want a footnote to exist (e.g. Foo bar baz▊)
  • When I hit my footnote hotkey
  • Then a new footnote marker (e.g. [^1]) is inserted where my cursor was (e.g. Foo bar baz[^1])
  • And a new footnote details marker (e.g. [^1]: ) is inserted on the last line of the document
  • And my cursor is now placed at the end of the detail marker (e.g. [^1]: ▊)

Scenario: Previous numeric (e.g. "[^1]") footnotes exist:

  • Given there is one or more numeric footnotes in my text
  • And my cursor is where I want a footnote to exist (e.g. Foo bar[^1] baz▊)
  • When I hit my footnote hotkey
  • Then a new footnote marker with the next numeric index (e.g. [^2]) is inserted where my cursor was (e.g. Foo bar[^1] baz[^2])
  • And a new footnote details marker (e.g. [^2]: ) is inserted on the last line of the document
  • And my cursor is now placed at the end of the detail marker (e.g. [^2]: ▊)

Scenario: Jumping TO a footnote detail

  • Given I'm on a footnote detail line (e.g. [^1]: ▊)
  • When I hit my footnote hotkey
  • Then my cursor is placed right after the first occurence of this footnote in my text (e.g. [^1]▊)

Scenario: Jumping BACK to a footnote

  • Given I'm on - or next to - a footnote (e.g. [^1]▊) in my text
  • When I hit my footnote hotkey
  • Then my cursor is placed to the right of the footnote (e.g. [^1]: ▊)

Known Limitations or Untested Scenarios

Indices are not updated

Inserting new footnote in-between two existing footnotes will insert the next numeric index (e.g. 1, 3, 2).

It will NOT update the indices according to their natural order (e.g. 1, 2, 3).

Example sentence[^1] with two▊ footnotes[^2] already.
  
[^1]: Foo
[^2]: Bar

After insertion:

Example sentence[^1] with two[^3] footnotes[^2] already.
  
[^1]: Foo
[^2]: Bar
[^3]: Baz

See "Automatically Re-Index Footnotes" below for a proposed feature

Future Possible Feature Ideas

Automatically Re-Index Footnotes

Re-index and re-sort all footnotes when you insert a new one in-between one or more existing numbered footnotes:

Example sentence[^1] with two▊ footnotes[^2] already.
  
[^1]: Foo
[^2]: Bar

Base Scenario

  • Given there are two footnotes already
  • When I enter a new footnote in-between those two
  • Then the NEW footnote gets the index "2"
  • And the previously second footnote gets the index "3"
  • And the NEW footnote detail is inserted as the second entry at the bottom
  • And the previously second footnote detail at the bottom is updated to be "3"
  • And the previously second footnote detail at the bottom is updated to be in third position
Example sentence[^1] with two[^2] footnotes[^3] already.

[^1]: Foo
[^2]: Baz
[^3]: Bar▊

Edge Cases to consider ("What if...?")

What if... new footnote is inserted before the first footnote?
Some sentence▊ with existing note[^1]

[^1]: Details
What if... text has the same footnote at several places?
Some sentence with existing note[^1] and the same▊ footnote re-appears later[^1].


[^1]: Details
What if...Footnote details are spread across the text?
Some sentence with existing note[^1] some more text▊ 

[^1]: Inline footnote details

Another text part▊
What if... the footnote details are multi-line on the bottom?
Some sentence with existing note[^1] some more text▊ 

[^1]: The details that
Span across
Multiple lines
What if... there are non-numeric footnotes in the text?
Some sentence with existing note[^] some more text▊ 

[^]: Details

Background

This plugin is based on the great idea by jacob.4ristotle posted in the "Footnote Shortcut" thread.

Use case or problem:

I use Obsidian to take school notes, write essays and so on, and I find myself needing to add frequent footnotes. Currently, to add a new footnote, I need to:

  • scroll to the bottom to check how many footnotes I already have
  • type [^n] in the body of the note, where n is the next number
  • move to the end of the note, type [^n] again, and then add my citation.

Proposed solution:

It would be convenient to have a shortcut to automate these steps. In particular, I envision that the shortcut would: Using the smallest natural number n that has not yet been used for a footnote

  • add [^n] at the insertion point
  • add [^n]: to the end of the note, and move the insertion point there.

obsidian-footnotes's People

Contributors

akaalias avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

obsidian-footnotes's Issues

Cursor does not jump to bottom of text

When I use the shortcut for the footnote (I use ctrl + ^) then a Footnote ist placed right where my cursor is but the Cursor stays there and does not jump to the bottom ob the text nor is a second Footnote created at the bottom line.

Klaas' Feature Request: Reindexing with pre-existing inline footnotes

Given I have inline footnotes in my text

bla bla bla^[inline footnote text]
ble ble ble^[another inline footnote text]

In Preview this will rendered as:

bla bla bla[1]
ble ble ble[2]

[1]: inline footnote text
[2]: another inline footnote text

When I have my cursor in-between the two existing inline footnotes

And I hit Command-Shift-P

bla bla bla^[inline footnote text]
meh meh█
ble ble ble^[another inline footnote text]

Then I want to see the new footnote to be with index [^2]

bla bla bla^[inline footnote text]
meh meh[^2]
ble ble ble^[another inline footnote text]

And at the bottom of the note in Preview see:

[1]: inline footnote text
[2]: newly inserted “normal” footnote text
[3]: another inline footnote text

Misalignment of footnote number and text in Preview

I tested the plug-in (0.0.6) in a note with pre-existing inline footnotes. The "Alexis" (= normal 😄 ) footnote , number 2 in this case, between 2 pre-existing footnotes has its text on a line below the number - see screenshot below.

image

[bug] Re-indexing not being saved

Love the plugin, this feels like core functionality. Noticed a minor issue where auto re-indexing is working correctly in Reading View, but the indexing is reverted on LivePreview.
For example, in live preview while editing
Live_preview
Reading Mode
ReadingView
The indexing reverts back on entering edit mode again.

Add an explicit license

In order to future proof this plugin it is necessary to put it under a license that allows forking in case this repository gets abandoned. See #12 (comment)

Found a bug

If there is text on the last line, the generated footnotes will be invalid in preview.
Consider the following code:
if (lastLine.length > 0) {
if(lastLine.match(detailLineRegex)) {
editor.replaceRange(\n[^${footNoteId}]: , { line: doc.lineCount(), ch: 0 });
}else{
editor.replaceRange(\n\n[^${footNoteId}]: , { line: doc.lineCount(), ch: 0 });
}
}

feature request: repurpose to also use this for markdown reference links

Thank you for the good work on this plugin. I was curious if you could add the feature (or repurpose into a new plugin) where we're also able to use this workflow for inserting markdown "reference" links.

I find that this lands up obstructing in the "readability" of the markdown document: for example

I use a few search engines: [Google](https://google.com), [duckduckgo](https://duckduckgo.com/) and [bing](https://bingcom/)

is harder to read than this:

I use a few search engines: [Google][g], [duckduckgo][d] and [bing][b]

[g](https://google.com)
[d](https://duckduckgo.com/)
[b](https://bingcom/)

This gets particularly gnarly when you have longer document links. Would it be possible to achieve something similar so that the reference link is auto inserted at the bottom?

Much thanks again for this.

Plugin does not work in Obsidian Live Preview Mode

Unfortunately, the plugin does not work correctly in the new, experimental, live preview mode. It creates the footnote on the original text but does not create the reference or jump the cursor for easy insertion.

Footnote marker inserted, but not the footnote itself

I have just tried to use this plugin. Unfortunately, although it inserts the footnote marker in the main text, it doesn't add the footnote itself to the end of the page.

I'm using Obsidian v0.13.19 on Windows 10.

Here are the plugins I have installed:

Mode LastWriteTime Length Name


d----- 06/01/2022 23:44 advanced-toolbar
d----- 06/01/2022 23:37 better-pdf-plugin
d----- 06/01/2022 23:12 calendar
d----- 06/01/2022 23:35 convert-url-to-iframe
d----- 07/01/2022 22:45 dangerzone-writing-plugin
d----- 06/01/2022 23:28 darlal-switcher-plus
d----- 12/01/2022 20:02 dataview
d----- 08/01/2022 19:28 find-unlinked-files
d----- 08/01/2022 19:43 highlightr-plugin
d----- 15/01/2022 10:35 nldates-obsidian
d----- 06/01/2022 23:23 note-refactor-obsidian
d----- 08/01/2022 19:09 obsidian-advanced-uri
d----- 06/01/2022 23:41 obsidian-auto-link-title
d----- 06/01/2022 23:24 obsidian-citation-plugin
d----- 07/01/2022 22:34 obsidian-dictionary-plugin
d----- 09/01/2022 15:29 obsidian-excalidraw-plugin
d----- 06/01/2022 23:32 obsidian-extract-pdf-highlights
d----- 08/01/2022 19:56 obsidian-flexible-pomo
d----- 06/01/2022 23:40 obsidian-footnotes
d----- 06/01/2022 23:36 obsidian-fullscreen-plugin
d----- 06/01/2022 23:10 obsidian-image-toolkit
d----- 06/01/2022 23:06 obsidian-kanban
d----- 06/01/2022 23:28 obsidian-kindle-plugin
d----- 06/01/2022 23:16 obsidian-mind-map
d----- 06/01/2022 23:15 obsidian-outliner
d----- 06/01/2022 23:29 obsidian-pandoc
d----- 08/01/2022 19:57 obsidian-statusbar-pomo
d----- 06/01/2022 23:10 oz-clear-unused-images
d-r--- 06/01/2022 20:14 oz-image-plugin
d----- 07/01/2022 22:38 periodic-notes
d----- 08/01/2022 19:11 quickadd
d----- 13/01/2022 19:45 recent-files-obsidian
d----- 13/01/2022 19:45 remember-cursor-position
d----- 06/01/2022 23:13 sliding-panes-obsidian
d----- 07/01/2022 22:49 tag-wrangler
d----- 06/01/2022 23:10 taskbone-ocr-plugin
d----- 06/01/2022 23:36 todoist-sync-plugin
d----- 06/01/2022 23:34 tq-obsidian
d----- 06/01/2022 23:23 url-into-selection

On iPadOS the reference, but not the footnote, gets added

Thank you for this wonderful plugin!

On iPadOS, invoking the Footnote Shortcut command creates a reference (e.g., [^1]), but the expected action of adding the footnote detail (e.g., [^1]: ) at the bottom of the text does not occur. Is this a known issue?

Not numbering properly between edit and preview

In edit mode footnote numbers correlate to when they were inserted not where they fall in the order of the text. In Preview mode this doesn't seem to be a problem.

The confusion comes when switching back and forth between the two views. The same footnote ^1 in Preview will show up as ^6 in Edit if the footnote was inserted after the others chronologically.

Preview mode:
Screen Shot 2021-10-22 at 11 17 16 AM

Edit mode:
Screen Shot 2021-10-22 at 11 17 30 AM

[bug] footnote not work on todo line

os: macOS montery 12.3.1
obsidian version: v0.14.5
obsidian theme: Primary
footnote shortcut plugin version: 0.0.8

# works well
test1 [^1]

# works well
- test2 [^2]

# not works
- [ ] test3 [^3]

if i add footnote at the end of a todo line(see above test3), it not works well.

  • readview footnote style
  • link not works

I record a gif of this case

CleanShot 2022-04-15 at 15 32 03

Plug-ins that can solve the sorting problem

Obsidian Tidy Footnotes
Adds a command in Obsidian that tidies your footnotes so they're easy to follow:

Consolidates all footnote definitions into one place, sorted by appearance
Re-indexes numbered footnotes (e.g., [^1][^4][^2] becomes [^1][^2][^3])

Feature suggestion: allow non-numerical footnotes

Firstly, thank you for an excellent plugin, not being able to do footnotes easily added a lot of friction for me, now this is fixed!

I previously edited my markdown in vim, and had a mapping that does basically the same thing as this plugin, but takes the word under the cursor as footnote id.

For example:

This is some text and this is my source footnotesource.

If I put my cursor on "footnotesource", it would change this to

This is some text and this is my source [^footnotesource].

[^footnotesource]: <cursor>

My main use case for this - I often edit separate markdown files that then get merged into a big one, and all the footnotes shouldn't get mixed up, same for copypasting snippets. Another way to solve this would be to randomize the footnotes, though this would hurt readability.

I'd gladly help with this if this is needed by at least some other people, this issue is also a way to gauge interest in that

SH

add empty line before the footnote definition

when there is no empty line at the end of the text, the plugin will add the footnote text directly below the text – however, having a line break in between those would be cleaner to read.

Screenshot 2021-10-12 18 37 07

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.