Skip to content

Commit

Permalink
fix: Re-enable syntax highlighting (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbmorley authored May 25, 2024
1 parent 26a0010 commit 06f723a
Showing 1 changed file with 72 additions and 72 deletions.
144 changes: 72 additions & 72 deletions Thoughts/Extensions/Sequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,78 +63,78 @@ public extension Sequence where Iterator.Element == HighlightRule {
static var markdown: [HighlightRule] {
[
HighlightRule(pattern: .all, formattingRule: TextFormattingRule(key: .font, value: defaultEditorFont)),
// HighlightRule(pattern: inlineCodeRegex, formattingRule: TextFormattingRule(key: .font, value: codeFont)),
// HighlightRule(pattern: codeBlockRegex, formattingRule: TextFormattingRule(key: .font, value: codeFont)),
// HighlightRule(pattern: headingRegex, formattingRules: [
// TextFormattingRule(fontTraits: headingTraits),
// TextFormattingRule(key: .kern, value: 0.5),
// TextFormattingRule(key: .font, calculateValue: { content, _ in
// let uncappedLevel = content.prefix(while: { char in char == "#" }).count
// let level = Swift.min(maxHeadingLevel, uncappedLevel)
// let fontSize = CGFloat(maxHeadingLevel - level) * 2.5 + defaultEditorFont.pointSize
// return SystemFontAlias(descriptor: defaultEditorFont.fontDescriptor, size: fontSize) as Any
// })
// ]),
// HighlightRule(
// pattern: linkOrImageRegex,
// formattingRules: [
// TextFormattingRule(fontTraits: boldTraits),
// TextFormattingRule(key: .foregroundColor, value: NSColor.systemBlue),
// ]
// ),
// HighlightRule(
// pattern: linkOrImageTagRegex,
// formattingRule: TextFormattingRule(key: .underlineStyle, value: NSUnderlineStyle.single.rawValue)
// ),
// HighlightRule(pattern: boldRegex, formattingRule: TextFormattingRule(fontTraits: boldTraits)),
// HighlightRule(
// pattern: asteriskEmphasisRegex,
// formattingRule: TextFormattingRule(fontTraits: emphasisTraits)
// ),
// HighlightRule(
// pattern: underscoreEmphasisRegex,
// formattingRule: TextFormattingRule(fontTraits: emphasisTraits)
// ),
// HighlightRule(
// pattern: boldEmphasisAsteriskRegex,
// formattingRule: TextFormattingRule(fontTraits: boldEmphasisTraits)
// ),
// HighlightRule(
// pattern: blockquoteRegex,
// formattingRule: TextFormattingRule(key: .backgroundColor, value: secondaryBackground)
// ),
// HighlightRule(
// pattern: horizontalRuleRegex,
// formattingRule: TextFormattingRule(key: .foregroundColor, value: lighterColor)
// ),
// HighlightRule(
// pattern: unorderedListRegex,
// formattingRule: TextFormattingRule(key: .foregroundColor, value: lighterColor)
// ),
// HighlightRule(
// pattern: orderedListRegex,
// formattingRule: TextFormattingRule(key: .foregroundColor, value: lighterColor)
// ),
// HighlightRule(
// pattern: buttonRegex,
// formattingRule: TextFormattingRule(key: .foregroundColor, value: lighterColor)
// ),
// HighlightRule(pattern: strikethroughRegex, formattingRules: [
// TextFormattingRule(key: .strikethroughStyle, value: NSUnderlineStyle.single.rawValue),
// TextFormattingRule(key: .strikethroughColor, value: textColor)
// ]),
// HighlightRule(
// pattern: tagRegex,
// formattingRule: TextFormattingRule(key: .foregroundColor, value: lighterColor)
// ),
// HighlightRule(
// pattern: footnoteRegex,
// formattingRule: TextFormattingRule(key: .foregroundColor, value: lighterColor)
// ),
// HighlightRule(pattern: htmlRegex, formattingRules: [
// TextFormattingRule(key: .font, value: codeFont),
// TextFormattingRule(key: .foregroundColor, value: lighterColor)
// ]),
HighlightRule(pattern: inlineCodeRegex, formattingRule: TextFormattingRule(key: .font, value: codeFont)),
HighlightRule(pattern: codeBlockRegex, formattingRule: TextFormattingRule(key: .font, value: codeFont)),
HighlightRule(pattern: headingRegex, formattingRules: [
TextFormattingRule(fontTraits: headingTraits),
TextFormattingRule(key: .kern, value: 0.5),
TextFormattingRule(key: .font, calculateValue: { content, _ in
let uncappedLevel = content.prefix(while: { char in char == "#" }).count
let level = Swift.min(maxHeadingLevel, uncappedLevel)
let fontSize = CGFloat(maxHeadingLevel - level) * 2.5 + defaultEditorFont.pointSize
return SystemFontAlias(descriptor: defaultEditorFont.fontDescriptor, size: fontSize) as Any
})
]),
HighlightRule(
pattern: linkOrImageRegex,
formattingRules: [
TextFormattingRule(fontTraits: boldTraits),
TextFormattingRule(key: .foregroundColor, value: NSColor.systemBlue),
]
),
HighlightRule(
pattern: linkOrImageTagRegex,
formattingRule: TextFormattingRule(key: .underlineStyle, value: NSUnderlineStyle.single.rawValue)
),
HighlightRule(pattern: boldRegex, formattingRule: TextFormattingRule(fontTraits: boldTraits)),
HighlightRule(
pattern: asteriskEmphasisRegex,
formattingRule: TextFormattingRule(fontTraits: emphasisTraits)
),
HighlightRule(
pattern: underscoreEmphasisRegex,
formattingRule: TextFormattingRule(fontTraits: emphasisTraits)
),
HighlightRule(
pattern: boldEmphasisAsteriskRegex,
formattingRule: TextFormattingRule(fontTraits: boldEmphasisTraits)
),
HighlightRule(
pattern: blockquoteRegex,
formattingRule: TextFormattingRule(key: .backgroundColor, value: secondaryBackground)
),
HighlightRule(
pattern: horizontalRuleRegex,
formattingRule: TextFormattingRule(key: .foregroundColor, value: lighterColor)
),
HighlightRule(
pattern: unorderedListRegex,
formattingRule: TextFormattingRule(key: .foregroundColor, value: lighterColor)
),
HighlightRule(
pattern: orderedListRegex,
formattingRule: TextFormattingRule(key: .foregroundColor, value: lighterColor)
),
HighlightRule(
pattern: buttonRegex,
formattingRule: TextFormattingRule(key: .foregroundColor, value: lighterColor)
),
HighlightRule(pattern: strikethroughRegex, formattingRules: [
TextFormattingRule(key: .strikethroughStyle, value: NSUnderlineStyle.single.rawValue),
TextFormattingRule(key: .strikethroughColor, value: textColor)
]),
HighlightRule(
pattern: tagRegex,
formattingRule: TextFormattingRule(key: .foregroundColor, value: lighterColor)
),
HighlightRule(
pattern: footnoteRegex,
formattingRule: TextFormattingRule(key: .foregroundColor, value: lighterColor)
),
HighlightRule(pattern: htmlRegex, formattingRules: [
TextFormattingRule(key: .font, value: codeFont),
TextFormattingRule(key: .foregroundColor, value: lighterColor)
]),
]
}
}

0 comments on commit 06f723a

Please sign in to comment.