h3 heading support in syntax highlighter
This commit is contained in:
parent
9ed64712f8
commit
b1dd8653c9
|
|
@ -1206,6 +1206,21 @@ func applySyntaxHighlighting(to textStorage: NSTextStorage) {
|
|||
}
|
||||
|
||||
private func highlightMarkdownLine(_ trimmed: String, line: String, lineRange: NSRange, textStorage: NSTextStorage, baseFont: NSFont, palette: CatppuccinPalette, isTableHeader: Bool = false) -> Bool {
|
||||
if trimmed.hasPrefix("### ") {
|
||||
let hashRange = (textStorage.string as NSString).range(of: "###", range: lineRange)
|
||||
if hashRange.location != NSNotFound {
|
||||
textStorage.addAttribute(.foregroundColor, value: palette.overlay0, range: hashRange)
|
||||
let contentStart = hashRange.location + hashRange.length
|
||||
let contentRange = NSRange(location: contentStart, length: NSMaxRange(lineRange) - contentStart)
|
||||
if contentRange.length > 0 {
|
||||
let h3Font = NSFont.systemFont(ofSize: 15, weight: .bold)
|
||||
textStorage.addAttribute(.font, value: h3Font, range: contentRange)
|
||||
textStorage.addAttribute(.foregroundColor, value: palette.text, range: contentRange)
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
if trimmed.hasPrefix("## ") {
|
||||
let hashRange = (textStorage.string as NSString).range(of: "##", range: lineRange)
|
||||
if hashRange.location != NSNotFound {
|
||||
|
|
|
|||
Loading…
Reference in New Issue