renderStyle function

String renderStyle(
  1. String markdown, {
  2. required GlamourTheme theme,
  3. int width = 80,
})

Renders markdown text using the specified theme.

If width is provided, text will be wrapped to that width. Defaults to 80 columns.

Implementation

String renderStyle(
  String markdown, {
  required GlamourTheme theme,
  int width = 80,
}) {
  final document = md.Document(
    extensionSet: md.ExtensionSet.gitHubFlavored,
    encodeHtml: false,
  );

  // Parse markdown
  final nodes = _normalizeBlockquotes(
    document.parseLines(markdown.split('\n')),
  );

  // Render
  final renderer = GlamourRenderer(theme: theme, width: width);
  return renderer.render(nodes);
}