pygments 0.1.3

  • Installing
  • Versions
  • 49


Highlight source code snippets in your HTML files using pygments.


In pubspec.yaml:

  pygments: any

  - pygments:
      # Here we define all the HTML elements pygments will run on
        # First comes the DOM selector. This will match all *pre* elements that contain a class
        # starting with *language*. For instance, this will match <pre class="language-python">.
        # Note that these are just 100% standard DOM selectors!!
        # Also note that an outer code tag will be stripped. e.g. given
        # <pre class="langauge-python"><code>def main: return 0</code></pre>, the transformer will
        # automatically lift out the *def main: return 0* and only highlight that, ignoring the
        # outer code tag.
        - "pre[class|='language']":
            # Now we need to define the source language. You can do this using a regex as shown
            # below. This will match the language-* class and extract just the language name
            # (e.g. language-dart -> dart).
            re: "language-(.*)"
            # By default, pygments will automatically unescape any HTML escape codes. For example,
            # <pre>a &gt; b</pre> will be converted to *a > b*. Set unescape to false to disable
            # this.
            unescape: false
        # Here's another example. This will run only on elements like <pre class="dart"></pre>.
        - "pre[class=dart]":
            # If your language is constant, you don't need to use a regex. Just use the lang
            # property instead:
            lang: dart
        # Last example! This is for CSS:
        - "pre[class=css]":
            # In the cases where you aren't passing any other options, the default option will
            # be *lang*. So something like:
            # - "pre[class=dart]":
            #     lang: dart
            # can be shortened to:
            # - "pre[class=dart]": dart


(No changes.)

version 0.1.3

Fix UTF8 issues.

version 0.1.2

Fix a crash when a language class can't be found.

version 0.1.1

Initial version (I screwed up version 0.1).

Use this package as a library

1. Depend on it

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

  pygments: "^0.1.3"

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:pygments/pygments.dart';
Version Uploaded Documentation Archive
0.1.3 Jan 2, 2018 Go to the documentation of pygments 0.1.3 Download pygments 0.1.3 archive
0.1.2 Oct 9, 2017 Go to the documentation of pygments 0.1.2 Download pygments 0.1.2 archive
0.1.1 Aug 28, 2017 Go to the documentation of pygments 0.1.1 Download pygments 0.1.1 archive
0.1.0 Aug 28, 2017 Go to the documentation of pygments 0.1.0 Download pygments 0.1.0 archive


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

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


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


Detected platforms: Flutter, other

Primary library: package:pygments/pygments.dart with components: io, build.


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

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use pygments.dart.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 3 hints.

    Run dartfmt to format lib/pygments.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0
barback ^0.15.2+2 0.15.2+16
html ^0.13.2 0.13.3+1
html_unescape ^0.1.5 0.1.5 1.0.0
source_maps ^0.10.4 0.10.5
source_span ^1.4.0 1.4.0
Transitive dependencies
args 1.4.3
async 2.0.7
charcode 1.1.1
collection 1.14.10
csslib 0.14.4
logging 0.11.3+1
path 1.6.0
pool 1.3.5
stack_trace 1.9.2
utf 0.9.0+4