Create a link inside a block

What I’m trying to do

I have blocks of text of hundreds of lines.
The obsidian ‘internal links’ help page only explains how to link to a block in a note, but not to a specifig place inside this note.
Is it possible ?

Things I have tried

I have tried to place my anchor for instance « ^b » somewhere inside the block, but when I type the call link formula, neither « ^b » is proposed to be linked, nor does the « [[#^b]] » formula works and make the link connection to « ^b ».

Thanks in advance for your help.

If the blocks are separated by blank lines, you should be able to link to them.

Type [[ and start typing the name of the note. Use your up/down arrow keys to select the note you want (don’t hit enter)

then type ^ (usually shift + 6). Then use the arrow keys again to select the block

and hit enter when you’ve found the block/section you want to link to. A link and block ID will be created.

Does that work?

See also official help page.

And, this plugin makes it easy to automatically assign and copy links to blocks!

Thanks Ariehen for your detailed reply.

Yes it works, but this is not what I am looking for, maybe I was not clear : what I look for is to make a link in a certain place inside a block.

For instance I have a block a 300 hundred lines, and I want to make a link to a sentence written in the line number 150 inside this block.
If I link the block, I will have to read the 300 lines to find the sentence I am looking for.

Can you get what I mean ?

Do you know if that is ever possible (with a specific plugin for instance) ?

Best regards

Ah, I understand (your post title is clear :pensive:).

I don’t think there’s currently a way to link to individual sentences or words within a block. There may be a plugin to do that, but I haven’t come across one.

Thank you ever, have a good day :slightly_smiling_face:

Hi @buigui - what is it you want to do with the referenced sentence?

There is a plugin that will parse out chunks of text from blocks of text and place them into a variety of destinations - have a look at Extract Highlights - there is a short video that may help you.

Best wishes

Hi Writtenfool,

Thanks for your reply.

For exemple, inside a block of 1000 lines (indented), I would like to make a link from permit my to jump from line 800 to line 300.

Extract-highlights could bu useful to me, but for another need. :slightly_smiling_face:


Out of curiosity, what are you doing that involves blocks that are hundreds of lines long?

I am student, one block is one lesson, indented as per below :
I Title
(one tab then) 1.1 sub-title
(two tabs then) 1.1.1 sub-sub title
(three tabs then) text…

One lesson has generally a few thousand lines.

These format is perfect for me until now, only this link-indise-a-block function is missing to me now.

I know could separate blocks and use headers, and then link either to headers, or to blocks, but the matters it that all my lessons are already formatted in the way I explaned above, as I just discover markdown now, and that I’ve already been working for my lessons for past months.

That mean I would have to re-format all these lessons again, which would be a big quantity of work, and my exams are coming soon. In which case I don’t know, if only to gain the this link function, that would worth it.

1 Like

What you have is an ordered list. If you format it as one, you’ll be able to use block links to link to each item. The easiest way would be to abandon the nested numbers:

1. Title
    1. sub-title
        1. sub-sub title
            - text…

I’m not sure how you’d want to handle the text. In the above example I formatted it as an unordered sub-list. But you could instead format it as paragraphs that are part of the sub-sub title item:

1. Title
    1. sub-title
        1. sub-sub title

If you want to keep the nested numbers, it might be possible with a CSS snippet. You’d type the numbers as above, but then Live Preview and Reading View would show the nested version. I know I’ve seen discussion of this; I don’t recall if it was successful (I also forget the proper name — I know it’s not “nested numbers”).

If a snippet can’t do it, you’d type the nested version after the list marker (Markdown doesn’t accept nested numbers as list markers):

1. Title
    1. 1.1 sub-title
        1. 1.1.1 sub-sub title
            - text…

You could then use a CSS snippet to hide the list markers so you don’t see extra numbers in Live Preview and Reading View.

On the first level they use I Title, which isn’t the start of a numbered lists, and strangely enough all of their example is just garbled up into something non-marked text. So not sure what happens there, but I do believe the solution would/should be to change it into proper lists, ordered or unordered.

This shouldn’t be too hard to do, as one could search for any combination of tabs on the start of the line, and replace the last tab with a dash, -, if one wanted to make it unordered. Or 1. if one wanted ordered lists.

And now when they’re all lists, one could add the blockId a the end of any list items, and make links between any list item of choice using the blockId link type.

Yeah, I guessed the I was a Roman numeral, so a list item in spirit.

1 Like

Thank you all for your all pertinent advices.
Following them, with search/replace tool, I can quite easily transform my current formatting (without lists) into a new one with lists and then use the blockId link type.

For nested numbers I’ll see later if it’s possible, as you suggest again, to indent them automatically (e.g. 1.1.1, then 1.1.2, etc…) with a dedicated code.

As for your suggestion to use my own 1.1.1 indentation types and hide the list numbers with a CSS snippet, in that case, why not use unordered list items instead, which would directly resolve the issue, wouldn’t it? In other words, what difference would there be between ordered list with hidden number, and unordered list ?

Thanks in advance for your replies.

Yeah, that would be easier. The rendered markup won’t convey the proper meaning but that’s unlikely to be a practical problem.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.