Skip to main content

libara_formats 0.2.3 copy "libara_formats: ^0.2.3" to clipboard
libara_formats: ^0.2.3 copied to clipboard

Markup syntaxes for libara: XML, HTML, Markdown, LMNL, man, ms, me, LaTeX, JSON and Dart, each read into layers that write back character for character.

libara_formats #

Markup syntaxes for libara: XML, HTML, LMNL, Markdown, man, ms, me and LaTeX, and JSON and Dart source, each a libara Format from a text to a layered document.

A document keeps its text exactly as it was read. Its markup is a layer of tokens over the text, and its elements a layer of ranges over the tokens, both read again over only the stretch an edit touches. Writing a document in the syntax it was read in gives back its text byte for byte; writing it in another converts it.

Use #

import 'package:libara/libara.dart';
import 'package:libara_formats/libara_formats.dart';

final read = formats['md']!.decode(Text.of('# Notes\n\nA quick fox.\n'));
if (read case Success(value: final document)) {
  // Type a word, and the layers above the text are read again.
  final edited = document.apply(Edit(1, Insert(11, Text.of('brown '))));
  if (edited case Success(:final value)) {
    // Write it as XML.
    final xml = formats['xml']!.encode(value.document);
  }
}

formats maps each syntax's name and file extension, in lower case, to its format: xml, html and htm, lmnl, markdown and md, man and the section numbers 1 to 9, ms, me, latex and tex, json, and dart.

example/main.dart reads, edits and converts a document, and doc/layers.md sets out how each syntax maps onto the layers.

License #

BSD 3-Clause; see LICENSE.

0
likes
160
points
876
downloads

Documentation

API reference

Publisher

verified publisherlibdbm.com

Weekly Downloads

Markup syntaxes for libara: XML, HTML, Markdown, LMNL, man, ms, me, LaTeX, JSON and Dart, each read into layers that write back character for character.

Repository (GitHub)
View/report issues

Topics

#markup #xml #html #markdown #parsing

License

BSD-3-Clause (license)

Dependencies

libara

More

Packages that depend on libara_formats