Engineering 22 min read

LlamaIndex's Markdown and Obsidian Readers Strip the Links Out of Your Notes by Default — So the AI Can't Tell You Where a Fact Came From

MMNMNOTE
ragllamaindexmarkdownlinkscitationsobsidian

LlamaIndex's MarkdownReader deletes the URL from every [text](url) link before your notes are split into chunks, and ObsidianReader uses it with no way to turn that off 1 2. The model can quote "Smith 2024" but never sees the DOI. The fix: load .md files as plain text and chunk them with MarkdownNodeParser, which kept every URL 3.

The loss is quiet — nothing errors, the answers still read well, and the index looks complete. In a nine-form test note with 7 URLs, the default MarkdownReader passed 3 of them on to the documents; the other 4 never reached the model 4. The package that ships the reader, llama-index-readers-file, was downloaded 1,722,178 times in the 30 days to 13 November 2026 — a figure for the whole package, which ships more than 20 readers, not this reader alone 5.

The default is not new. remove_hyperlinks: bool = True was already in the original parser when it was merged on 31 January 2023, so it has stood for about three years and nine months 6. It is not universal either. LlamaIndex's own one-liner, SimpleDirectoryReader("notes").load_data(), has no Markdown entry in its default reader map and reads .md files as raw text — links included 7. The loss begins when you opt in — including the package README's own file_extractor={".md": MarkdownReader()} recipe 8.

This post shows the two source lines responsible, a receipt for nine link forms across four load paths, why the angle-bracket workaround makes things worse, the fixes in order of preference, and a short check that counts what your loader drops.

The problem in concrete terms: seven URLs in, three out

A test note with nine link forms and seven URLs lost four of them under the default MarkdownReader — the inline link's URL, the autolink, the HTML link target and a link inside a code block. Bare URLs, reference-style definitions, footnote definitions and wikilinks survived. The receipt ran on the released wheels, which match LlamaIndex's main branch byte for byte.

The note is called Reading-notes.md. Each line exercises one path through the reader's code 4:

# Reading notes

