Link Search Menu Expand Document

10 Blocks

Goals

Implement Roam like block references in Dendron

Context

Block references let you embed blocks of text into different parts of your code

Lookup

This section describes existing work that has been done on this topic.

Proposal

Extend Dendron syntax to support block references. Obsidian has a great implementation of this already - unless there are critical deficiencies, we should adhere to their implementation and strive for interoperability.

Concepts

A block link has the following format. It is created in a note that is referencing a piece of text. When navigating the link, users should be taken to the block anchor.

[[somelink#^1234]]

Block Anchor

A block anchor has the following format. It is created in the note where a block link is targeting.

{Some markdown block element} ^1234

A block reference link is a reference to a block link.

![[somelink#^1234]]

Details

  • to create a block, add #^{id} to the end of a wiki link
    [[filename#^1234]]
    
  • typing ^ will trigger a search of all blocks that currently exist within the file
  • inputting enter will generate a block anchor, a random id, in the target file
  • typing ^^ will trigger a search of all existing block anchors

Tasks

Example

  • link to block
Some notes ^dcf64c

[[filename#^dcf64c]]

More notes
  • html
<!-- source -->
<div id="dcf64c">
<a aria-hidden="true" href="#dcf64c"><span class="icon icon-link"></span></a>
<p> Some notes </p>
</div>

<a  href="...#^dcf64c">filename</a>

<div>
<p> More Notes </p>
</div>
  • link to block

    • file a
    Some notes ^dcf64c
    
    • file b
    [[filename#^dcf64c]]
    
    More notes
    
  • html

    • a.html
    <!-- source -->
    <div id="dcf64c">
    <a aria-hidden="true" href="#dcf64c"><span class="icon icon-link"></span></a>
    <p> Some notes </p>
    </div>
    
    • b.html
    <a  href="...#^dcf64c">filename</a>
    
    <p> More Notes </p>
    

Block reference to other file

  • link to block

    • file a
    Some notes ^dcf64c
    
    • file b
    ![[filename#^dcf64c]]
    
    More notes
    
  • html

    • a.html
    <!-- source -->
    <div id="dcf64c">
    <a aria-hidden="true" href="#dcf64c"><span class="icon icon-link"></span></a>
    <p> Some notes </p>
    </div>
    
    • b.html
    <p>Some notes</p>
    
    <p> More Notes </p>
    

Tradeoffs

  • we are using a purely plaintext based approach of doing block references which means that we are leaving artifacts in the source doc when we generate a block reference
    • alternatives are using a separate mapping file or using a db, the former adds a layer of indirection that doesn't fit with our current note modal, the latter is currently out of scope

Discussion


Children

  1. HTML Integration
  2. Markdown Integration
  3. Parsing Block Syntax
  4. Vscode Integration