Dart syntax highlighting support for Pygments

171 views
Skip to first unread message

Olov Lassus

unread,
Oct 27, 2011, 2:03:18 PM10/27/11
to mi...@dartlang.org
I have implemented Dart support for Pygments. It should be fairly
correct but any review would be much appreciated. Source code is
available at <https://gist.github.com/1320163>. Check out
<http://blog.lassus.se/2011/10/dart-syntax-highlighting.html> for a
highlighting example and installation instructions.

I plan to submit this upstreams once we're reasonably confident that
it's correct. I'll also submit it to the GitHub team to enable syntax
highlighting on Dart projects. The bloggers of you who use Jekyll (or
anything else utilizing Pygments for highlighting) should also find
this useful to get your samples in beautiful Technicolor.

/Olov

Bob Nystrom

unread,
Oct 27, 2011, 2:38:05 PM10/27/11
to Olov Lassus, mi...@dartlang.org
On Thu, Oct 27, 2011 at 11:03 AM, Olov Lassus <olov....@gmail.com> wrote:
I have implemented Dart support for Pygments. It should be fairly
correct but any review would be much appreciated. Source code is
available at <https://gist.github.com/1320163>. Check out
<http://blog.lassus.se/2011/10/dart-syntax-highlighting.html> for a
highlighting example and installation instructions.

This is fantastic. I hacked together an unbelievably crude one for my blog, and it will be nice to switch to this instead.

If I can throw out some feature requests (hey, it's finally my turn to do that!), it would be swell if it:

1. Supported multi-line strings: '''foo''' and """foo""".
2. Highlighted interpolation expressions inside string literals '$like ${this + "one"}';


I plan to submit this upstreams once we're reasonably confident that
it's correct. I'll also submit it to the GitHub team to enable syntax
highlighting on Dart projects. The bloggers of you who use Jekyll (or
anything else utilizing Pygments for highlighting) should also find
this useful to get your samples in beautiful Technicolor.

Score!

- bob

Olov Lassus

unread,
Oct 27, 2011, 2:53:10 PM10/27/11
to Bob Nystrom, mi...@dartlang.org
On Thu, Oct 27, 2011 at 8:38 PM, Bob Nystrom <rnys...@google.com> wrote:
> If I can throw out some feature requests (hey, it's finally my turn to do
> that!), it would be swell if it:
> 1. Supported multi-line strings: '''foo''' and """foo""".

That should work already (let me know if you find a case for which it doesn't).

> 2. Highlighted interpolation expressions inside string literals '$like
> ${this + "one"}';

I'd like that too. Did I mention that I accept patches? ;)

/Olov

Olov Lassus

unread,
Nov 26, 2011, 9:05:28 AM11/26/11
to Bob Nystrom, mi...@dartlang.org
On Thu, Oct 27, 2011 at 8:38 PM, Bob Nystrom <rnys...@google.com> wrote:
> If I can throw out some feature requests (hey, it's finally my turn to do
> that!), it would be swell if it:
> 1. Supported multi-line strings: '''foo''' and """foo""".
> 2. Highlighted interpolation expressions inside string literals '$like
> ${this + "one"}';

Done. String interpolation highlighting isn't bullet proof but works
well in practice. I created a color scheme too. Check out
<http://blog.lassus.se/2011/11/dart-syntax-highlighting-update.html>
for a demonstration and installation/usage instructions.

Please let me know of any issues.

I'll check if the github guys want to add it.

/Olov

Olov Lassus

unread,
Feb 5, 2012, 6:25:55 AM2/5/12
to Bob Nystrom, mi...@dartlang.org
It's upstream now:
https://bitbucket.org/birkenfeld/pygments-main/changeset/972091dacea4

I've pinged the Github guys.

/Olov

Bob Nystrom

unread,
Feb 6, 2012, 1:52:56 PM2/6/12
to Olov Lassus, mi...@dartlang.org
\o/

- bob

Olov Lassus

unread,
Apr 19, 2012, 12:34:38 PM4/19/12
to mi...@dartlang.org
Alright, it's live and kicking at Github now!

Thanks to Ilya Grigorik for submitting the configuration change. The
highlighter lives in the upstream Pygments repository now and is
included in releases since 1.5 (released Mar 10, 2012). I will try to
keep it correct and updated. Patches and bug reports are welcome,
either to me or the Pygments project.

I've found a few bugs already after clicking around on peoples repos,
such as StringBuffer being incorrectly highlighted and that multi-line
comments are falsely detected. Will fix unless someone beats me to it.

/Olov

Seth Ladd

unread,
Apr 19, 2012, 12:36:27 PM4/19/12
to Olov Lassus, mi...@dartlang.org
Great news!

Bob Nystrom

unread,
Apr 19, 2012, 12:52:36 PM4/19/12
to Seth Ladd, Olov Lassus, mi...@dartlang.org
So awesome. I feel all giggly inside!

- bob

Olov Lassus

unread,
Apr 19, 2012, 3:58:23 PM4/19/12
to mi...@dartlang.org
On Thu, Apr 19, 2012 at 6:34 PM, Olov Lassus <olov....@gmail.com> wrote:

> I've found a few bugs already after clicking around on peoples repos,
> such as StringBuffer being incorrectly highlighted and that multi-line
> comments are falsely detected. Will fix unless someone beats me to it.

Alright, those are fixed now in
https://bitbucket.org/olov/pygments-main/changesets

I would /love/ to get some help testing that before submitting
upstreams again. It's very easy, just hg clone
https://bitbucket.org/olov/pygments-main; cd pygments-main;
./pygmentize <filename.dart>.

/Olov

Reply all
Reply to author
Forward
0 new messages