html2md 0.1.7

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 85

html2md

Build status

Convert html to markdown in Dart. A simplify version of node's turndown.

Usage

A simple usage example:

import 'package:html2md/html2md.dart' as html2md;

main() {
  var html = '<h1>HTML2MD Demo</h1>';
  print(html2md.convert(html));
}

Config

You can config convert style by passing styleOptions to convert:

html2md.convert(html, styleOptions: { 'headingStyle': 'atx' });

The default and available style options:

NameDefaultOptions
headingStyle"setext""setext", "atx"
hr"* * *""* * *", "- - -", "_ _ _"
bulletListMarker"*""*", "-", "_"
codeBlockStyle"indented""indented", "fenced"
fence"```""```", "~~~"
emDelimiter"_""_", "*"
strongDelimiter"**""**", "__"
linkStyle"inlined""inlined", "referenced"
linkReferenceStyle"full""full", "collapsed", "shortcut"

Test

pub run test

Features and bugs

Please file feature requests and bugs at the issue tracker.

License

Created from templates made available by Stagehand under a BSD-style license.

Changelog

0.1.7

  • Ignore invalid style options

0.1.6

  • Remove noscript element and cleanup
  • Fix pre node
  • Update test

0.1.5

  • Add named optional parameter 'styleOptions' to convert

0.1.4

  • Remove the incorrect default value for 'rootTag'

0.1.3

  • Fix for crash in Dart 2

0.1.2

  • Fix 'rootTag' issue

0.1.1

  • Add named optional parameter 'rootTag' to convert
  • Add named optional parameter 'imageBaseUrl' to convert

0.1.0

  • Cleanup
  • Publish 0.1.0

0.0.1

  • Initial version

example/html2md_example.dart

import 'package:html2md/html2md.dart' as html2md;

main() {
  String html = '''<h1>HTML2MD Demo</h1>

<p>This demonstrates <a href="https://github.com/jarontai/html2md">html2md</a> – an HTML to Markdown converter in Dart.</p>

<h2>Usage</h2>

<pre><code class="language-dart">import 'package:html2md/html2md.dart' as html2md;
void main() {
  print(html2md.convert('&lt;h1&gt;Hello world&lt;/h1&gt;'));
}</code></pre>

<hr />

<p>It aims to be <a href="http://commonmark.org/">CommonMark</a> compliant, and includes options to style the output. These options include:</p>

<ul>
  <li>headingStyle (setext or atx)</li>
  <li>horizontalRule (*, -, or _)</li>
  <li>bullet (*, -, or +)</li>
  <li>codeBlockStyle (indented or fenced)</li>
  <li>fence (` or ~)</li>
  <li>emDelimiter (_ or *)</li>
  <li>strongDelimiter (** or __)</li>
  <li>linkStyle (inlined or referenced)</li>
  <li>linkReferenceStyle (full, collapsed, or shortcut)</li>
</ul>''';
  print(html2md.convert(html));
}

Use this package as a library

1. Depend on it

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


dependencies:
  html2md: "^0.1.7"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


      import 'package:html2md/html2md.dart';
  
Version Uploaded Documentation Archive
0.1.7 Apr 20, 2018 Go to the documentation of html2md 0.1.7 Download html2md 0.1.7 archive
0.1.6 Apr 18, 2018 Go to the documentation of html2md 0.1.6 Download html2md 0.1.6 archive
0.1.5 Apr 16, 2018 Go to the documentation of html2md 0.1.5 Download html2md 0.1.5 archive
0.1.4 Apr 16, 2018 Go to the documentation of html2md 0.1.4 Download html2md 0.1.4 archive
0.1.3 Apr 14, 2018 Go to the documentation of html2md 0.1.3 Download html2md 0.1.3 archive
0.1.2 Apr 11, 2018 Go to the documentation of html2md 0.1.2 Download html2md 0.1.2 archive
0.1.1 Apr 11, 2018 Go to the documentation of html2md 0.1.1 Download html2md 0.1.1 archive
0.1.0 Apr 10, 2018 Go to the documentation of html2md 0.1.0 Download html2md 0.1.0 archive
0.0.1 Apr 8, 2018 Go to the documentation of html2md 0.0.1 Download html2md 0.0.1 archive

Analysis

We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
71 / 100
Health:
Code health derived from static analysis. [more]
99 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
85
Learn more about scoring.

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:html2md/html2md.dart.

Suggestions

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 4 hints.

    Run dartfmt to format lib/src/converter.dart.

    Run dartfmt to format lib/src/node.dart.

    Similar analysis of the following files failed:

    • lib/src/rules.dart (hint)
    • lib/src/utils.dart (hint)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <2.0.0
html ^0.13.3 0.13.3+1
path ^1.4.1 1.6.1
Transitive dependencies
args 1.4.3
charcode 1.1.1
csslib 0.14.4
logging 0.11.3+1
source_span 1.4.0
utf 0.9.0+4
Dev dependencies
test ^0.12.0