# Return text under heading

**URL:** https://community.silverbullet.md/t/return-text-under-heading/895
**Category:** General
**Created:** [August 27, 2024, 12:04pm UTC](https://community.silverbullet.md/t/return-text-under-heading/895 "2024-08-27T12:04:52Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![nickb](https://community.silverbullet.md/user_avatar/community.silverbullet.md/nickb/32/1239_2.png) [@nickb](https://community.silverbullet.md/u/nickb)
#### Post date: [August 27, 2024, 12:04pm UTC](https://community.silverbullet.md/t/return-text-under-heading/895/1 "2024-08-27T12:04:52Z")

</div>

Probably easy one … I have a headings with tags and ‘contained’ text. How might I return the text ‘below’ a heading? For example, with:

```auto
## My heading #aheadingtag

Item content here.

More item content.

## My heading2 #anotherheadingtag

Item2 content here.

More item2 content.

```

… how would I return all the text for #aheadingtag, which would be:

```auto
Item content here.

More item content.

```

Thanks

---

<div class="post-metadata">

### Author: ![Aese](https://community.silverbullet.md/letter_avatar_proxy/v4/letter/a/57b2e6/32.png) [@Aese](https://community.silverbullet.md/u/Aese)
#### Post date: [August 27, 2024, 9:17pm UTC](https://community.silverbullet.md/t/return-text-under-heading/895/2 "2024-08-27T21:17:11Z")

</div>

In theory, something like ![[Test#My heading #aheadingtag]] would work, but it doesn’t seem to function with a tag in it.

So here’s some template code that’s technically functional, if a little fragile:

```template
{{#let @startPos = at({header where page = @page.name and at(tags,0)="aheadingtag" select pos},0)}}
  {{#if @startPos}}
    {{#let @endPos = at({header where page = @page.name and pos > @startPos.pos select pos},0)}}
      {{#if @endPos}}
        {{#each {paragraph where page = @page.name and pos > @startPos.pos and pos < @endPos.pos}}}
{{text}}

{{/each}}
      {{else}}
        {{#each {paragraph where page = @page.name and pos > @startPos.pos}}}
{{text}}

{{/each}}
      {{/if}}
    {{/let}}
  {{/if}}
{{/let}}

```
