Conversation
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>
There was a problem hiding this comment.
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+_AutolinkExtensioninapps/core/markdown.pyand enabled it inrender_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 on lines
+85
to
+88
| while url and ( | ||
| url[-1] in _BARE_URL_TRAILING_PUNCTUATION | ||
| or (url[-1] == ')' and url.count('(') < url.count(')')) | ||
| ): |
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 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
https://...URLs typed into an entry/report description now render as clickable links, without requiring[text](url)markdown syntaxapps/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(see https://example.com)doesn't swallow the closing paren;.../wiki/Foo_(bar)keeps it)Test plan
tests/test_entries.py::TestMarkdownPreview(basic autolink, trailing punctuation, no duplicate linking of existing markdown links)<a>HTML are left untouched🤖 Generated with Claude Code