Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added
- **`SpellCheckingPolicy.automaticQuoteSubstitution`**: makes
`NSTextView.isAutomaticQuoteSubstitutionEnabled` configurable instead of
hard-coded on. Some Markdown sources need straight quotes throughout
(frontmatter, code-adjacent prose) where automatic curly-quote substitution
would corrupt the source. Defaults to `true`, preserving the prior
always-on behavior.
- **Directive seam (parsing)**: opt-in named inline commands with typed
arguments, for constructs that need a name and parameters rather than
delimiters. A `MarkdownDirective` declares a name, a form — self-contained
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,21 @@ public struct SpellCheckingPolicy: Sendable {
public var grammarChecking: Bool
/// Mirrors `NSTextView.isAutomaticSpellingCorrectionEnabled`.
public var automaticSpellingCorrection: Bool
/// Mirrors `NSTextView.isAutomaticQuoteSubstitutionEnabled`. Markdown sources
/// sometimes need straight quotes throughout (frontmatter, code-adjacent prose);
/// `true` preserves the historical always-on behavior.
public var automaticQuoteSubstitution: Bool

public init(
continuousSpellChecking: Bool = true,
grammarChecking: Bool = true,
automaticSpellingCorrection: Bool = true
automaticSpellingCorrection: Bool = true,
automaticQuoteSubstitution: Bool = true
) {
self.continuousSpellChecking = continuousSpellChecking
self.grammarChecking = grammarChecking
self.automaticSpellingCorrection = automaticSpellingCorrection
self.automaticQuoteSubstitution = automaticQuoteSubstitution
}

public static let `default` = SpellCheckingPolicy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ extension NativeTextViewCoordinator {
textView.isGrammarCheckingEnabled = shouldDisableSpelling
? false
: userPrefersGrammarChecking
textView.isAutomaticQuoteSubstitutionEnabled = !shouldDisableSpelling
textView.isAutomaticQuoteSubstitutionEnabled = shouldDisableSpelling
? false
: configuration.spellChecking.automaticQuoteSubstitution
textView.isAutomaticDashSubstitutionEnabled = false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public struct NativeTextViewWrapper: NSViewRepresentable {
textView.isAutomaticSpellingCorrectionEnabled = configuration.spellChecking.automaticSpellingCorrection
textView.isContinuousSpellCheckingEnabled = configuration.spellChecking.continuousSpellChecking
textView.isGrammarCheckingEnabled = configuration.spellChecking.grammarChecking
textView.isAutomaticQuoteSubstitutionEnabled = true
textView.isAutomaticQuoteSubstitutionEnabled = configuration.spellChecking.automaticQuoteSubstitution
textView.isAutomaticDataDetectionEnabled = true
textView.isAutomaticDashSubstitutionEnabled = false
textView.onPasteImage = onPasteImage
Expand Down
26 changes: 26 additions & 0 deletions Tests/MarkdownEngineTests/SpellCheckingPolicyTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// SpellCheckingPolicyTests.swift
// MarkdownEngineTests
//

import Testing
@testable import MarkdownEngine

@Suite("SpellCheckingPolicy")
struct SpellCheckingPolicyTests {
@Test("automaticQuoteSubstitution defaults to true, preserving prior always-on behavior")
func defaultsToEnabled() {
let policy = SpellCheckingPolicy()
#expect(policy.automaticQuoteSubstitution == true)
#expect(SpellCheckingPolicy.default.automaticQuoteSubstitution == true)
}

@Test("automaticQuoteSubstitution can be disabled independently of the other toggles")
func canBeDisabled() {
let policy = SpellCheckingPolicy(automaticQuoteSubstitution: false)
#expect(policy.automaticQuoteSubstitution == false)
#expect(policy.continuousSpellChecking == true)
#expect(policy.grammarChecking == true)
#expect(policy.automaticSpellingCorrection == true)
}
}