Skip to content
Merged
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
11 changes: 11 additions & 0 deletions QuickMD/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ All notable changes to QuickMD will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.15.1] - 2026-11-15

Formulas: no more repeated characters inside brackets, a crash on a malformed formula, signs and spaces as LaTeX sets them.

### Fixed
- **A crash on a malformed formula:** a row break right after `^` or `_` inside `aligned`, `matrix` or `cases` (for example `b^\\`) closed QuickMD.
- **Formulas inside brackets repeated characters:** in `cases`, `pmatrix`, `bmatrix` and anything between `\left` and `\right`, `20` was drawn as `200` and `2x` as `2xx`. Thanks to @ilmarmors for the report (#59).
- The limits of a sum, product or integral inside `\left…\right` are drawn again.
- A minus or plus sign at the start of a matrix or `cases` cell, or right after `\displaystyle` or a space command, sits against its number instead of being spaced like a subtraction.
- Space commands have their own widths: `\quad`, `\qquad`, `\;` and `\!` were all drawn as narrow as `\,`.

## [1.15.0] - 2026-11-11

Edit side by side, separate windows, tables on macOS 27.2, a redrawn icon, and many documents shown more faithfully.
Expand Down
68 changes: 64 additions & 4 deletions QuickMD/QuickMD.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,35 @@
A1B2C3D401000181 /* SourceEditLanding.swift in Sources (Tests) */ = {isa = PBXBuildFile; fileRef = A1B2C3D400000180 /* SourceEditLanding.swift */; };
A1B2C3D401000182 /* SourceEditLandingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D400000181 /* SourceEditLandingTests.swift */; };
A1B2C3D4010000F0 /* HeadingLayoutTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D4000000F0 /* HeadingLayoutTests.swift */; };
A1B2C3D401000560 /* MathFont.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D40000001A /* MathFont.swift */; };
A1B2C3D401000561 /* MathImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D40000001B /* MathImage.swift */; };
A1B2C3D401000562 /* MTBezierPath.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D40000001C /* MTBezierPath.swift */; };
A1B2C3D401000563 /* MTColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D40000001D /* MTColor.swift */; };
A1B2C3D401000564 /* MTConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D40000001E /* MTConfig.swift */; };
A1B2C3D401000565 /* MTFont.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D40000001F /* MTFont.swift */; };
A1B2C3D401000566 /* MTFontManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D400000020 /* MTFontManager.swift */; };
A1B2C3D401000567 /* MTFontMathTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D400000021 /* MTFontMathTable.swift */; };
A1B2C3D401000568 /* MTFontMathTableV2.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D400000022 /* MTFontMathTableV2.swift */; };
A1B2C3D401000569 /* MTFontV2.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D400000023 /* MTFontV2.swift */; };
A1B2C3D40100056A /* MTLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D400000024 /* MTLabel.swift */; };
A1B2C3D40100056B /* MTMathAtomFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D400000025 /* MTMathAtomFactory.swift */; };
A1B2C3D40100056C /* MTMathImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D400000026 /* MTMathImage.swift */; };
A1B2C3D40100056D /* MTMathList.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D400000027 /* MTMathList.swift */; };
A1B2C3D40100056E /* MTMathListBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D400000028 /* MTMathListBuilder.swift */; };
A1B2C3D40100056F /* MTMathListDisplay.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D400000029 /* MTMathListDisplay.swift */; };
A1B2C3D401000570 /* MTMathListIndex.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D40000002A /* MTMathListIndex.swift */; };
A1B2C3D401000571 /* MTMathUILabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D40000002B /* MTMathUILabel.swift */; };
A1B2C3D401000572 /* MTTypesetter.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D40000002C /* MTTypesetter.swift */; };
A1B2C3D401000573 /* MTTypesetter+Tokenization.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D40000002D /* MTTypesetter+Tokenization.swift */; };
A1B2C3D401000574 /* MTUnicode.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D40000002E /* MTUnicode.swift */; };
A1B2C3D401000575 /* RWLock.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D40000002F /* RWLock.swift */; };
A1B2C3D401000576 /* MTAtomTokenizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D400000030 /* MTAtomTokenizer.swift */; };
A1B2C3D401000577 /* MTBreakableElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D400000031 /* MTBreakableElement.swift */; };
A1B2C3D401000578 /* MTDisplayGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D400000032 /* MTDisplayGenerator.swift */; };
A1B2C3D401000579 /* MTDisplayPreRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D400000033 /* MTDisplayPreRenderer.swift */; };
A1B2C3D40100057A /* MTElementWidthCalculator.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D400000034 /* MTElementWidthCalculator.swift */; };
A1B2C3D40100057B /* MTLineFitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D400000035 /* MTLineFitter.swift */; };
A1B2C3D401000541 /* MathEngineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D400000540 /* MathEngineTests.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -358,6 +387,7 @@
A1B2C3D40000004D /* FileWatcherTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileWatcherTests.swift; sourceTree = "<group>"; };
A1B2C3D400000066 /* ChromeHoverState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChromeHoverState.swift; sourceTree = "<group>"; };
A1B2C3D400000067 /* ChromeHoverTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChromeHoverTests.swift; sourceTree = "<group>"; };
A1B2C3D400000540 /* MathEngineTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MathEngineTests.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -401,6 +431,7 @@
A1B2C3D40000006A /* BlockHeightMeasurerTests.swift */,
A1B2C3D4000002A1 /* VerticalRhythmTests.swift */,
A1B2C3D400000440 /* MathInTextKindsTests.swift */,
A1B2C3D400000540 /* MathEngineTests.swift */,
A1B2C3D400000483 /* InlineSyntaxTests.swift */,
A1B2C3D400000462 /* ImageRowTests.swift */,
A1B2C3D400000465 /* LocalLinkSafetyTests.swift */,
Expand Down Expand Up @@ -822,6 +853,35 @@
A1B2C3D40100006A /* BlockHeightMeasurerTests.swift in Sources */,
A1B2C3D4010002A2 /* VerticalRhythmTests.swift in Sources */,
A1B2C3D401000441 /* MathInTextKindsTests.swift in Sources */,
A1B2C3D401000560 /* MathFont.swift in Sources */,
A1B2C3D401000561 /* MathImage.swift in Sources */,
A1B2C3D401000562 /* MTBezierPath.swift in Sources */,
A1B2C3D401000563 /* MTColor.swift in Sources */,
A1B2C3D401000564 /* MTConfig.swift in Sources */,
A1B2C3D401000565 /* MTFont.swift in Sources */,
A1B2C3D401000566 /* MTFontManager.swift in Sources */,
A1B2C3D401000567 /* MTFontMathTable.swift in Sources */,
A1B2C3D401000568 /* MTFontMathTableV2.swift in Sources */,
A1B2C3D401000569 /* MTFontV2.swift in Sources */,
A1B2C3D40100056A /* MTLabel.swift in Sources */,
A1B2C3D40100056B /* MTMathAtomFactory.swift in Sources */,
A1B2C3D40100056C /* MTMathImage.swift in Sources */,
A1B2C3D40100056D /* MTMathList.swift in Sources */,
A1B2C3D40100056E /* MTMathListBuilder.swift in Sources */,
A1B2C3D40100056F /* MTMathListDisplay.swift in Sources */,
A1B2C3D401000570 /* MTMathListIndex.swift in Sources */,
A1B2C3D401000571 /* MTMathUILabel.swift in Sources */,
A1B2C3D401000572 /* MTTypesetter.swift in Sources */,
A1B2C3D401000573 /* MTTypesetter+Tokenization.swift in Sources */,
A1B2C3D401000574 /* MTUnicode.swift in Sources */,
A1B2C3D401000575 /* RWLock.swift in Sources */,
A1B2C3D401000576 /* MTAtomTokenizer.swift in Sources */,
A1B2C3D401000577 /* MTBreakableElement.swift in Sources */,
A1B2C3D401000578 /* MTDisplayGenerator.swift in Sources */,
A1B2C3D401000579 /* MTDisplayPreRenderer.swift in Sources */,
A1B2C3D40100057A /* MTElementWidthCalculator.swift in Sources */,
A1B2C3D40100057B /* MTLineFitter.swift in Sources */,
A1B2C3D401000541 /* MathEngineTests.swift in Sources */,
A1B2C3D401000484 /* InlineSyntaxTests.swift in Sources */,
A1B2C3D401000462 /* ImageRowTests.swift in Sources */,
A1B2C3D401000465 /* LocalLinkSafetyTests.swift in Sources */,
Expand Down Expand Up @@ -1021,7 +1081,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 32;
CURRENT_PROJECT_VERSION = 33;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = VJ92852M32;
ENABLE_APP_SANDBOX = YES;
Expand All @@ -1046,7 +1106,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.15.0;
MARKETING_VERSION = 1.15.1;
PRODUCT_BUNDLE_IDENTIFIER = pl.falami.studio.QuickMD;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -1065,7 +1125,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 32;
CURRENT_PROJECT_VERSION = 33;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = VJ92852M32;
ENABLE_APP_SANDBOX = YES;
Expand All @@ -1090,7 +1150,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.15.0;
MARKETING_VERSION = 1.15.1;
PRODUCT_BUNDLE_IDENTIFIER = pl.falami.studio.QuickMD;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
7 changes: 6 additions & 1 deletion QuickMD/QuickMD/SwiftMath/MTBezierPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ extension MTBezierPath {
}
}

