[PR #1444] [MERGED] Optimize and fix autolink function (#1442) #15907

Closed
opened 2025-11-02 11:57:30 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-gitea/gitea/pull/1444
Author: @mjwwit
Created: 4/4/2017
Status: Merged
Merged: 4/12/2017
Merged by: @lunny

Base: masterHead: master


📝 Commits (2)

  • 4c6ff02 Optimize and fix autolink function (#1442)
  • 0af8e78 Fix bug in autolink recursive fallback function

📊 Changes

1 file changed (+45 additions, -15 deletions)

View changed files

📝 public/js/libs/autolink.js (+45 -15)

📄 Description

This PR fixes the markdown rendering issues with code-blocks containing URLs (#1442). The culprit was the autolink function, which conflicted with highlight.js. I've excluded code-block URLs from being auto-linked to fix this issue.

Besides being broken the autolink function was also crazy inefficient. I've improved the efficiency by making use of the browser-native createTreeWalker function. If this function is not available (IE8 and below) I make use of a recursive function (which is still more efficient than the previous implementation).


🔄 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/go-gitea/gitea/pull/1444 **Author:** [@mjwwit](https://github.com/mjwwit) **Created:** 4/4/2017 **Status:** ✅ Merged **Merged:** 4/12/2017 **Merged by:** [@lunny](https://github.com/lunny) **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (2) - [`4c6ff02`](https://github.com/go-gitea/gitea/commit/4c6ff027e3383da63128f19ee3df9a90b646acf0) Optimize and fix autolink function (#1442) - [`0af8e78`](https://github.com/go-gitea/gitea/commit/0af8e78b9457ef018b7d0ebbe9726789a2b00590) Fix bug in autolink recursive fallback function ### 📊 Changes **1 file changed** (+45 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `public/js/libs/autolink.js` (+45 -15) </details> ### 📄 Description This PR fixes the markdown rendering issues with code-blocks containing URLs (#1442). The culprit was the `autolink` function, which conflicted with highlight.js. I've excluded code-block URLs from being auto-linked to fix this issue. Besides being broken the `autolink` function was also crazy inefficient. I've improved the efficiency by making use of the browser-native `createTreeWalker` function. If this function is not available (IE8 and below) I make use of a recursive function (which is still more efficient than the previous implementation). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-02 11:57:30 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#15907