Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,16 @@ _.extend(Renderer.prototype, rawRenderer.prototype, {
return line
})
var type = ordered ? '#' : '*'
return _.map(arr, function(line) {
return type + ' ' + line
return '\n' + _.map(arr, function(line) {
var bullet = type
if (!/^[*#]+ /.test(line)) {
// When the line starts with '# ' or '* ', it means that it is
// a nested list. '* * ' should be squashed to '** ' in the
// case.
bullet += ' '
}
return bullet + line;
}).join('\n') + '\n\n'

}
, listitem: function(body, ordered) {
return body + '\n'
Expand Down
1 change: 1 addition & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var pairs = [
['# h1', 'h1. h1\n\n']
, ['head1\n===', 'h1. head1\n\n']
, ['### h3', 'h3. h3\n\n']
, ['- item\n - nested', '\n* item\n** nested\n\n']
]

pairs.forEach(function(arr, i) {
Expand Down