A general format for specifying ranges in internal links

I moved a couple of posts into this new thread because they propose a very general way of defining ranges. General is nice but sometimes complex if the problem at hand is narrow.

9 Likes

The syntax for transclusion of range should allow to Exclude first (or last) block/item mentioned in specification of the range.
This would allow to keep adding items to start or end of (sub)list …
… without need to update specification of each transclusion of this (sub)list.

usecases:

  • content of the chapter without header
  • queue/stack of tasks
  • nested (sub)lists

syntax suggestions

  • I suggest double period as distinct range specifier. “..” has minimum of other common meanings so it would intuitively explain itself at first glance to many computer literate people. Wikipedia: Ellipsis (computer programming) → Ranges
  • ![[FileNameORPageURL#^id1..^id2]] transcludes range starting by block with ^id1 and ending by block denoted by ^id2.
  • Assuming that IDs do not start by hyphen, start/end item would be excluded from the range by prefixed hyphen.
  • ![[pageurl#-^id1..^id2]] excludes first block from range so items inserted after ^id1 are automatically transcluded without need to update references.
  • ![[pageurl#^id1..-^id2]] excludes last block from range so items appended to list before ^id2 are automatically transcluded without need to update references.

related requests/functionality:

13 Likes
  • The same as in the post above would work for html elements with id attribute (without caret). e.g. ![[pageurl#id1..id9]], ![[pageurl#-id1..id9]].
  • References to “markdown” block-id and html id can be combined in ranges.
    ![[pageurl#^md-block-id..div-id]]
    ![[pageurl#span-id..-^md-block-id]]
    
  • If there can exist/exists element with ID starting by hyphen then we would need e.g. to enclose such ID in parentheses in order to exclude it from range.

Interfering problem:

Reference to chapter is indistinguishable from reference to html block and (perhaps as a consequence) it is impossible to transclude / refer to html block/element with assigned ID.
For example [[pageurl#markdown-chapter-id]] refering to

# Markdown Chapter ID
Text of the chapter.

is indistinguishable from [[pageurl#span-id]] refering to html span

markdown text 
containing<span id="span-id">html elements</span>

which is standard but does not work in Obsidian.

solution:

I would suggest (before Obsidian 1.0) changing syntax for chapter reference from [[pageurl#markdown-chapter-id]] to [[pageurl##markdown-chapter-id]].

  • This would put markdown headers with associated chapters on the same level as (markdown)-block-IDs with associated blocks.
    First # symbol would always separate fragment from page URL and the second # would denote header just like ^ denotes block. Then we could refer to everything:
![[pageurl#html-element-id]]
![[pageurl##markdown-header-id]]
![[pageurl#^markdown-block-id]]
![[pageurl##first-chapter..#last-chapter]]
![[pageurl#-#intro-chapter..#last-chapter]] where prefixed hyphen excludes introduction chapter from range. 
![[pageurl##intro-chapter..-#index-chapter]]
![[pageurl##first-chapter..]] transclusion starts by first chapter up to the end of page. 
![[pageurl#-#intro-chapter..]] everything after intro chapter up to the end of page. 
![[pageurl#..#last-chapter]] everything up to last chapter (including)
![[pageurl#..-#last-chapter]] everything up to last chapter (excluding)

Possible behavior of references in nested structures:

  • useful e.g. for referencing Bible
  • Distinguish duplicate id’s via tree structure created by chapters, markdown blocks and html elements
    ![[bookname##ch1^v5..#ch2^v3]] - from chapter1/verse(block)3 up to chapter2/verse3
  • limit range by boundaries of surrounding (higher level) block/element:
    ![[pageurl##chapter1..^block-in-chapter1]] would transclude beginning of chapter up to specified block. 
    ![[pageurl#^block-in-chapter1..#chapter1]] would transclude end of chapter starting by specified block. 
    
10 Likes

I created a related FR today and later realized that this FR could solve it, and wrote about my particular use case for it there: Paragraph+List Block Range Transclusions. It lists plugin Quoth that also supports transcluding ranges, which might be a temporary solution for those interested until this FR is implemented.

1 Like

Earlier I wrote my suggestions in comments under Header level support for Linking To/Embedding Ranges - Feature requests - Obsidian Forum before I discovered this topic.
Just linking here for now. I can post it here as well if needed.

I tried to propose a syntax that is both more flexible and readable compared to other proposals I can see.

1 Like