extension MTView {
// QuickMD (#59): upstream declares this on MTView, i.e. on EVERY NSView. A read
// of `textView.backgroundColor` where an optional colour is expected then binds
// to this layer property instead of NSTextView's own (it broke the editor's
// colour tests once the engine was compiled into the test target). The label
// is the only user, so the property lives on the label.
extension MTMathUILabel {

var backgroundColor:MTColor? {
get {
Expand Down
14 changes: 12 additions & 2 deletions QuickMD/QuickMD/SwiftMath/MTFont.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ public class MTFont {
}

static var fontBundle:Bundle {
// Uses bundle for class so that this can be access by the unit tests.
Bundle(url: Bundle.main.url(forResource: "mathFonts", withExtension: "bundle")!)!
Bundle(url: MathFontsBundle.url!)!
}

/** Returns a copy of this font but with a different size. */
Expand Down Expand Up @@ -78,3 +77,14 @@ public class MTFont {
}

}

/// Where the math fonts live (QuickMD addition, #59). The app reads them from
/// its own bundle. The unit tests have no host app (their main bundle is the
/// test runner), so `MathEngineTests` points `overrideURL` at the folder in the
/// source tree to typeset with the real engine.
enum MathFontsBundle {
static var overrideURL: URL?
static var url: URL? {
overrideURL ?? Bundle.main.url(forResource: "mathFonts", withExtension: "bundle")
}
}
16 changes: 11 additions & 5 deletions QuickMD/QuickMD/SwiftMath/MTMathList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,11 @@ public class MTMathList : NSObject {
let zeroRange = NSMakeRange(0, 0)

var prevNode: MTMathAtom? = nil
// TeX's "most recent previous atom" for rules 5 & 6 (QuickMD): style
// changes and spaces are not atoms, so `\displaystyle -x`, `\quad -x`
// and a matrix cell `-1` (cells start with a style) begin with a sign,
// not with a subtraction.
var prevNoad: MTMathAtom? = nil
for atom in self.atoms {
let newNode = atom.finalized

Expand All @@ -949,12 +954,12 @@ public class MTMathList : NSObject {

switch newNode.type {
case .binaryOperator:
if isNotBinaryOperator(prevNode) {
if isNotBinaryOperator(prevNoad) {
newNode.type = .unaryOperator
}
case .relation, .punctuation, .close:
if prevNode != nil && prevNode!.type == .binaryOperator {
prevNode!.type = .unaryOperator
if prevNoad != nil && prevNoad!.type == .binaryOperator {
prevNoad!.type = .unaryOperator
}
case .number:
if prevNode != nil && prevNode!.type == .number && prevNode!.subScript == nil && prevNode!.superScript == nil {
Expand All @@ -965,9 +970,10 @@ public class MTMathList : NSObject {
}
finalizedList.add(newNode)
prevNode = newNode
if newNode.type != .style && newNode.type != .space { prevNoad = newNode }
}
if prevNode != nil && prevNode!.type == .binaryOperator {
prevNode!.type = .unaryOperator
if prevNoad != nil && prevNoad!.type == .binaryOperator {
prevNoad!.type = .unaryOperator
}
return finalizedList
}
Expand Down
8 changes: 7 additions & 1 deletion QuickMD/QuickMD/SwiftMath/MTMathListBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,13 @@ public struct MTMathListBuilder {
currentCol+=1
if currentEnv!.numRows > currentRow {
currentRow = currentEnv!.numRows
rows.append([MTMathList]())
// A row break consumed inside a sub-list (e.g. `x^\\`) can advance
// numRows by more than one per cell, so grow to the row we're on
// rather than by exactly one, or the subscript above traps
// (upstream SwiftMath #76).
while rows.count <= currentRow {
rows.append([MTMathList]())
}
currentCol = 0
}
}
Expand Down
16 changes: 15 additions & 1 deletion QuickMD/QuickMD/SwiftMath/MTTypesetter+Tokenization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,21 @@ extension MTTypesetter {
// Phase 0: Preprocess atoms to fuse ordinary characters
// This is critical for accents and other structures where multi-character
// text like "xyzw" should stay together as a single atom
let preprocessedAtoms = MTTypesetter.preprocessMathList(mathList)
//
// INVARIANT: typesetting never changes its input (upstream SwiftMath #75;
// QuickMD #59). `preprocessMathList` mutates the atoms it is handed (it
// rewrites `type` and `nucleus`, and `MTMathAtom.fuse(with:)` appends the
// next atom's nucleus onto the previous atom while the next atom stays in
// the list). Every internal typeset request funnels through this function,
// and some typeset the same list more than once (delimiter measurement,
// accent re-layout), so preprocessing the caller's atoms made the second
// pass fuse again: "2","x" became "2x", then "2x","x" became "2xx".
// Preprocess a deep copy instead. `MTMathAtom.copy()` is the
// type-dispatched deep copy (sublists included); `finalized` is
// deliberately not used here because it re-applies TeX rules 5 & 6.
let atomsToPreprocess = MTMathList()
atomsToPreprocess.atoms = mathList.atoms.map { $0.copy() }
let preprocessedAtoms = MTTypesetter.preprocessMathList(atomsToPreprocess)

// Phase 1: Tokenize atoms into breakable elements
let tokenizer = MTAtomTokenizer(font: font, style: style, cramped: cramped, maxWidth: maxWidth)
Expand Down
Loading
Loading