Extension to allow code fence styles#127
Closed
nwhitehead wants to merge 11 commits intojoshka:mainfrom
Closed
Conversation
…nition lists Implement rendering for all previously unsupported markdown elements: - **Tables**: Full GFM table support with Unicode box-drawing borders, column alignment (left/center/right), header styling, and inline formatting within cells. New `tables` module with `TableBuilder`. - **Images**: Alt-text fallback rendering with image indicator prefix. New `images` module with `terminal-images` feature flag for future inline image protocol support. - **Math**: Inline (`$...$`) and display (`$$...$$`) math rendering with magenta styling. - **GFM Alerts**: Note, Tip, Important, Warning, and Caution callout blockquotes with colored icons and labels. - **Footnotes**: Reference and definition rendering. - **Definition Lists**: Term/description pairs with indentation. - **HTML**: Inline and block HTML rendered as dim text instead of being silently dropped. - **Links**: Link text now styled with the link style (blue underline), not just the URL portion. Extends `StyleSheet` trait with `image_alt`, `table_header`, `table_border`, `alert`, `html`, `math_inline`, `math_display`, `footnote_ref`, `footnote_def`, `definition_title`, and `definition_desc` methods. Adds `--test` flag to markdown-reader for loading the comprehensive test fixture, plus comprehensive integration tests and snapshots. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…blocks
Introduce `MarkdownContent` and `MarkdownBlock` types that allow
consumers to handle images separately from text instead of flattening
everything to alt-text. The new `parse()` and `parse_with_options()`
functions return `MarkdownContent` with a `blocks: Vec<MarkdownBlock>`
where each block is either `Text(Text)` or `Image { url, alt, title }`.
This enables terminal image protocol rendering (iTerm2/Kitty/Sixel)
by consumers while preserving the existing `from_str()` API unchanged.
Also adds `image` and `ratatui-image` as optional deps behind the
`terminal-images` feature flag, and a `link()` method to `StyleSheet`.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace byte-length width calculation with `unicode_width::UnicodeWidthStr` so that emoji and CJK characters are measured by their display column width instead of their UTF-8 byte length. This fixes misaligned table columns when cells contain emoji like ✅ or 🟧. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add `code_theme` field to `Options` with a builder method so consumers
can select any built-in syntect theme instead of the hardcoded
"base16-ocean.dark".
let options = Options::default().code_theme("Solarized (dark)");
let text = from_str_with_options(markdown, &options);
Add `available_themes()` function (behind `highlight-code` feature) to
list valid theme names at runtime. Invalid theme names fall back to
the default with a warning rather than panicking.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add two new builder methods to Options (behind highlight-code feature):
- `code_theme_file(path)` — loads a .tmTheme file from disk
- `code_theme_custom(theme)` — accepts a syntect Theme directly
Custom themes take precedence over the built-in theme name. Re-export
`SyntectTheme` and `LoadingError` so consumers don't need a direct
syntect dependency.
Usage:
let opts = Options::default().code_theme_file("Dracula.tmTheme")?;
let text = from_str_with_options(markdown, &opts);
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #127 +/- ##
==========================================
+ Coverage 57.79% 58.91% +1.11%
==========================================
Files 7 7
Lines 661 679 +18
==========================================
+ Hits 382 400 +18
Misses 279 279 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Author
|
I reworked my repo to build on pull request #125, I'll wait until that one is done and reopen something afterwards (keeping this one around would be too many merge conflicts). |
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.
This is a change to allow styles for the fence markup in the output. This lets you turn off display of the fence markup, or style it in a very dim color or similar.
The UI changes the stylesheet interface, makes the fence style an
Option. If it isNonethen the fence markup is not included, if it isSomethen that style is used to display the marks.