Module markdown

Source
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ยง

CodeBlocks ๐Ÿ”’
Adds syntax highlighting and playground Run buttons to Rust code blocks.
ExtraInfo ๐Ÿ”’
HeadingLinks ๐Ÿ”’
Make headings links with anchor IDs and build up TOC.
IdMap
Indices ๐Ÿ”’
LangString ๐Ÿ”’
LinkReplacer ๐Ÿ”’
LinkReplacerInner ๐Ÿ”’
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.
MarkdownItemInfo ๐Ÿ”’
A tuple struct like Markdown that renders the markdown escaping HTML tags and includes no paragraph tags.
MarkdownLink ๐Ÿ”’
MarkdownSummaryLine ๐Ÿ”’
A tuple struct like Markdown that renders only the first paragraph.
MarkdownWithToc ๐Ÿ”’
A struct like Markdown that renders the markdown with a table of contents.
MdRelLine ๐Ÿ”’
A newtype that represents a relative line number in Markdown.
Playground
RustCodeBlock ๐Ÿ”’
SpannedLinkReplacer ๐Ÿ”’
SummaryLine ๐Ÿ”’
Extracts just the first paragraph.
TableWrapper ๐Ÿ”’
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ยง

ErrorCodes
HeadingOffset
Ignore ๐Ÿ”’
LangStringToken ๐Ÿ”’
Line ๐Ÿ”’
Controls whether a line will be hidden or shown in HTML output.
MarkdownLinkRange ๐Ÿ”’

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ยง

SpannedEvent ๐Ÿ”’