Skip to content

Commit

Permalink
indent markdown multiline code by 4 spaces for the console
Browse files Browse the repository at this point in the history
  • Loading branch information
mildm8nnered committed Aug 1, 2024
1 parent cc59e2b commit 2db6532
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions Source/SwiftLintCore/Models/RuleDescription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,22 @@ public struct RuleDescription: Equatable, Sendable {
guard let rationale else {
return nil
}
return rationale.components(separatedBy: "\n").compactMap { line in
line.contains("```") ? nil : line
var insideMultilineString = false
return rationale.components(separatedBy: "\n").map { line in
if line.contains("```") {
if insideMultilineString {
insideMultilineString = false
} else {
insideMultilineString = true
if line.hasSuffix("```") {
return line + "swift"
}
}
}
if insideMultilineString {
return " \(line)"
}
return line
}.joined(separator: "\n")
}

Expand Down

0 comments on commit 2db6532

Please sign in to comment.