Attributes
import 'package:notus/notus.dart';
void makeItPretty(NotusDocument document) {
/// All attributes can be accessed through [NotusAttribute] class.
// Format 5 characters starting at index 0 as bold.
document.format(0, 5, NotusAttribute.bold);
// Similarly for italic.
document.format(0, 5, NotusAttribute.italic);
// Format the first line as a heading (level 1).
// Note that there is no need to specify character range of the whole
// line. Simply set index position to anywhere within the line and
// length to 0.
document.format(0, 0, NotusAttribute.heading.level1);
// Add a link:
document.format(10, 15, NotusAttribute.link.fromString('https://github.com'));
// Format a line as code block. Similarly to heading styles there is no need
// to specify the whole character range of the line. In following example:
// whichever line is at character index 23 in the document will get
// formatted as code block.
document.format(23, 0, NotusAttribute.block.code);
// Remove heading style from the first line. All attributes
// have `unset` property which can be used the same way.
document.format(0, 0, NotusAttribute.heading.unset);
}How attributes are stored in Deltas
Last updated
Was this helpful?