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 mut html = String::new();
md.write_into(&mut html).unwrap();
// ... something using htmlRe-exportsΒ§
use std::borrow::Cow;πuse std::collections::VecDeque;πuse std::fmt;πuse std::fmt::Write;πuse std::iter::Peekable;πuse std::ops::ControlFlow;πuse std::ops::Range;πuse std::path::PathBuf;πuse std::str;πuse std::str::CharIndices;πuse std::sync::atomic::AtomicUsize;πuse std::sync::Arc;πuse std::sync::Weak;πuse rustc_data_structures::fx::FxHashMap;πuse rustc_data_structures::fx::FxIndexMap;πuse rustc_errors::Diag;πuse rustc_errors::DiagMessage;πuse rustc_hir::def_id::LocalDefId;πuse rustc_middle::ty::TyCtxt;πuse rustc_resolve::rustdoc::pulldown_cmark;πuse rustc_resolve::rustdoc::pulldown_cmark::BrokenLink;πuse rustc_resolve::rustdoc::pulldown_cmark::CodeBlockKind;πuse rustc_resolve::rustdoc::pulldown_cmark::CowStr;πuse rustc_resolve::rustdoc::pulldown_cmark::Event;πuse rustc_resolve::rustdoc::pulldown_cmark::LinkType;πuse rustc_resolve::rustdoc::pulldown_cmark::Options;πuse rustc_resolve::rustdoc::pulldown_cmark::Parser;πuse rustc_resolve::rustdoc::pulldown_cmark::Tag;πuse rustc_resolve::rustdoc::pulldown_cmark::TagEnd;πuse rustc_resolve::rustdoc::pulldown_cmark::html;πuse rustc_resolve::rustdoc::DocFragment;πuse rustc_resolve::rustdoc::may_be_doc_link;πuse rustc_resolve::rustdoc::source_span_for_markdown_range;πuse rustc_span::edition::Edition;πuse rustc_span::Span;πuse rustc_span::Symbol;πuse tracing::debug;πuse tracing::trace;πuse crate::clean::RenderedLink;πuse crate::doctest;πuse crate::doctest::GlobalTestOptions;πuse crate::html::escape::Escape;πuse crate::html::escape::EscapeBodyText;πuse crate::html::highlight;πuse crate::html::length_limit::HtmlWithLimit;πuse crate::html::render::small_url_encode;πuse crate::html::toc::Toc;πuse crate::html::toc::TocBuilder;π
ModulesΒ§
- footnotes π
- Markdown footnote handling.
StructsΒ§
- Code
Blocks π - Adds syntax highlighting and playground Run buttons to Rust code blocks.
- Code
Line πMapping - 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_stringis called, this struct will emit the HTML corresponding to the rendered version of the contained markdown string. - Markdown
Item πInfo - A struct like
Markdownthat renders the markdown escaping HTML tags and includes no paragraph tags. - Markdown
Link π - Markdown
Summary πLine - A tuple struct like
Markdownthat renders only the first paragraph. - Markdown
With πToc - A struct like
Markdownthat 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.
EnumsΒ§
- Code
Block πPosition - A type representing a position of a code block in Markdown.
- 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_
code_ πblock - map_
line π - This function is used to handle the βhidden linesβ (ie starting with
#) in doctests. It also transforms##back into#. - markdown_
links π - markdown_
range_ πfor_ code_ range - 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
rustor 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 π