-
-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parse sub-lists indented with tabs #347
Changes from 3 commits
ac7b893
5fd0e66
c920366
5c658f9
244b10f
3ae5e78
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -432,7 +432,8 @@ function normalListItem(ctx, value, position) { | |
|
||
lines = value.split(C_NEWLINE); | ||
|
||
trimmedLines = removeIndent(value, getIndent(max).indent).split(C_NEWLINE); | ||
var maxIndent = getIndent(max); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you move the |
||
trimmedLines = removeIndent(value, maxIndent.indent).split(C_NEWLINE); | ||
|
||
/* We replaced the initial bullet with something | ||
* else above, which was used to trick | ||
|
@@ -467,7 +468,7 @@ function normalListItem(ctx, value, position) { | |
$2 = C_SPACE + $2; | ||
} | ||
|
||
max = $1 + repeat(C_SPACE, $2.length) + $3; | ||
max = $1 + repeat(C_SPACE, Math.max($2.length, TAB_SIZE)) + $3; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is necessary because we want to trim ensuing lines if they contain at least a I've looked through the changed (failing) test cases that this edit introduces, and afaict, their output fixtures were less correct before this change. |
||
|
||
return max + rest; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,6 @@ module.exports = indentation; | |
|
||
var C_SPACE = ' '; | ||
var C_NEWLINE = '\n'; | ||
var C_TAB = '\t'; | ||
|
||
/* Remove the minimum indent from every line in `value`. | ||
* Supports both tab, spaced, and mixed indentation (as | ||
|
@@ -21,7 +20,6 @@ function indentation(value, maximum) { | |
var index; | ||
var indentation; | ||
var stops; | ||
var padding; | ||
|
||
values.unshift(repeat(C_SPACE, maximum) + '!'); | ||
|
||
|
@@ -56,17 +54,7 @@ function indentation(value, maximum) { | |
index--; | ||
} | ||
|
||
if ( | ||
trim(values[position]).length !== 0 && | ||
minIndent && | ||
index !== minIndent | ||
) { | ||
padding = C_TAB; | ||
} else { | ||
padding = ''; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This logic for adding padding in a function that is supposed to be removing padding is definitely incorrect. I've checked the failing test cases before and after this change, and this code block does more harm than good. There is only one test case whose output changes after making this change, and the previous fixture expected it to introduce a phantom |
||
|
||
values[position] = padding + values[position].slice( | ||
values[position] = values[position].slice( | ||
index in stops ? stops[index] + 1 : 0 | ||
); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed :)