Expand description
Markdown rendering for gpuikit
This module provides markdown parsing and rendering using GPUI elements. It supports CommonMark and GitHub Flavored Markdown.
§Example
use gpuikit::markdown::{MarkdownStyle, markdown};
// Simple usage - create markdown element inline
div().child(markdown("# Hello\n\nThis is **bold** text.", cx))
// With custom style
div().child(
markdown("# Hello", cx)
.style(MarkdownStyle::new().code_font("Monaco"))
)Structs§
- Inline
Palette - Theme-resolved colors for the inline styles that need them. Resolved by
the element (which has the theme) and passed into
RichText::to_highlights_with;Noneleaves that aspect unstyled. - Inline
Style - Inline text style flags that can be combined.
- Markdown
- A markdown document that can be rendered as a GPUI element.
- Markdown
Element - Element for rendering markdown content.
- Markdown
Event - Parsed markdown event with source range information.
- Markdown
Selection - Shared handle to a document’s selection state. Cheap to clone; every run element of one document holds the same handle.
- Markdown
Style - Complete style configuration for markdown rendering.
- Options
- Option struct containing flags for enabling extra features that are not part of the CommonMark spec.
- Parser
- Markdown event iterator.
- Rich
Text - Rich text container that holds styled text spans, plus the URL table that link spans index into.
- Selectable
Text - A selectable (and optionally link-bearing) text run.
- Selection
Position - A position in the document: which run, and a byte offset into its text.
- Text
Span - A span of text with associated styling.
- Text
Style - Style configuration for a text element.
Enums§
- Code
Block Kind - Codeblock kind.
- Code
Highlight Theme - Which syntect theme code blocks highlight with.
- Heading
Level - Heading level (h1-h6).
- Link
Type - Type specifier for inline links. See the Tag::Link for more information.
- RunRole
- What kind of block a run is, and therefore how a screen reader announces it. Every run has one: a run that has not decided how it is announced cannot be built.
Constants§
- BASE_
SIZE - Base font size in rems.
- DEFAULT_
DARK_ THEME - The syntect theme used on a dark surface when following the app.
- DEFAULT_
LIGHT_ THEME - The syntect theme used on a light surface when following the app.
- TYPESCALE_
RATIO - The typescale ratio (minor third).
Functions§
- block_
quote - Render a block quote element with plain text.
- code_
block_ language - Extract the language from a fenced code block kind.
- code_
highlight_ themes - The syntect theme names
CodeHighlightTheme::Pinnedaccepts, or an empty vector beforeinit_code_highlighting. - default_
options - Default parsing options with GFM support enabled.
- divider
- Render a horizontal rule (divider) element.
- has_
open_ code_ fence - Whether
sourceends with a fenced code block that never closed. - heading
- Render a heading element with plain text.
- image
- Render an image element.
- init_
code_ highlighting - Turn on syntax highlighting for markdown code blocks.
- inline_
code - Render inline code.
- link
- Render a link element.
- list_
item - Render a list item element with plain text.
- markdown
- Create a markdown element from source text.
- normalize_
language - Reduce a code fence’s info string to a language token, or
Noneif it names no language. - ordered_
marker - Get the marker for an ordered list item.
- paragraph
- Render a paragraph element with plain text.
- parse
- Parse markdown source with default options.
- parse_
with_ options - Parse markdown source with custom options.
- preprocessing_
available - Whether this build can close open syntax — true with the
stitchfeature, false without it, whereclose_open_syntaxis the identity. - set_
code_ highlight_ theme - Pin code blocks to a specific syntect theme, or put them back on
CodeHighlightTheme::FollowApp. - unordered_
marker - Get the marker for an unordered list item.