notustohtml 0.0.7

  • Readme
  • Changelog
  • Example
  • Installing
  • 84

Notus to HTML #

Convert between the Notus document format and HTML.

Overview #

This project is a generic Dart package used to convert between HTML and the Notus document format. Notus documents are used by the popular Zefyr rich text editor.

The Notus format for Zefyr utilises Deltas to represent the document. These Deltas are not compatible with other editors. The Deltas used in this converter can only be used with Notus and Zefyr.

Usage #

Encode HTML #

final converter = NotusHtmlCodec();

String html = converter.encode(myNotusDocument.toDelta()); // HTML Output

Decode HTML #

final converter = NotusHtmlCodec();

Delta delta = converter.decode(myHtmlString); // Zefyr compatible Delta
NotusDocument document = NotusDocument.fromDelta(delta); // Notus document ready to be loaded into Zefyr

Contributing #

This package was created for a personal project. Pull requests are accepted on GitHub if you are interested in building upon this.

Changelog #

All notable changes to this project will be documented in this file.

[0.0.7] - 2020-06-12 #

  • Ensure deltas end with \n

[0.0.6] - 2020-05-31 #

  • Fix bugs with HTML decoding.

[0.0.4] - 2020-05-31 #

  • Allow decoding of HTML to a Zefyr compatible Delta.

[0.0.3] - 2020-05-26 #

  • Improve accuracy of output
  • Use the document for conversion rather than converting to JSON

[0.0.2] - 2020-05-22 #

  • Add examples and documentation

[0.0.1] - 2020-05-22 #

  • Basic HTML output from Notus documents.
  • Works with Notus 0.1.5.

example/main.dart

import 'package:notus/notus.dart';
import 'package:notustohtml/notustohtml.dart';
import 'package:quill_delta/quill_delta.dart';

void main() {
  final converter = NotusHtmlCodec();

  // Replace with the document you have take from the Zefyr editor
  final doc = NotusDocument.fromJson(
    [
      {
        "insert": "Hello World!",
      },
      {
        "insert": "\n",
        "attributes": {
          "heading": 1,
        },
      },
    ],
  );

  String html = converter.encode(doc.toDelta());
  print(html); // The HTML representation of the Notus document

  Delta delta = converter.decode(html); // Zefyr compatible Delta
  NotusDocument document = NotusDocument.fromDelta(delta); // Notus document ready to be loaded into Zefyr
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  notustohtml: ^0.0.7

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:notustohtml/notustohtml.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
73
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
84
Learn more about scoring.

We analyzed this package on Jul 14, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15

Health suggestions

Fix lib/notustohtml.dart. (-0.50 points)

Analysis of lib/notustohtml.dart reported 1 hint:

line 378 col 13: DO use curly braces for all flow control structures.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
html ^0.14.0 0.14.0+3
notus ^0.1.5 0.1.5
quill_delta ^1.0.2 1.0.2
Transitive dependencies
charcode 1.1.3
collection 1.14.13 1.15.0-nullsafety
csslib 0.16.1
meta 1.2.2 1.3.0-nullsafety
path 1.7.0
quiver_hashcode 2.0.0
source_span 1.7.0
term_glyph 1.1.0
Dev dependencies
test any