Source: [Smith 2024](https://doi.org/10.1000/xyz) found 40%.
Autolink: <https://example.org/raw>
Bare: https://example.org/bare
Wiki: [[Project Alpha]]
Image: ![map of the route](route.png)
Ref: [the report][r1]
HTML: <a href="https://example.org/html">the page</a>
Footnote claim.[^1]

[r1]: https://example.org/ref
[^1]: https://example.org/footnote

## Code

```
curl [x](https://example.org/in-code)
```

Here is what reached the loaded documents, per load path. Versions: llama-index-core 0.14.25, llama-index-readers-file 0.7.0, llama-index-readers-obsidian 0.8.0, Python 3.14.4 4.

Link form in the noteMarkdownReader()MarkdownReader(remove_hyperlinks=False)ObsidianReader(vault)SimpleDirectoryReader + MarkdownNodeParser
Inline [Smith 2024](https://doi.org/…)Smith 2024 — URL gonekeptSmith 2024 — URL gonekept
Autolink <https://…/raw>Autolink: — text and URL gonegonegonekept
HTML <a href="…">the page</a>the page — URL gonethe pagethe pagekept
Link inside a code blockcurl xkeptcurl xkept
Image ![map of the route](route.png)!map of the routekept!map of the routekept
Bare URL in running textkeptkeptkeptkept
Reference definition [r1]: https://…keptkeptkeptkept
Footnote definition with a URLkeptkeptkeptkept
Wikilink [[Project Alpha]]keptkeptkeptkept
URLs that reached the model (of 7)3537

The first row is the one that matters. The sentence that tells a reader where the 40% came from survives as Source: Smith 2024 found 40%. The claim stays — the link to its evidence does not.

MarkdownReader removes links in two places. A flagged regex rewrites [text](url) to text across the whole file before it is split at headings, so no chunk ever holds the URL. Then an unflagged regex deletes everything between < and > in each section, which removes autolinks, HTML link targets and angle-bracket paths.

The constructor sets both defaults on lines 28–29 1:

    def __init__(
        self,
        *args: Any,
        remove_hyperlinks: bool = True,
        remove_images: bool = True,
        separator: str = " ",
        **kwargs: Any,
    ) -> None:

The link regex sits under the docstring "Remove hyperlinks in markdown content." It keeps the bracketed text and discards the parenthesised URL 1:

    def remove_hyperlinks(self, content: str) -> str:
        """Remove hyperlinks in markdown content."""
        pattern = r"\[(.*?)\]\((.*?)\)"
        return re.sub(pattern, r"\1", content)

Order is the important part. parse_tups reads the file, runs remove_hyperlinks, then remove_images, and only then calls markdown_to_tups, which splits the text into sections at headings 1. The reader does track code blocks — but only to find headings, and that runs after the regex. A link inside a fenced block is rewritten like any other.

The second deletion is a postprocessing line at the end of markdown_to_tups, line 98 1:

                re.sub(r"<.*?>", "", value),  # Remove HTML tags

No argument controls it, and it treats any <…> span as a tag — HTML or not. A sentence like If a < b and c > d, stop. came out as If a d, stop., and Map<String, Integer> counts; inside a Java code block came out as Map counts; 4.

In outline, a file passes through the reader like this:

1. read the whole file
2. [text](url)  ->  text            remove_hyperlinks, default True
3. image regex  ->  (never matches) remove_images, default True
4. split into sections at headings  (code blocks tracked here)
5. <anything>   ->  ""              no flag
6. one Document per section

Why links at all? The reader's history offers a design goal, not a rationale. Its author, Hursh Desai, described the original pull request this way: "Most important feature to me is that I decided to chunk the markdown files by the headers instead of by the more random chunking that is usually used." 6 Header chunking was the point — the link default came along with it, and neither package's README mentions hyperlinks at all 8.

Rewriting sources as autolinks — <https://…> — does not escape the reader. The unflagged tag strip deletes the whole autolink, text and URL, even with remove_hyperlinks=False. Angle-bracket link paths such as [My Note](<My Note.md>) lose their target the same way. In this reader, the bracketed forms fare worse than plain inline links.

The obvious move is to dodge the link regex: write the source as <https://doi.org/10.1000/xyz>, which has no square brackets for the pattern to match. The receipt shows why that fails. Autolink: <https://example.org/raw> became Autolink: under every MarkdownReader configuration tested, because line 98 removes everything from < to > 4.

This finding is not ours — Enrico Stauss reported it in May 2024, in an issue titled "MarkdownReader removes hyperlink URLs enclosed in angular brackets". Describing the pass that strips tags, he wrote: "The said postprocessing stel [sic] therefore removes the URL altogether." 9

He added: "I know it's a rather rare case but I'd consider it a bug nonetheless." 9 The issue was closed as not planned on 28 October 2024 by a stale-issue bot, after no maintainer had replied, and the behaviour is unchanged on main 1 9.

Two earlier posts here recommend exactly these bracketed forms, and both are right about what they cover. The period after your link is not part of the URL uses <url> to remove a renderer's guess about where a link ends — and in every renderer tested there, it does.

A space in the note name breaks the Markdown link uses [t](<path>) so CommonMark keeps the path whole. Renderers follow the spec; this reader does not parse Markdown at all — it runs regexes over it.

The receipt for that second form, from a second test note, Angle.md 4:

note text:              See [My Note](<My Note.md>) and <https://example.org/raw>.
MarkdownReader():       See My Note and .
remove_hyperlinks=False: See [My Note]() and .

Keep writing the brackets for your editor and your readers — just do not load those notes through MarkdownReader.

ObsidianReader cannot turn it off

ObsidianReader loads every note by calling MarkdownReader() with no arguments, so the link defaults always apply. Its constructor accepts only input_dir, extract_tasks and remove_tasks_from_text, leaving no way to pass the flag through. Wikilinks survive in the text and in metadata; links to the outside world do not.

The call is on line 97 of the Obsidian reader 2:

                        md_docs = MarkdownReader().load_data(Path(filepath))

The constructor, lines 59–64, has three parameters, none of them about links 2. The result is a split vault. Internal links survive: [[Project Alpha]] stays in the text, and the reader records it in metadata["wikilinks"], alongside backlinks 2 4. The DOI behind "Smith 2024" does not, and no metadata field records it either. The reader keeps the vault's own link graph — and drops its links to sources.

For a vault indexed with ObsidianReader, the receipt matches the default MarkdownReader exactly: 3 of 7 URLs 4. Package downloads give a sense of scale, with a caveat — llama-index-readers-obsidian saw 384 downloads in the same 30-day window, against 1.7 million for the file package 5. Few people use the Obsidian reader. Everyone who does gets this default.

The fix: load Markdown as text and chunk it with MarkdownNodeParser

Skip the Markdown reader. Load .md files with SimpleDirectoryReader, which reads them as raw text by default, then split them with LlamaIndex's MarkdownNodeParser. You still get chunks split at headings, with the heading path in metadata, and in the receipt all seven URLs reached the nodes. Flipping the flag recovers only five.

MarkdownNodeParser lives in llama-index-core. Its docstring says it "Splits a document into Nodes using Markdown header-based splitting logic" and that each node carries "the path of headers leading to it" 3. That is the feature the original reader was built for — without the regexes. Fix (a); the loading and splitting lines were run at the versions above 4:

from llama_index.core import SimpleDirectoryReader, VectorStoreIndex
from llama_index.core.node_parser import MarkdownNodeParser

docs = SimpleDirectoryReader("notes", required_exts=[".md"], recursive=True).load_data()
nodes = MarkdownNodeParser().get_nodes_from_documents(docs)
index = VectorStoreIndex(nodes)

On the nine-form note this produced two nodes, one per heading, with the DOI, the autolink and all 7 URLs intact. The MarkdownNodeParser output keeps the heading line in the node text, so # Reading notes and ## Code stay with their sections 4. Building the index needs whatever embedding model you have configured; the loading and splitting lines need nothing else.

Fix (b) is one argument: MarkdownReader(remove_hyperlinks=False). Inline links and links in code come back — 5 of 7 URLs — but the tag strip still deletes autolinks and HTML link targets 4. Passing remove_images=False as well changes nothing, for a reason covered under trade-offs. Use (b) only if your notes contain no angle brackets anywhere — prose included.

Fix (c) is for ObsidianReader users who want its wikilink and backlink metadata. Because the reader looks up MarkdownReader by name in its own module, you can swap in a configured version before loading:

import functools
import llama_index.readers.obsidian.base as obsidian_base
from llama_index.readers.file import MarkdownReader

obsidian_base.MarkdownReader = functools.partial(MarkdownReader, remove_hyperlinks=False)
docs = obsidian_base.ObsidianReader("vault").load_data()

On the test vault, the DOI came back, 5 of 7 URLs reached the documents, and wikilinks still listed Project Alpha 4. It is a patch on a module-level name, so pin the package version — a refactor of the reader would break it silently. The sturdier alternative is to copy the reader's load_data into your own class.

Check what the loader feeds the model

Count the URLs in each file, count them again in what the loader returns, and print any note where the second number is smaller. The script below does that for whichever reader your pipeline uses. On the test vault it flagged both notes: 7 URLs in the file and 3 after loading, and 1 and 0.

This is fix (d) — and it applies to any loader, not just this one:

import re
from pathlib import Path
from llama_index.readers.file import MarkdownReader

reader = MarkdownReader()          # or whatever reader your pipeline uses
url = re.compile(r"https?://")

for path in sorted(Path("notes").rglob("*.md")):
    in_file = len(url.findall(path.read_text(encoding="utf-8")))
    loaded = "\n".join(d.text for d in reader.load_data(path))
    in_docs = len(url.findall(loaded))
    if in_docs < in_file:
        print(f"{path.name}: {in_file} URLs in the file, {in_docs} after loading")

Its output on the test vault 4:

Angle.md: 1 URLs in the file, 0 after loading
Reading-notes.md: 7 URLs in the file, 3 after loading

Silence means every URL survived. Run it once when you set up the pipeline and again after any upgrade.

The same habit catches other losses: your bold reaches the AI as two asterisks — or not at all covers the loaders that drop emphasis. Emphasis is the subject there; links are the subject here. The chat runs on your machine — the embedding step may have uploaded every note makes the same point about a different LlamaIndex default you may not have chosen either.

Why a missing URL matters for citations

An AI that cites your notes is only as checkable as the links it was given. Two 2023 studies found that citations are often unreliable even when the sources are present. A loader that deletes the URL takes away the reader's way to check. Neither study tested loaders, so this shows why checking matters, not that link loss causes errors.

Nelson F. Liu, Tianyi Zhang and Percy Liang audited four generative search engines. They found that "on average, a mere 51.5% of generated sentences are fully supported by citations and only 74.5% of citations support their associated sentence." They called the results concerningly low for tools people use to look things up, "especially given their facade of trustworthiness." 10

Tianyu Gao and colleagues built a citation benchmark and reported that "on the ELI5 dataset, even the best models lack complete citation support 50% of the time." 11

Those numbers come from systems that had the sources. In a notes index built with the default reader, the model has a name and a year where the link was. It can still write "according to Smith 2024". Nobody can click through to check it — not you, and not the model.

This sits beside an earlier argument. A link is not context for your AI says to paste the load-bearing passage into the note and "keep the URL for humans." That advice assumes the URL reaches the index. With the default MarkdownReader it does not, so the two habits work as a pair — embed the passage for the model, and load the file in a way that keeps the URL for you.

The same loss happens when a person copies a note out of an editor. Convert a note to plain text and the links lose their URLs covers the converters that strip them. This post covers the retrieval index, where the cost shows up as an answer you cannot verify.

Trade-offs: what this receipt does not show

The receipt is one note, built so that each regex path runs once, at pinned versions. It does not measure LangChain or any other loader, and it does not show that link loss makes answers worse. Another project with the same design chose to keep links, and the image handling has its own known bug.

The edges, plainly:

Dify's knowledge-base MarkdownExtractor uses the same design — the same two flags and the same <.*?> strip. A July 2024 pull request flipped both of its defaults from True to False, so its source keeps inline links unless told otherwise 12. That is a source reading only. Dify was not run for this post.

The image regex is a separate, known problem. remove_images is documented as "Remove images in markdown content but keep the description", but its pattern, ![(.?)](.?), uses square brackets as character classes and never matches ![alt](url) 1. A January 2025 fix for a reported image bug kept a pattern that still does not match 13. The link regex runs first anyway and leaves !alt text.

A community reviewer, VANDRANKI, reproduced this independently: "The hyperlink pattern \[(.*?)\]\((.*?)\) also matches the [alt](url) part of an image, so after step one the content is already !alt text and there is no image syntax left for remove_images to find." 14 An open pull request from October 2026 would fix the image regex and its order. It leaves the remove_hyperlinks default and pattern unchanged 14.

Frequently asked questions

It keeps the link text and drops the URL. remove_hyperlinks defaults to True, and the reader rewrites [text](url) to text across the whole file before chunking. Bare URLs, reference definitions and footnote definitions survive. Autolinks and HTML link targets are deleted even with the flag off. In a seven-URL test note, three survived the defaults.

Check the loader first. If your pipeline uses LlamaIndex's MarkdownReader or ObsidianReader, the URLs were removed before indexing, so the model only ever saw the link text. Count URLs in a file and in the loaded documents. If the numbers differ, load the files with SimpleDirectoryReader and split them with MarkdownNodeParser.

Yes. A postprocessing line deletes everything between < and > in each section, with no flag to turn it off, so <https://…> disappears entirely and [t](<path>) loses its path. Enrico Stauss reported it in issue #13802 in May 2024; a stale-issue bot closed it as not planned. Load the notes as raw text instead.

What is the rationale behind this please?

No rationale is documented. A July 2024 comment on issue #13802 asked exactly this, and no maintainer answered before the issue closed. The original pull request from January 2023 explains a different goal: chunking Markdown by headers instead of by size. The link default shipped with that reader and has not changed since.

Images from markdown file are not removed

That is a known bug. The image pattern, ![(.?)](.?), never matches standard image syntax, and a January 2025 fix kept a pattern that still does not match. In practice the link regex runs first and leaves !alt text. An open pull request from October 2026 would correct both the pattern and the order.

The cause is the order of operations. The hyperlink pattern also matches the [alt](url) inside ![alt](url), so with links removed and images kept, an image becomes !alt. In LlamaIndex's MarkdownReader, setting remove_hyperlinks=False keeps images intact. Dify's extractor, derived from the same code, has an open issue with this title.


The patch in fix (c) depends on a module-level name, and the open image pull request may land before you read this. Run the URL count against whatever versions you ship, this post's receipt included.

A citation points somewhere only if the loader let the link through.


If you keep notes as plain Markdown files on your own device, mnmnote.com is a local-first editor built around that — and a note you can open is a note you can count URLs in.

References


Footnotes

  1. run-llama/llama_index. llama-index-readers-file/llama_index/readers/file/markdown/base.py, lines 28–29 and 94–131, at commit baeabbfe26 (2026-11-11; identical to llama-index-readers-file 0.7.0). https://github.com/run-llama/llama_index/blob/baeabbfe26241a6916e13e2a8c8156a02e0602cd/llama-index-integrations/readers/llama-index-readers-file/llama_index/readers/file/markdown/base.py (accessed 2026-11-13). ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9

  2. run-llama/llama_index. llama-index-readers-obsidian/llama_index/readers/obsidian/base.py, lines 5–14, 59–64 and 97, at commit baeabbfe26 (identical to llama-index-readers-obsidian 0.8.0). https://github.com/run-llama/llama_index/blob/baeabbfe26241a6916e13e2a8c8156a02e0602cd/llama-index-integrations/readers/llama-index-readers-obsidian/llama_index/readers/obsidian/base.py (accessed 2026-11-13). ↩ ↩2 ↩3 ↩4

  3. run-llama/llama_index. llama-index-core/llama_index/core/node_parser/file/markdown.py, MarkdownNodeParser docstring, at commit baeabbfe26. https://github.com/run-llama/llama_index/blob/baeabbfe26241a6916e13e2a8c8156a02e0602cd/llama-index-core/llama_index/core/node_parser/file/markdown.py (accessed 2026-11-13). ↩ ↩2

  4. Own reproduction, 13 November 2026 — Python 3.14.4 on Linux; llama-index-core 0.14.25, llama-index-readers-file 0.7.0, llama-index-readers-obsidian 0.8.0, installed from PyPI. A nine-form test note (Reading-notes.md) loaded through four paths, plus the fix (c) patch, the URL-count check, and two short probe notes (angle-bracket destination and autolink; < and > in prose and in a Java code block). ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11 ↩12 ↩13

  5. pypistats.org. Recent downloads for llama-index-readers-file (last month: 1,722,178) and llama-index-readers-obsidian (last month: 384), read 2026-11-13. https://pypistats.org/packages/llama-index-readers-file · https://pypistats.org/packages/llama-index-readers-obsidian (accessed 2026-11-13). ↩ ↩2

  6. Desai, H. (hursh-desai). "added ObsidianReader data connector." run-llama/llama_index pull request #331, merged 2023-01-31; original parser gpt_index/readers/file/markdown_parser.py, line 24. https://github.com/run-llama/llama_index/pull/331 (accessed 2026-11-13). ↩ ↩2

  7. run-llama/llama_index. llama-index-core/llama_index/core/readers/file/base.py, default reader map (lines 92–112) and standard read (lines 635–640), at commit baeabbfe26 (identical to llama-index-core 0.14.25). https://github.com/run-llama/llama_index/blob/baeabbfe26241a6916e13e2a8c8156a02e0602cd/llama-index-core/llama_index/core/readers/file/base.py (accessed 2026-11-13). ↩

  8. run-llama/llama_index. llama-index-readers-file/README.md, lines 131–136, at commit baeabbfe26. https://github.com/run-llama/llama_index/blob/baeabbfe26241a6916e13e2a8c8156a02e0602cd/llama-index-integrations/readers/llama-index-readers-file/README.md (accessed 2026-11-13). ↩ ↩2

  9. Stauss, E. (enrico-stauss). "[Bug]: MarkdownReader removes hyperlink URLs enclosed in angular brackets." run-llama/llama_index issue #13802, 2024-05-29; closed as not planned 2024-10-28 by dosubot after a stale label. https://github.com/run-llama/llama_index/issues/13802 (accessed 2026-11-13). ↩ ↩2 ↩3

  10. Liu, N. F., Zhang, T., & Liang, P. "Evaluating Verifiability in Generative Search Engines." Findings of the Association for Computational Linguistics: EMNLP 2023. https://aclanthology.org/2023.findings-emnlp.467/ (accessed 2026-11-13). ↩ ↩2

  11. Gao, T., Yen, H., Yu, J., & Chen, D. "Enabling Large Language Models to Generate Text with Citations." Proceedings of EMNLP 2023. https://aclanthology.org/2023.emnlp-main.398/ (accessed 2026-11-13). ↩ ↩2

  12. tangyoha. "fix: markdown proc will remove image." langgenius/dify pull request #5855, merged 2024-07-12; current api/core/rag/extractor/markdown_extractor.py at commit 763a0e8b38. https://github.com/langgenius/dify/pull/5855 (accessed 2026-11-13). ↩

  13. TomskDiver. "[Bug]: Images from markdown file are not removed." run-llama/llama_index issue #17397, 2024-12-31; fix pull request #17429 merged 2025-01-10. https://github.com/run-llama/llama_index/issues/17397 (accessed 2026-11-13). ↩

  14. longzhenren. "fix: correct image regex in MarkdownReader.remove_images." run-llama/llama_index pull request #23363, opened 2026-10-05 (open as of 2026-11-13); community review by VANDRANKI, 2026-10-06. https://github.com/run-llama/llama_index/pull/23363 (accessed 2026-11-13). ↩ ↩2