html2md 0.2.1

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

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.2.1 #

  • Fix dependency error

0.2.0 #

  • Fix the multiple child issue of indentedCodeBlock rule
  • Support Dart 2

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.2.1

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.3.1 Mar 18, 2019 Go to the documentation of html2md 0.3.1 Download html2md 0.3.1 archive
0.3.0 Jan 18, 2019 Go to the documentation of html2md 0.3.0 Download html2md 0.3.0 archive
0.2.1 Aug 14, 2018 Go to the documentation of html2md 0.2.1 Download html2md 0.2.1 archive
0.2.0 Aug 14, 2018 Go to the documentation of html2md 0.2.0 Download html2md 0.2.0 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

All 13 versions...

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

We analyzed this package on Apr 4, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14

Platforms

Detected platforms: Flutter, web, other

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

Health suggestions

Fix lib/src/utils.dart. (-1 points)

Analysis of lib/src/utils.dart reported 2 hints:

line 93 col 10: Use contains instead of indexOf

line 97 col 10: Use contains instead of indexOf

Fix lib/src/node.dart. (-0.50 points)

Analysis of lib/src/node.dart reported 1 hint:

line 87 col 12: Use contains instead of indexOf

Fix lib/src/rules.dart. (-0.50 points)

Analysis of lib/src/rules.dart reported 1 hint:

line 273 col 14: Use contains instead of indexOf

Format lib/src/converter.dart.

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

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <3.0.0
html ^0.13.3 0.13.4+1
path ^1.4.1 1.6.2
Transitive dependencies
args 1.5.1
charcode 1.1.2
csslib 0.14.6
logging 0.11.3+2
source_span 1.5.5
term_glyph 1.1.0
utf 0.9.0+5
Dev dependencies
test ^1.3.0