Console Markdown Formatting

All print output in this workspace can be formatted using console_markdown syntax. This applies to DartScript scripts, CLI tools, and any Dart code that outputs to the console.

Package

  • Package: console_markdown
  • Import: import 'package:console_markdown/console_markdown.dart';

Usage

Apply markdown formatting to console output:

// Using the apply method
print(ConsoleMarkdown.apply('Hello **World**!'));

// Using the extension method (preferred)
print('Hello, **world**!'.toConsole());

// Multi-line example
print('''
  Hello **World**!
  __Looks *pretty* easy__
  
  <console color="red" background="black" bold> Console Markdown </console>
'''.toConsole());

Markdown Cheatsheet

Symbols

SymbolPropertyExampleDescription
**bold**text**Bold text
*italic*text*Italic text
__underline__text__Underlined text
~~ strikethrough ~~text~~ Strikethrough text
^superscript^text^Superscript
~subscript~text~Subscript
___ double-underline ___text___ Double underline
!!blink!!text!!Blinking text
!!!rapid-blink!!!text!!!Rapid blinking
`\ \ ` hidden `\ \ text\ \ ` Hidden text
^^inverse^^text^^Inverse colors
` `` dim ` text ` Dimmed text

Tags (HTML-like syntax)

TagPropertyExample
<reset>reset<reset>text
<overline> overline <overline>text</overline>
<br>line break<br>
<b>bold<b>text</b>
<i>italic<i>text</i>
<u>underline<u>text</u>
<uu> double-underline <uu>text</uu>
<s>strikethrough<s>text</s>
<sup> superscript <sup>text</sup>
<sub>subscript<sub>text</sub>

Colors

Available color tags: black, red, green, yellow, blue, magenta, cyan, white, gray

Use background flag to set background color.

Dynamic Tags

TagExampleDescription
<console> <console color="red" background="#000000" bold>text</console> All properties can be combined
<rgb(r,g,b)> <rgb(255, 0, 0)>text</rgb> RGB color, add background for bg
<hex(...)> <hex(#ff0000)>text</hex> Hex color
<#...> <#ff0000>text</#> Short hex syntax

Performance Alternatives

ClassDescription
ConsoleMarkdownSymbolsSymbols only (fastest)
ConsoleMarkdownBasicConsole tag only
ConsoleMarkdownFull markdown syntax

References