File tree Expand file tree Collapse file tree 3 files changed +8
-7
lines changed
Tests/MarkdownTests/Parsing Expand file tree Collapse file tree 3 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -675,10 +675,11 @@ private enum ParseContainer: CustomStringConvertible {
675
675
// We need to keep track of what we removed because cmark will report different source locations than what we
676
676
// had in the source. We'll adjust those when we get them back.
677
677
let trimmedIndentationAndLines = lines. map { line -> ( line: TrimmedLine ,
678
- indentation: TrimmedLine . Lex ? ) in
678
+ indentation: Int ) in
679
679
var trimmedLine = line
680
680
let trimmedWhitespace = trimmedLine. lexWhitespace ( maxLength: indentationColumnCount)
681
- return ( trimmedLine, trimmedWhitespace)
681
+ let indentation = ( trimmedWhitespace? . text. count ?? 0 ) + line. untrimmedText. distance ( from: line. untrimmedText. startIndex, to: line. parseIndex)
682
+ return ( trimmedLine, indentation)
682
683
}
683
684
684
685
// Build the logical block of text that cmark will see.
Original file line number Diff line number Diff line change @@ -19,18 +19,18 @@ struct RangeAdjuster: MarkupWalker {
19
19
20
20
/// An array of whitespace spans that were removed for each line, indexed
21
21
/// by line number. `nil` means that no whitespace was removed on that line.
22
- var trimmedIndentationPerLine : [ TrimmedLine . Lex ? ]
22
+ var trimmedIndentationPerLine : [ Int ]
23
23
24
24
mutating func defaultVisit( _ markup: Markup ) {
25
25
/// This should only be used in the parser where ranges are guaranteed
26
26
/// to be filled in from cmark.
27
27
let adjustedRange = markup. range. map { range -> SourceRange in
28
28
// Add back the offset to the column as if the indentation weren't stripped.
29
29
let start = SourceLocation ( line: startLine + range. lowerBound. line - 1 ,
30
- column: range. lowerBound. column + ( trimmedIndentationPerLine [ range. lowerBound. line - 1 ] ? . text . count ?? 0 ) ,
30
+ column: range. lowerBound. column + ( trimmedIndentationPerLine [ range. lowerBound. line - 1 ] ) ,
31
31
source: range. lowerBound. source)
32
32
let end = SourceLocation ( line: startLine + range. upperBound. line - 1 ,
33
- column: range. upperBound. column + ( trimmedIndentationPerLine [ range. upperBound. line - 1 ] ? . text . count ?? 0 ) ,
33
+ column: range. upperBound. column + ( trimmedIndentationPerLine [ range. upperBound. line - 1 ] ) ,
34
34
source: range. upperBound. source)
35
35
return start..< end
36
36
}
Original file line number Diff line number Diff line change @@ -170,8 +170,8 @@ class DoxygenCommandParserTests: XCTestCase {
170
170
let expectedDump = """
171
171
Document @1:1-2:39
172
172
└─ DoxygenParam @1:1-2:39 parameter: thing
173
- └─ Paragraph @1:1 -2:39
174
- ├─ Text @1:1 -1:11 " The thing. "
173
+ └─ Paragraph @1:14 -2:39
174
+ ├─ Text @1:14 -1:24 " The thing. "
175
175
├─ SoftBreak
176
176
└─ Text @2:1-2:39 " This is the thing that is messed with. "
177
177
"""
You can’t perform that action at this time.
0 commit comments