[PR #2374] [MERGED] fix: Added markdown parser logic to detect code block fences #2377

Closed
opened 2026-02-17 17:23:21 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/docs/pull/2374
Author: @Devpatel1901
Created: 1/26/2026
Status: Merged
Merged: 3/13/2026
Merged by: @mdrxy

Base: mainHead: devpatel1901/fix-autolink-preprocessor-for-code-blocks


📝 Commits (3)

  • 4407f21 fix: Added markdown parser logic to detect code block fences
  • f86dfd3 Merge branch 'main' into devpatel1901/fix-autolink-preprocessor-for-code-blocks
  • 549c49b cr

📊 Changes

2 files changed (+181 additions, -0 deletions)

View changed files

📝 pipeline/preprocessors/handle_auto_links.py (+12 -0)
tests/unit_tests/test_handle_auto_links.py (+169 -0)

📄 Description

Overview

The Autolink preprocessor was transforming @[...] patterns found inside triple-backtick code blocks, causing false positive warnings when code contained regex patterns like email validators or character classes (e.g., @[a-zA-Z0-9.-]).

Changes:

  • Added code block detection to replace_autolinks() using markdown-it-py token parsing
  • Lines within triple-backtick fences are now skipped from autolink transformation
  • Fence markers and code block content are preserved unchanged in output
  • Conditional scope markers (:::language) outside code blocks continue to work correctly

Type of change

Type: Bug

Related issues/PRs

https://github.com/langchain-ai/docs/issues/2069

To automatically close an issue when this PR is merged, use closing keywords:

Checklist

  • I have read the contributing guidelines
  • I have tested my changes locally using docs dev
  • All code examples have been tested and work correctly
  • I have used root relative paths for internal links
  • I have updated navigation in src/docs.json if needed

Additional notes

For these changes, I added markdown-it-py package as a dependency. In addition to that, I haven't added any unit test cases to test my changes because I am not able to find any unit test cases related to this Autolink preprocessors. Let me know if you would like to add those then I am happy to do that.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/docs/pull/2374 **Author:** [@Devpatel1901](https://github.com/Devpatel1901) **Created:** 1/26/2026 **Status:** ✅ Merged **Merged:** 3/13/2026 **Merged by:** [@mdrxy](https://github.com/mdrxy) **Base:** `main` ← **Head:** `devpatel1901/fix-autolink-preprocessor-for-code-blocks` --- ### 📝 Commits (3) - [`4407f21`](https://github.com/langchain-ai/docs/commit/4407f21d841381de77ef138d4d848455c38a097e) fix: Added markdown parser logic to detect code block fences - [`f86dfd3`](https://github.com/langchain-ai/docs/commit/f86dfd35320fd94ea11f7e297fabc4547fac270e) Merge branch 'main' into devpatel1901/fix-autolink-preprocessor-for-code-blocks - [`549c49b`](https://github.com/langchain-ai/docs/commit/549c49bd134b435bad082d68ba78a988f21bf8da) cr ### 📊 Changes **2 files changed** (+181 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `pipeline/preprocessors/handle_auto_links.py` (+12 -0) ➕ `tests/unit_tests/test_handle_auto_links.py` (+169 -0) </details> ### 📄 Description ## Overview The Autolink preprocessor was transforming @[...] patterns found inside triple-backtick code blocks, causing false positive warnings when code contained regex patterns like email validators or character classes (e.g., @[a-zA-Z0-9.-]). Changes: * Added code block detection to `replace_autolinks()` using `markdown-it-py` token parsing * Lines within triple-backtick fences are now skipped from autolink transformation * Fence markers and code block content are preserved unchanged in output * Conditional scope markers (:::language) outside code blocks continue to work correctly ## Type of change **Type:** Bug ## Related issues/PRs https://github.com/langchain-ai/docs/issues/2069 To automatically close an issue when this PR is merged, use closing keywords: - "closes #2069" ## Checklist <!-- Put an 'x' in all boxes that apply --> - [x] I have read the [contributing guidelines](README.md) - [x] I have tested my changes locally using `docs dev` - [x] All code examples have been tested and work correctly - [x] I have used **root relative** paths for internal links - [x] I have updated navigation in `src/docs.json` if needed ## Additional notes For these changes, I added `markdown-it-py` package as a dependency. In addition to that, I haven't added any unit test cases to test my changes because I am not able to find any unit test cases related to this Autolink preprocessors. Let me know if you would like to add those then I am happy to do that. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-17 17:23:21 -05:00
yindo changed title from [PR #2374] fix: Added markdown parser logic to detect code block fences to [PR #2374] [MERGED] fix: Added markdown parser logic to detect code block fences 2026-06-05 18:18:15 -04:00
yindo closed this issue 2026-06-05 18:18:15 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/docs#2377