Skip to content

Commit

Permalink
With nested list items that contain no double newlines, only RunSpanG…
Browse files Browse the repository at this point in the history
…amut over the outer one (http://meta.stackoverflow.com/q/176537)
  • Loading branch information
balpha committed Apr 15, 2013
1 parent c245b9e commit 7e2f563
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Markdown.Converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ else
return text;
}

function _DoLists(text) {
function _DoLists(text, isInsideParagraphlessListItem) {
//
// Form HTML ordered (numbered) and unordered (bulleted) lists.
//
Expand Down Expand Up @@ -830,7 +830,7 @@ else
var list = m1;
var list_type = (m2.search(/[*+-]/g) > -1) ? "ul" : "ol";

var result = _ProcessListItems(list, list_type);
var result = _ProcessListItems(list, list_type, isInsideParagraphlessListItem);

// Trim any trailing whitespace, to put the closing `</$list_type>`
// up on the preceding line, to get it past the current stupid
Expand Down Expand Up @@ -861,7 +861,7 @@ else

var _listItemMarkers = { ol: "\\d+[.]", ul: "[*+-]" };

function _ProcessListItems(list_str, list_type) {
function _ProcessListItems(list_str, list_type, isInsideParagraphlessListItem) {
//
// Process the contents of a single ordered or unordered list, splitting it
// into individual list items.
Expand Down Expand Up @@ -937,9 +937,10 @@ else
}
else {
// Recursion for sub-lists:
item = _DoLists(_Outdent(item));
item = _DoLists(_Outdent(item), /* isInsideParagraphlessListItem= */ true);
item = item.replace(/\n$/, ""); // chomp(item)
item = _RunSpanGamut(item);
if (!isInsideParagraphlessListItem)
item = _RunSpanGamut(item);
}
last_item_had_a_double_newline = ends_with_double_newline;
return "<li>" + item + "</li>\n";
Expand Down

0 comments on commit 7e2f563

Please sign in to comment.