Conversation
Post and Comment only carried the rendered HTML body. Store the Markdown source Reddit already returns (selftext for posts, body for comments) in a new body_md field, so a Markdown view can print it instead of embedding HTML. Removed content gets a plain "[removed]" placeholder. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
wants_markdown() checks Content-Type/Accept for text/markdown, markdown() builds the response like template() does for HTML, and page() picks one of the two for a request. error() and info() use a small message.md template when Markdown is requested. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Post listing entries, media, poll, badges and user comments are used by several pages, so they live in md/utils.md. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Comments are nested Markdown lists, one level of indentation per reply. Askama does not allow recursive macros, so Comment::markdown() renders a comment's replies through comment.md. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Wikis keep Reddit's Markdown source (content_md) next to the HTML. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Community descriptions are collapsed to one line so they stay in a list item. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
dreamldx
marked this pull request as ready for review
September 25, 2026 02:37
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.
What
Redlib pages can now be returned as Markdown. When a request has
Content-Type: text/markdown(orAccept: text/markdown), the page is rendered from a Markdown template instead of the HTML one. Without that header nothing changes; a browser'sAccept: text/html,...never triggers it.This makes it easy to feed Reddit threads to an LLM or a script without HTML noise.
Covered pages
Front page, subreddits (incl.
a+b,all,popular), posts with nested comments, user pages, search (global and per subreddit), duplicates, wiki/sidebar, and the error/info pages. Comments are nested Markdown lists, one indent level per reply.Not covered:
/settings, the media proxies and RSS keep their formats.How
PostandCommentkeep Reddit's Markdown source in a newbody_mdfield (selftext/body), so the templates print Markdown rather than embedding the rendered HTML.wants_markdown(),markdown()andpage()inutils.rs:markdown()builds the response liketemplate()does for HTML,page()picks one for a request.XxxMarkdown<'a> { t: &'a XxxTemplate }wrapper, so a handler builds its data once and only the last step differs (page(&req, &html, &md)). Fetching, settings and filtering are shared with the HTML page, including the NSFW display setting.templates/md/. Askama forbids recursive macros, soComment::markdown()renders replies throughcomment.md.Commits are split so each one builds on its own (I ran
cargo checkon every commit).Notes / open questions
/r/...,/img/...), like the HTML pages.Allocator\_api) and absolute reddit.com links that are not rewritten.should_be_nsfw_gated) and subscription filters apply as they do for HTML because the handlers are shared. The NSFW landing and quarantine/gated wall pages themselves are still HTML.br/gzipcompression).Opening as a draft to get feedback on the approach first (header-based negotiation rather than a URL suffix, and the wrapper-struct pattern).
🤖 Generated with Claude Code