use comrak builder
This commit is contained in:
parent
051c4d5d5b
commit
50307d0c3e
1 changed files with 35 additions and 48 deletions
|
@ -21,54 +21,41 @@ pub struct File {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Options used for parser and compiler MD --> HTML
|
/// Options used for parser and compiler MD --> HTML
|
||||||
pub fn get_options<'a>() -> ComrakOptions<'a> {
|
pub fn get_options() -> ComrakOptions {
|
||||||
let mut options = comrak::Options::default();
|
comrak::Options {
|
||||||
|
extension: comrak::ExtensionOptions::builder()
|
||||||
// Extension
|
.strikethrough(true)
|
||||||
options.extension.strikethrough = true;
|
.tagfilter(true)
|
||||||
options.extension.tagfilter = true;
|
.table(true)
|
||||||
options.extension.table = true;
|
.autolink(true)
|
||||||
options.extension.autolink = true;
|
.tasklist(true)
|
||||||
options.extension.tasklist = true;
|
.superscript(true)
|
||||||
options.extension.superscript = true;
|
.header_ids(String::new())
|
||||||
options.extension.header_ids = Some(String::new());
|
.footnotes(true)
|
||||||
options.extension.footnotes = true;
|
.description_lists(true)
|
||||||
options.extension.description_lists = true;
|
.front_matter_delimiter("---".into())
|
||||||
options.extension.front_matter_delimiter = Some("---".into());
|
.multiline_block_quotes(true)
|
||||||
options.extension.multiline_block_quotes = true;
|
.math_dollars(true)
|
||||||
options.extension.math_dollars = true;
|
.underline(true)
|
||||||
options.extension.math_code = false;
|
//.spoiler(true) // todo: css
|
||||||
options.extension.wikilinks_title_after_pipe = false;
|
//.image_url_rewriter(Arc::new(|url: &str| url.into())) // todo: image rewriter b64
|
||||||
options.extension.wikilinks_title_before_pipe = false;
|
//.link_url_rewriter(Arc::new(|url: &str| url.into())) // todo: local link
|
||||||
options.extension.underline = true;
|
.build(),
|
||||||
options.extension.spoiler = false;
|
parse: comrak::ParseOptions::builder()
|
||||||
options.extension.greentext = false;
|
.smart(true)
|
||||||
|
.default_info_string("plaintext".into())
|
||||||
// Parser
|
.relaxed_tasklist_matching(true)
|
||||||
options.parse.smart = true; // could be boring
|
.relaxed_autolinks(true)
|
||||||
options.parse.default_info_string = Some("plaintext".into());
|
.build(),
|
||||||
options.parse.relaxed_tasklist_matching = true;
|
render: comrak::RenderOptions::builder()
|
||||||
options.parse.relaxed_autolinks = true;
|
.full_info_string(true)
|
||||||
// options.render.broken_link_callback = ...;
|
.unsafe_(true)
|
||||||
|
.list_style(ListStyleType::Dash)
|
||||||
// Renderer
|
.ignore_setext(true)
|
||||||
options.render.hardbreaks = false;
|
.ignore_empty_links(true)
|
||||||
options.render.github_pre_lang = false;
|
.gfm_quirks(true)
|
||||||
options.render.full_info_string = true;
|
.build(),
|
||||||
options.render.width = 0; // 0 mean disabled?
|
}
|
||||||
options.render.unsafe_ = true;
|
|
||||||
options.render.escape = false;
|
|
||||||
options.render.list_style = ListStyleType::Dash;
|
|
||||||
options.render.sourcepos = false;
|
|
||||||
options.render.experimental_inline_sourcepos = false;
|
|
||||||
options.render.escaped_char_spans = false;
|
|
||||||
options.render.ignore_setext = true;
|
|
||||||
options.render.ignore_empty_links = true;
|
|
||||||
options.render.gfm_quirks = true;
|
|
||||||
options.render.prefer_fenced = false;
|
|
||||||
options.render.figure_with_caption = false;
|
|
||||||
|
|
||||||
options
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resize images if needed
|
/// Resize images if needed
|
||||||
|
|
Loading…
Reference in a new issue