-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from gjtorikian/expose-more-info
Add `sourcepos` information
- Loading branch information
Showing
4 changed files
with
141 additions
and
1 deletion.
There are no files selected for viewing
Submodule cmark
updated
from 1f4632 to cc9c76
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
## Try CommonMark | ||
|
||
You can try CommonMark here. This dingus is powered by | ||
[commonmark.js](https://github.com/jgm/commonmark.js), the | ||
JavaScript reference implementation. | ||
|
||
1. item one | ||
2. item two | ||
- sublist | ||
- sublist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
require 'test_helper' | ||
|
||
class TestAttributes < Minitest::Test | ||
def setup | ||
contents = File.read(File.join(FIXTURES_DIR, 'dingus.md')) | ||
@doc = CommonMarker.render_doc(contents.strip) | ||
end | ||
|
||
def test_sourcepos | ||
sourcepos = [] | ||
|
||
@doc.walk do |node| | ||
sourcepos << node.sourcepos | ||
end | ||
|
||
sourcepos.delete_if { |h| h.values.all? { |v| v == 0 } } | ||
|
||
result = [ | ||
{ | ||
:start_line => 1, | ||
:start_column => 1, | ||
:end_line => 10, | ||
:end_column => 12 | ||
}, | ||
{ | ||
:start_line => 1, | ||
:start_column => 4, | ||
:end_line => 1, | ||
:end_column => 17 | ||
}, | ||
{ | ||
:start_line => 3, | ||
:start_column => 1, | ||
:end_line => 5, | ||
:end_column => 36 | ||
}, | ||
{ | ||
:start_line => 7, | ||
:start_column => 1, | ||
:end_line => 10, | ||
:end_column => 12 | ||
}, | ||
{ | ||
:start_line => 7, | ||
:start_column => 1, | ||
:end_line => 7, | ||
:end_column => 11 | ||
}, | ||
{ | ||
:start_line => 7, | ||
:start_column => 4, | ||
:end_line => 7, | ||
:end_column => 11 | ||
}, | ||
{ | ||
:start_line => 8, | ||
:start_column => 1, | ||
:end_line => 10, | ||
:end_column => 12 | ||
}, | ||
{ | ||
:start_line => 8, | ||
:start_column => 4, | ||
:end_line => 8, | ||
:end_column => 11 | ||
}, | ||
{ | ||
:start_line => 9, | ||
:start_column => 4, | ||
:end_line => 10, | ||
:end_column => 12 | ||
}, | ||
{ | ||
:start_line => 9, | ||
:start_column => 4, | ||
:end_line => 9, | ||
:end_column => 12 | ||
}, | ||
{ | ||
:start_line => 9, | ||
:start_column => 6, | ||
:end_line => 9, | ||
:end_column => 12 | ||
}, | ||
{ | ||
:start_line => 10, | ||
:start_column => 4, | ||
:end_line => 10, | ||
:end_column => 12 | ||
}, | ||
{ | ||
:start_line => 10, | ||
:start_column => 6, | ||
:end_line => 10, | ||
:end_column => 12 | ||
} | ||
] | ||
|
||
assert_equal result, sourcepos | ||
end | ||
end |