Skip to content

Auto-link bare URLs in markdown descriptions - #27

Merged
normanajn merged 1 commit into
mainfrom
auto-url
Aug 3, 2026
Merged

normanajn merged 1 commit into
mainfrom
auto-url

Conversation

@normanajn

Copy link
Copy Markdown
Collaborator

Summary

  • Closes Hyperlinks not automatically created #25 — plain https://... URLs typed into an entry/report description now render as clickable links, without requiring [text](url) markdown syntax
  • Implemented as a small custom Python-Markdown inline pattern (apps/core/markdown.py), registered at a priority that runs after the built-in link/autolink/raw-HTML patterns, so it never double-links URLs already inside [text](url), <url>, raw <a> HTML, or code spans
  • Handles trailing sentence punctuation and balanced parentheses (e.g. (see https://example.com) doesn't swallow the closing paren; .../wiki/Foo_(bar) keeps it)
  • Updated the markdown cheat sheet panel to document the new behavior

Test plan

  • Added 3 new tests in tests/test_entries.py::TestMarkdownPreview (basic autolink, trailing punctuation, no duplicate linking of existing markdown links)
  • Full suite: 214 passed (211 existing + 3 new)
  • Manually verified fenced code, inline code, angle-bracket autolinks, and existing raw <a> HTML are left untouched

🤖 Generated with Claude Code

Typing a plain https://... URL now renders as a clickable link without
requiring [text](url) syntax (fixes #25). Implemented as a small custom
Python-Markdown inline pattern registered after the existing link/
autolink/html patterns, so it doesn't double-link URLs already inside
markdown links, angle-bracket autolinks, raw HTML, or code spans.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 3, 2026 21:17
@normanajn
normanajn merged commit 8153b54 into main Aug 3, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a custom Python-Markdown inline extension so plain https://... URLs in entry/report descriptions render as clickable links without requiring explicit [text](url) syntax, and documents the behavior in the UI cheat sheet.

Changes:

  • Implemented a _BareUrlInlineProcessor + _AutolinkExtension in apps/core/markdown.py and enabled it in render_markdown.
  • Added markdown preview tests covering basic bare-URL autolinking and avoiding duplicate links for existing Markdown links.
  • Updated the markdown cheat sheet to mention/display bare-URL auto-linking.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
apps/core/markdown.py Adds and registers a custom inline processor to auto-link bare http(s) URLs during Markdown rendering.
tests/test_entries.py Adds tests for the markdown preview endpoint to verify basic auto-linking behavior.
apps/entries/templates/entries/partials/_markdown_cheatsheet.html Updates the user-facing cheat sheet to document bare-URL auto-linking.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/core/markdown.py
Comment on lines +85 to +88
while url and (
url[-1] in _BARE_URL_TRAILING_PUNCTUATION
or (url[-1] == ')' and url.count('(') < url.count(')'))
):
Comment thread tests/test_entries.py
Comment on lines +441 to +449
def test_autolink_does_not_swallow_trailing_punctuation(self, client, user):
client.force_login(user)
resp = client.post(reverse('entries:markdown-preview'), {
'description': 'Visit https://example.com, then https://example.com/other.',
})
assert resp.status_code == 200
assert b'<a href="https://example.com">https://example.com</a>,' in resp.content
assert b'<a href="https://example.com/other">https://example.com/other</a>.' in resp.content

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hyperlinks not automatically created

2 participants