Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(324)

Issue 8680025: First pass at a markdown parser in Dart. (Closed)

Created:
9 years ago by Bob Nystrom
Modified:
9 years ago
CC:
reviews_dartlang.org
Visibility:
Public.

Description

First pass at a markdown parser in Dart. Committed: https://code.google.com/p/dart/source/detail?r=1830

Patch Set 1 #

Total comments: 18

Patch Set 2 : Review. Add missing file (oops!). #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1846 lines, -0 lines) Patch
A utils/markdown/README.txt View 1 chunk +4 lines, -0 lines 0 comments Download
A utils/markdown/ast.dart View 1 chunk +63 lines, -0 lines 0 comments Download
A utils/markdown/block_parser.dart View 1 1 chunk +433 lines, -0 lines 0 comments Download
A utils/markdown/html_renderer.dart View 1 chunk +54 lines, -0 lines 0 comments Download
A utils/markdown/inline_parser.dart View 1 chunk +349 lines, -0 lines 0 comments Download
A utils/markdown/lib.dart View 1 1 chunk +109 lines, -0 lines 0 comments Download
A utils/markdown/markdown.dart View 1 1 chunk +47 lines, -0 lines 0 comments Download
A utils/markdown/test/markdown_tests.dart View 1 chunk +787 lines, -0 lines 0 comments Download

Messages

Total messages: 3 (0 generated)
Bob Nystrom
It doesn't handle every possible edge case, but it has most of the basic markdown ...
9 years ago (2011-11-23 22:03:14 UTC) #1
Jennifer Messerly
lgtm http://codereview.chromium.org/8680025/diff/1/utils/markdown/ast.dart File utils/markdown/ast.dart (right): http://codereview.chromium.org/8680025/diff/1/utils/markdown/ast.dart#newcode12 utils/markdown/ast.dart:12: class Element implements Node { if only the ...
9 years ago (2011-11-23 22:25:40 UTC) #2
Bob Nystrom
9 years ago (2011-11-29 02:56:28 UTC) #3
Argh. Never actually sent out these comments...

http://codereview.chromium.org/8680025/diff/1/utils/markdown/ast.dart
File utils/markdown/ast.dart (right):

http://codereview.chromium.org/8680025/diff/1/utils/markdown/ast.dart#newcode12
utils/markdown/ast.dart:12: class Element implements Node {
On 2011/11/23 22:25:41, John Messerly wrote:
> if only the real DOM was this simple

:)

http://codereview.chromium.org/8680025/diff/1/utils/markdown/ast.dart#newcode32
utils/markdown/ast.dart:32: bool get isEmpty() => children == null;
On 2011/11/23 22:25:41, John Messerly wrote:
> great, now I'm going to be jealous every time I have to type "isEmpty()" for
> real collections :)

I should start filing bugs for that stuff...

http://codereview.chromium.org/8680025/diff/1/utils/markdown/block_parser.dart
File utils/markdown/block_parser.dart (right):

http://codereview.chromium.org/8680025/diff/1/utils/markdown/block_parser.dar...
utils/markdown/block_parser.dart:5: class _Re {
On 2011/11/23 22:25:41, John Messerly wrote:
> what is this Java doing in my Dart code? :)
> 
> Seriously though can these be top level? Actually... after reading further in
> the code, maybe these are just members of the classes that use them?
> 
> If it's only used once it seems better to just inline it in the pattern() =>
> getter.

Reorganized. I don't know what I was thinking. They aren't directly in the
classes because ListParser (sigh) uses almost all of them in addition to them
being used by their appropriate parsers.

http://codereview.chromium.org/8680025/diff/1/utils/markdown/block_parser.dar...
utils/markdown/block_parser.dart:93: new EmptyBlockSyntax(),
On 2011/11/23 22:25:41, John Messerly wrote:
> could these be const, and then use a "static final" list?

They could be, but I'm thinking users may be able to insert their own block
parsers in this collection in order to extend the markdown syntax for their own
needs. I figured it might be handy to have it mutable. (Also, it saves me the
chore of having to write const constructors for every syntax class.)

http://codereview.chromium.org/8680025/diff/1/utils/markdown/inline_parser.dart
File utils/markdown/inline_parser.dart (right):

http://codereview.chromium.org/8680025/diff/1/utils/markdown/inline_parser.da...
utils/markdown/inline_parser.dart:12: new AutolinkSyntax(),
On 2011/11/23 22:25:41, John Messerly wrote:
> const ctors?

See similar comment on block parser. Here I also ran into an issue where I think
some syntaxes were building their pattern in the constructor using "+" on
strings and the VM wasn't allowing it as a const expression.

http://codereview.chromium.org/8680025/diff/1/utils/markdown/inline_parser.da...
utils/markdown/inline_parser.dart:127: // searching from a given offset.
On 2011/11/23 22:25:41, John Messerly wrote:
> yeah... that seriously needs to be fixed in RegExp. mind filing an issue?

Yeah. There's a few things in RegExp that are annoying now that I've really put
it through its paces.

http://codereview.chromium.org/8680025/diff/1/utils/markdown/inline_parser.da...
utils/markdown/inline_parser.dart:211: // TODO(rnystrom): Doing this.field
doesn't seem to work with named args.
On 2011/11/23 22:25:41, John Messerly wrote:
> what's the issue here? can you file to the issue tracker?

I think this might be the same issue that Mattias was working on yesterday.
Filed a bug just in case: https://code.google.com/p/dart/issues/detail?id=588

http://codereview.chromium.org/8680025/diff/1/utils/markdown/inline_parser.da...
utils/markdown/inline_parser.dart:230: static get linkPattern() {
On 2011/11/23 22:25:41, John Messerly wrote:
> could this be a field? or does the string interp break const-ness?

It was breaking constness when I tried that.

http://codereview.chromium.org/8680025/diff/1/utils/markdown/markdown.dart
File utils/markdown/markdown.dart (right):

http://codereview.chromium.org/8680025/diff/1/utils/markdown/markdown.dart#ne...
utils/markdown/markdown.dart:15: print('  dart_bin markdown.dart <inputfile>
[<outputfile>]');
On 2011/11/23 22:25:41, John Messerly wrote:
> I think this is just "dart" now (dart_bin is going away/gone)

Oh yeah. Fixed!

Powered by Google App Engine
This is Rietveld 408576698