# Proposal to allow specifying a text snippet in a URL fragment inside blockquotes in CommonMarkdown

**URL:** <https://talk.commonmark.org/t/proposal-to-allow-specifying-a-text-snippet-in-a-url-fragment-inside-blockquotes-in-commonmarkdown/4225>\
**Category:** Implementation\
**Created:** [July 5, 2022, 5:23pm UTC](https://talk.commonmark.org/t/proposal-to-allow-specifying-a-text-snippet-in-a-url-fragment-inside-blockquotes-in-commonmarkdown/4225 "2022-07-05T17:23:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon20778841](https://cdn.commonmark.org/letter_avatar_proxy/v2/letter/a/8e7dd6/32.png) [@anon20778841](https://talk.commonmark.org/u/anon20778841)\
**Post date:** [July 5, 2022, 5:23pm UTC](https://talk.commonmark.org/t/proposal-to-allow-specifying-a-text-snippet-in-a-url-fragment-inside-blockquotes-in-commonmarkdown/4225/1 "2022-07-05T17:23:06Z")

</div>

##### 1. feature-name

Proposal to allow specifying a text snippet in a URL fragment inside blockquotes in CommonMarkdown

##### 2. feature-description

##### 2.1 Overview

Nearly all Markdown applications support the basic syntax outlined in the original Markdown design document. There are minor variations and discrepancies between Markdown processors — those are noted inline wherever possible.

##### 2.2 proposal

Proposal to allow specifying a text snippet in a URL fragment inside blockquotes in CommonMarkdown

##### 2.3 concept/idea/draft syntax

```auto
// context |-------match-----| context
:~:text=[prefix-,]textStart[,textEnd][,-suffix]

```

##### 2.3.1 sample

```auto
https://example.com#:~:text=prefix-,startText,endText,-suffix

```

##### 3. syntax, tags: ‘syntax’, ‘demo’, ‘algorithm’, ‘regex’, ‘constants’, ‘js’

```javascript

const blockquote = (^> ?.+?)((\r?\n\r?\n\w)|\Z) 
// syntax: '>', sample: > text

const pattern = /!?\[(.+)?\]\(((https?:\/\/)?[A-Za-z0-9\:\/\.]+)(\"(.+)\")?\)/gm 
// syntax: '[]()', sample: [text](url)

const textSnippetUrl = :~:text=[prefix-,]textStart[,textEnd][,-suffix]

```

##### 3.1. demo: blockquote in Commonmark ‘before’

```auto
> Dorothy followed her through many of the beautiful rooms in her castle.

```

##### 3.2 demo: blockquote in Commonmark with cite/text-fragments ‘after’

```auto
> [cite](https://dorothy.sample.net/blog/blogtest/#:~:text=blogtest,blogtest2)
// output: Dorothy followed her through many of the beautiful rooms in her castle.

```

#### 4. Questions

1. An important and interesting question: is it possible to use text fragments in CommonMarkdown?
2. Is it possible to have a new syntax for what I’m asking for?
3. Why?
  - “If Commonmark start using the blockquote with attribute url and text-fragment… This allow users to navigate to the page that contains the quote.”
  - “This can help the WIGC community and the Commonmark community”
  - “Innovative feature”
  - “I would like to HTML Quotation and Citation Elements from fragmented texts”
  - To create a blockquote, add a `>` in front of a paragraph. But there is no possibility to add a fragmented cite.

##### 5. Input/Output or ‘rules’

##### 5.1 input

```auto
> This is blockquote text

```

##### 5.1.2 output

```auto
<blockquote>
    <p>This is blockquote text</p>
</blockquote>

```

##### 5.2 input

```auto
> [cite](https://oleb.net/2020/swift-docker-linux/#:~:text=running,container)

```

##### 5.2.1 output

```auto
<blockquote cite="https://oleb.net/2020/swift-docker-linux/#:~:text=running,container">
    <p>This is blockquote text</p>
</blockquote>

```

#### 6. Security/Problem/Notes

1. If the quoted website removed the quoted text, that would break this feature. _ **Note 1: This issue can occur when you quote something on some outside website or server.** _, _ **Note 2: This feature is great on local files like Obsidian, Dendron, Notion etc. Because you can have a central files, it’s easy to find various types of documents with this.** _
2. I think the quoted text should be included directly in the HTML document.

#### 7. References

- [Possible Bug of List and Blockquote - #2 by jgm](https://talk.commonmark.org/t/possible-bug-of-list-and-blockquote/2025/2)
- [Why is the blockquote split into two in this case?](https://talk.commonmark.org/t/why-is-the-blockquote-split-into-two-in-this-case/879)
- [Blockquotes - could spec require strict indent before/after "\>"? - #3 by vitaly](https://talk.commonmark.org/t/blockquotes-could-spec-require-strict-indent-before-after/984/3)
- [Blockquotes - whitespace after `\>`](https://talk.commonmark.org/t/blockquotes-whitespace-after/2956)
- [Fenced blockquote](https://talk.commonmark.org/t/fenced-blockquote/2370)
- [[Proposal] Allow scrolling to a specified text snippet in a navigation](https://discourse.wicg.io/t/proposal-allow-scrolling-to-a-specified-text-snippet-in-a-navigation/3442)
- [https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url](https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url)
- [HTML Quotation and Citation Elements from fragmented texts](https://discourse.wicg.io/t/html-quotation-and-citation-elements-from-fragmented-texts/5918)
- [RFC Spec extension for \*tables\*: Syntax and transformation rules](https://talk.commonmark.org/t/rfc-spec-extension-for-tables-syntax-and-transformation-rules/1910)
- [Markdown Tutorial - Blockquotes](https://commonmark.org/help/tutorial/05-blockquotes.html)
- [Project ANN+RFC: Extending and using CommonMark in new ways](https://talk.commonmark.org/t/project-ann-rfc-extending-and-using-commonmark-in-new-ways/1896)
- [GitHub - WICG/scroll-to-text-fragment: Proposal to allow specifying a text snippet in a URL fragment](https://github.com/WICG/scroll-to-text-fragment)
- [Markdown Tutorial - Blockquotes](https://commonmark.org/help/tutorial/05-blockquotes.html)
- [Basic Syntax | Markdown Guide](https://www.markdownguide.org/basic-syntax/)
- [Regex to match markdown links](https://davidwells.io/snippets/regex-match-markdown-links)
- [https://medium.com/@michael\_perrin/match-markdown-links-with-advanced-regex-features-fc5f9f4122bc](https://medium.com/@michael_perrin/match-markdown-links-with-advanced-regex-features-fc5f9f4122bc)
- [https://stackoverflow.com/questions/37462126/regex-match-markdown-link](https://stackoverflow.com/questions/37462126/regex-match-markdown-link)
- [https://stackoverflow.com/questions/28391298/how-do-i-define-a-regex-that-will-match-blockquotes-in-markdown](https://stackoverflow.com/questions/28391298/how-do-i-define-a-regex-that-will-match-blockquotes-in-markdown)
- [Regex to match markdown links in Javascript - DEV Community](https://dev.to/davidwells/regex-to-match-markdown-links-in-javascript-472h)
- [Learn Markdown Blockquotes: Unleash the Power of formatting styles](https://www.w3schools.io/file/markdown-blockquotes/)
- [https://stackoverflow.com/questions/28391298/how-do-i-define-a-regex-that-will-match-blockquotes-in-markdown](https://stackoverflow.com/questions/28391298/how-do-i-define-a-regex-that-will-match-blockquotes-in-markdown)
- [Regex to match markdown links in Javascript - DEV Community](https://dev.to/davidwells/regex-to-match-markdown-links-in-javascript-472h)
- [https://stackoverflow.com/questions/37462126/regex-match-markdown-link](https://stackoverflow.com/questions/37462126/regex-match-markdown-link)
- [https://stackoverflow.com/questions/2002120/citing-the-author-of-a-blockquote-using-markdown-syntax](https://stackoverflow.com/questions/2002120/citing-the-author-of-a-blockquote-using-markdown-syntax)
- [Boldly link where no one has linked before: Text Fragments &nbsp;|&nbsp; Articles &nbsp;|&nbsp; web.dev](https://web.dev/text-fragments/)
- [RFC 3778 - The application/pdf Media Type](https://datatracker.ietf.org/doc/html/rfc3778#section-3)
- [Media Fragments URI 1.0 (basic)](https://www.w3.org/TR/media-frags/#media-fragment-syntax)

---

<div class="post-metadata">

**Author:** ![anon20778841](https://cdn.commonmark.org/letter_avatar_proxy/v2/letter/a/8e7dd6/32.png) [@anon20778841](https://talk.commonmark.org/u/anon20778841)\
**Post date:** [August 7, 2022, 4:39am UTC](https://talk.commonmark.org/t/proposal-to-allow-specifying-a-text-snippet-in-a-url-fragment-inside-blockquotes-in-commonmarkdown/4225/2 "2022-08-07T04:39:48Z")

</div>

#### example

![](https://cdn.commonmark.org/uploads/default/original/2X/a/ae1c89f0f9fb556a00f54ea297af8741a4bf947d.gif)

#### link

> **[Web annotation / higlights via text fragments](https://discuss.logseq.com/t/web-annotation-higlights-via-text-fragments/9171)**
>
> I’d love to see a native web highlighter with similar ux as the pdf annotation system or the video annotation system : open any website on a left pane or insert an iframe with a webpage url highlight and copy references via a right click menu or...
