Skip to content

Extension to allow code fence styles#127

Closed
nwhitehead wants to merge 11 commits intojoshka:mainfrom
nwhitehead:main
Closed

Extension to allow code fence styles#127
nwhitehead wants to merge 11 commits intojoshka:mainfrom
nwhitehead:main

Conversation

@nwhitehead
Copy link
Copy Markdown

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 is None then the fence markup is not included, if it is Some then that style is used to display the marks.

lightsofapollo and others added 5 commits February 7, 2026 18:57
…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-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.91%. Comparing base (d2438c9) to head (679a7d2).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nwhitehead
Copy link
Copy Markdown
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).

@nwhitehead nwhitehead closed this Mar 2, 2026
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.

3 participants