Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
mdfrier
mdfrier - Deep fry markdown for mdfried.
Goals
- Render markdown for terminals, as close to source as possible. Remove some style decorators such as asterisks for bold or italics, replace or enhance them with style markers.
- Wrap lines for the terminal width in their "block" context. It is necessary to track the "context" of "blocks" such as lists / list items, blockquotes, codeblocks, to render with the correct intention of the source markdown.
- Produce an intermediate representation that can be used by anything that renders to terminals.
- Spans: Text-spans with modifiers.
- Lines: Spans wrapped as lines.
- Sections: Typically separated by headings.
- Produce ratatui widgets with the
ratatuifeature. For convenience, directly map the intermediate output to ratatui widgets (ratatuiSpans).
Customization
The [Mapper] trait controls decorator symbols (e.g., blockquote bar, link brackets).
The optional ratatui feature provides the [ratatui::Theme] trait that combines [Mapper]
with ratatui::style::Style
conversion.
Examples
[StyledMapper] is the default goal of this crate. It heavily maps markdown symbols, and
strips many, with the intention of adding syles (color, bold, italics...) later, after wrapping.
That is, it does not "stylize" the markdown, but is intented for stylizing later.
The styles should be applied when iterating over the [Line]'s [Span]s.
use ;
let mut frier = new.unwrap;
// StyledMapper removes decorators (for use with colors/bold/italic styling)
let lines = frier.parse;
let text: String = lines.iter
.flat_map
.collect;
assert_eq!;
A custom mapper should implement the [Mapper] trait. For example, here we replace some
markdown delimiters with fancy symbols.
use ;
;
let mut frier = new.unwrap;
let lines = frier.parse;
let mut output = Stringnew;
for line in lines
assert_eq!;
A [DefaultMapper] exists, which could be used only style, preserving the markdown content.
Note that it would be much more efficient to use the
tree-sitter-md crate directly instead,
since it operates with byte-ranges of the original text. Think editor syntax highlighting.
use ;
let mut frier = new.unwrap;
let lines = frier.parse;
let text: String = lines.iter
.flat_map
.collect;
assert_eq!;
License: GPL-3.0-or-later