Expand description
Markdown formatting for rustdoc.
This module implements markdown formatting through the pulldown-cmark library.
#![feature(rustc_private)]
extern crate rustc_span;
use rustc_span::edition::Edition;
use rustdoc::html::markdown::{HeadingOffset, IdMap, Markdown, ErrorCodes};
let s = "My *markdown* _text_";
let mut id_map = IdMap::new();
let md = Markdown {
content: s,
links: &[],
ids: &mut id_map,
error_codes: ErrorCodes::Yes,
edition: Edition::Edition2015,
playground: &None,
heading_offset: HeadingOffset::H2,
};
let html = md.into_string();
// ... something using html
Modulesยง
- footnotes ๐
- Markdown footnote handling.
Structsยง
- Code
Blocks ๐ - Adds syntax highlighting and playground Run buttons to Rust code blocks.
- Extra
Info ๐ - Heading
Links ๐ - Make headings links with anchor IDs and build up TOC.
- IdMap
- Indices ๐
- Lang
String ๐ - Link
Replacer ๐ - Link
Replacer ๐Inner - Make headings links with anchor IDs and build up TOC.
- Markdown
- When
to_string
is called, this struct will emit the HTML corresponding to the rendered version of the contained markdown string. - Markdown
Item ๐Info - A tuple struct like
Markdown
that renders the markdown escaping HTML tags and includes no paragraph tags. - Markdown
Link ๐ - Markdown
Summary ๐Line - A tuple struct like
Markdown
that renders only the first paragraph. - Markdown
With ๐Toc - A struct like
Markdown
that renders the markdown with a table of contents. - MdRel
Line ๐ - A newtype that represents a relative line number in Markdown.
- Playground
- Rust
Code ๐Block - Spanned
Link ๐Replacer - Summary
Line ๐ - Extracts just the first paragraph.
- Table
Wrapper ๐ - Wrap HTML tables into
<div>
to prevent having the doc blocks width being too big. - TagIterator ๐
- This is the parser for fenced codeblocks attributes. It implements the following eBNF:
Enumsยง
- Error
Codes - Heading
Offset - Ignore ๐
- Lang
String ๐Token - Line ๐
- Controls whether a line will be hidden or shown in HTML output.
- Markdown
Link ๐Range
Constantsยง
- MAX_
HEADER_ ๐LEVEL
Functionsยง
- check_
if_ ๐allowed_ tag - find_
codes ๐ - find_
testable_ ๐code - html_
text_ ๐from_ events - is_
bareword_ ๐char - is_
default_ ๐id - is_
forbidden_ ๐tag - is_
leading_ ๐char - is_
separator ๐ - map_
line ๐ - markdown_
links ๐ - markdown_
summary_ ๐with_ limit - Renders a subset of Markdown in the first paragraph of the provided Markdown.
- plain_
text_ ๐from_ events - plain_
text_ ๐summary - Renders the first paragraph of the provided markdown as plain text. Useful for alt-text.
- rust_
code_ ๐blocks - Returns a range of bytes for each code block in the markdown that is tagged as
rust
or untagged (and assumed to be rust). - short_
markdown_ ๐summary - Renders a shortened first paragraph of the given Markdown as a subset of Markdown, making it suitable for contexts like the search index.
- slugify ๐
- Convert chars from a title for an id.
- summary_
opts ๐ - Options for rendering Markdown in summaries (e.g., in search results).
- main_
body_ ๐opts - Options for rendering Markdown in the main body of documentation.
Type Aliasesยง
- Spanned
Event ๐