convert function
Convert input
to markdown text.
The input
can be an html string or a dom.Node.
The root tag which should be converted can be set with rootTag
.
The image base url can be set with imageBaseUrl
.
Style options can be set with styleOptions
.
The default and available style options:
Name | Default | Options |
---|---|---|
headingStyle | "setext" | "setext", "atx" |
hr | "* * *" | "* * *", "- - -", "_ _ _" |
bulletListMarker | "*" | "*", "-", "_" |
codeBlockStyle | "indented" | "indented", "fenced" |
fence | "```" | "```", "~~~" |
emDelimiter | "_" | "_", "*" |
strongDelimiter | "**" | "**", "__" |
linkStyle | "inlined" | "inlined", "referenced" |
linkReferenceStyle | "full" | "full", "collapsed", "shortcut" |
Elements list in ignore
would be ingored.
The rules
parameter can be used to customize element processing.
Implementation
String convert(
Object input, {
String? rootTag,
String? imageBaseUrl,
bool removeLeadingWhitespaces = true,
bool escape = true,
Map<String, String>? styleOptions,
List<String>? ignore,
List<Rule>? rules,
}) {
if (imageBaseUrl != null && imageBaseUrl.isNotEmpty) {
_customOptions['imageBaseUrl'] = imageBaseUrl;
}
updateStyleOptions(styleOptions);
if (ignore != null && ignore.isNotEmpty) {
Rule.addIgnore(ignore);
}
if (rules != null && rules.isNotEmpty) {
Rule.addRules(rules);
}
final output = _process(Node.root(input, rootTag: rootTag, removeLeadingWhitespaces: removeLeadingWhitespaces), escape);
return _postProcess(output);
}