Skip to content

Commit a68a7b5

Browse files
authored
Merge branch 'gonzalezreal:main' into feature/fbernardo/mutiple_table_styles
2 parents aa22c2e + 5544181 commit a68a7b5

File tree

15 files changed

+161
-85
lines changed

15 files changed

+161
-85
lines changed

.github/workflows/format.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@ on:
66
jobs:
77
format:
88
name: swift-format
9-
runs-on: macos-12
9+
runs-on: macos-13
1010
steps:
11-
- uses: actions/checkout@v2
12-
- name: Select Xcode 14.2
13-
run: sudo xcode-select -s /Applications/Xcode_14.2.app
14-
- name: Tap
15-
run: brew tap pointfreeco/formulae
11+
- uses: actions/checkout@v4
12+
- name: Select Xcode
13+
run: sudo xcode-select -s /Applications/Xcode_15.0.app
1614
- name: Install
17-
run: brew install Formulae/swift-format@5.7
15+
run: brew install swift-format
1816
- name: Format
1917
run: make format
2018
- uses: stefanzweifel/git-auto-commit-action@v4

Examples/Demo/Demo/CodeSyntaxHighlightView.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,14 @@ struct CodeSyntaxHighlightView: View {
147147
}
148148

149149
private func copyToClipboard(_ string: String) {
150-
#if os(macOS)
151-
if let pasteboard = NSPasteboard.general {
152-
pasteboard.clearContents()
153-
pasteboard.setString(string, forType: .string)
154-
}
155-
#elseif os(iOS)
156-
UIPasteboard.general.string = string
157-
#endif
150+
#if os(macOS)
151+
if let pasteboard = NSPasteboard.general {
152+
pasteboard.clearContents()
153+
pasteboard.setString(string, forType: .string)
154+
}
155+
#elseif os(iOS)
156+
UIPasteboard.general.string = string
157+
#endif
158158
}
159159
}
160160

Sources/MarkdownUI/DSL/Inlines/SoftBreak.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,13 @@ public struct SoftBreak: InlineContentProtocol {
1111
.init(inlines: [.softBreak])
1212
}
1313
}
14+
15+
extension SoftBreak {
16+
public enum Mode {
17+
/// Treat a soft break as a space
18+
case space
19+
20+
/// Treat a soft break as a line break
21+
case lineBreak
22+
}
23+
}

Sources/MarkdownUI/Parser/InlineNode.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
enum InlineNode: Hashable {
3+
enum InlineNode: Hashable, Sendable {
44
case text(String)
55
case softBreak
66
case lineBreak

Sources/MarkdownUI/Renderer/AttributedStringInlineRenderer.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ extension InlineNode {
44
func renderAttributedString(
55
baseURL: URL?,
66
textStyles: InlineTextStyles,
7+
softBreakMode: SoftBreak.Mode,
78
attributes: AttributeContainer
89
) -> AttributedString {
910
var renderer = AttributedStringInlineRenderer(
1011
baseURL: baseURL,
1112
textStyles: textStyles,
13+
softBreakMode: softBreakMode,
1214
attributes: attributes
1315
)
1416
renderer.render(self)
@@ -21,12 +23,19 @@ private struct AttributedStringInlineRenderer {
2123

2224
private let baseURL: URL?
2325
private let textStyles: InlineTextStyles
26+
private let softBreakMode: SoftBreak.Mode
2427
private var attributes: AttributeContainer
2528
private var shouldSkipNextWhitespace = false
2629

27-
init(baseURL: URL?, textStyles: InlineTextStyles, attributes: AttributeContainer) {
30+
init(
31+
baseURL: URL?,
32+
textStyles: InlineTextStyles,
33+
softBreakMode: SoftBreak.Mode,
34+
attributes: AttributeContainer
35+
) {
2836
self.baseURL = baseURL
2937
self.textStyles = textStyles
38+
self.softBreakMode = softBreakMode
3039
self.attributes = attributes
3140
}
3241

@@ -67,10 +76,13 @@ private struct AttributedStringInlineRenderer {
6776
}
6877

6978
private mutating func renderSoftBreak() {
70-
if self.shouldSkipNextWhitespace {
79+
switch softBreakMode {
80+
case .space where self.shouldSkipNextWhitespace:
7181
self.shouldSkipNextWhitespace = false
72-
} else {
82+
case .space:
7383
self.result += .init(" ", attributes: self.attributes)
84+
case .lineBreak:
85+
self.renderLineBreak()
7486
}
7587
}
7688

Sources/MarkdownUI/Renderer/TextInlineRenderer.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ extension Sequence where Element == InlineNode {
55
baseURL: URL?,
66
textStyles: InlineTextStyles,
77
images: [String: Image],
8+
softBreakMode: SoftBreak.Mode,
89
attributes: AttributeContainer
910
) -> Text {
1011
var renderer = TextInlineRenderer(
1112
baseURL: baseURL,
1213
textStyles: textStyles,
1314
images: images,
15+
softBreakMode: softBreakMode,
1416
attributes: attributes
1517
)
1618
renderer.render(self)
@@ -24,18 +26,21 @@ private struct TextInlineRenderer {
2426
private let baseURL: URL?
2527
private let textStyles: InlineTextStyles
2628
private let images: [String: Image]
29+
private let softBreakMode: SoftBreak.Mode
2730
private let attributes: AttributeContainer
2831
private var shouldSkipNextWhitespace = false
2932

3033
init(
3134
baseURL: URL?,
3235
textStyles: InlineTextStyles,
3336
images: [String: Image],
37+
softBreakMode: SoftBreak.Mode,
3438
attributes: AttributeContainer
3539
) {
3640
self.baseURL = baseURL
3741
self.textStyles = textStyles
3842
self.images = images
43+
self.softBreakMode = softBreakMode
3944
self.attributes = attributes
4045
}
4146

@@ -72,10 +77,14 @@ private struct TextInlineRenderer {
7277
}
7378

7479
private mutating func renderSoftBreak() {
75-
if self.shouldSkipNextWhitespace {
80+
switch self.softBreakMode {
81+
case .space where self.shouldSkipNextWhitespace:
7682
self.shouldSkipNextWhitespace = false
77-
} else {
83+
case .space:
7884
self.defaultRender(.softBreak)
85+
case .lineBreak:
86+
self.shouldSkipNextWhitespace = true
87+
self.defaultRender(.lineBreak)
7988
}
8089
}
8190

@@ -104,6 +113,7 @@ private struct TextInlineRenderer {
104113
inline.renderAttributedString(
105114
baseURL: self.baseURL,
106115
textStyles: self.textStyles,
116+
softBreakMode: self.softBreakMode,
107117
attributes: self.attributes
108118
)
109119
)

Sources/MarkdownUI/Theme/TextStyle/Styles/Font+FontProperties.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ extension Font {
99
case .system(let design):
1010
font = .system(size: size, design: design)
1111
case .custom(let name):
12-
font = .custom(name, size: size)
12+
font = .custom(name, fixedSize: size)
1313
}
1414

1515
switch fontProperties.familyVariant {

Sources/MarkdownUI/Utility/Deprecations.swift

Lines changed: 27 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ extension View {
4646
@available(
4747
*,
4848
deprecated,
49-
message:
50-
"""
49+
message: """
5150
Use the version of this function that takes a closure receiving a generic 'Configuration'
5251
value.
5352
"""
@@ -62,8 +61,7 @@ extension View {
6261
@available(
6362
*,
6463
deprecated,
65-
message:
66-
"""
64+
message: """
6765
Use the version of this function that takes a closure receiving a generic 'Configuration'
6866
value.
6967
"""
@@ -85,8 +83,7 @@ extension Theme {
8583
@available(
8684
*,
8785
deprecated,
88-
message:
89-
"""
86+
message: """
9087
Use the version of this function that takes a closure receiving a 'BlockConfiguration'
9188
value.
9289
"""
@@ -102,8 +99,7 @@ extension Theme {
10299
@available(
103100
*,
104101
deprecated,
105-
message:
106-
"""
102+
message: """
107103
Use the version of this function that takes a closure receiving a 'BlockConfiguration'
108104
value.
109105
"""
@@ -119,8 +115,7 @@ extension Theme {
119115
@available(
120116
*,
121117
deprecated,
122-
message:
123-
"""
118+
message: """
124119
Use the version of this function that takes a closure receiving a 'BlockConfiguration'
125120
value.
126121
"""
@@ -136,8 +131,7 @@ extension Theme {
136131
@available(
137132
*,
138133
deprecated,
139-
message:
140-
"""
134+
message: """
141135
Use the version of this function that takes a closure receiving a 'BlockConfiguration'
142136
value.
143137
"""
@@ -153,8 +147,7 @@ extension Theme {
153147
@available(
154148
*,
155149
deprecated,
156-
message:
157-
"""
150+
message: """
158151
Use the version of this function that takes a closure receiving a 'BlockConfiguration'
159152
value.
160153
"""
@@ -170,8 +163,7 @@ extension Theme {
170163
@available(
171164
*,
172165
deprecated,
173-
message:
174-
"""
166+
message: """
175167
Use the version of this function that takes a closure receiving a 'BlockConfiguration'
176168
value.
177169
"""
@@ -187,8 +179,7 @@ extension Theme {
187179
@available(
188180
*,
189181
deprecated,
190-
message:
191-
"""
182+
message: """
192183
Use the version of this function that takes a closure receiving a 'BlockConfiguration'
193184
value.
194185
"""
@@ -204,8 +195,7 @@ extension Theme {
204195
@available(
205196
*,
206197
deprecated,
207-
message:
208-
"""
198+
message: """
209199
Use the version of this function that takes a closure receiving a 'BlockConfiguration'
210200
value.
211201
"""
@@ -221,8 +211,7 @@ extension Theme {
221211
@available(
222212
*,
223213
deprecated,
224-
message:
225-
"""
214+
message: """
226215
Use the version of this function that takes a closure receiving a 'CodeBlockConfiguration'
227216
value.
228217
"""
@@ -240,8 +229,7 @@ extension Theme {
240229
@available(
241230
*,
242231
deprecated,
243-
message:
244-
"""
232+
message: """
245233
Use the version of this function that takes a closure receiving a 'BlockConfiguration'
246234
value.
247235
"""
@@ -257,8 +245,7 @@ extension Theme {
257245
@available(
258246
*,
259247
deprecated,
260-
message:
261-
"""
248+
message: """
262249
Use the version of this function that takes a closure receiving a 'BlockConfiguration'
263250
value.
264251
"""
@@ -274,8 +261,7 @@ extension Theme {
274261
@available(
275262
*,
276263
deprecated,
277-
message:
278-
"""
264+
message: """
279265
Use the version of this function that takes a closure receiving a 'BlockConfiguration'
280266
value.
281267
"""
@@ -291,8 +277,7 @@ extension Theme {
291277
@available(
292278
*,
293279
deprecated,
294-
message:
295-
"""
280+
message: """
296281
Use the version of this function that takes a closure receiving a 'BlockConfiguration'
297282
value.
298283
"""
@@ -330,11 +315,10 @@ public typealias InlineCode = Code
330315
@available(
331316
*,
332317
unavailable,
333-
message:
318+
message: """
319+
"MarkdownImageHandler" has been superseded by the "ImageProvider" protocol and its conforming
320+
types "DefaultImageProvider" and "AssetImageProvider".
334321
"""
335-
"MarkdownImageHandler" has been superseded by the "ImageProvider" protocol and its conforming
336-
types "DefaultImageProvider" and "AssetImageProvider".
337-
"""
338322
)
339323
public struct MarkdownImageHandler {
340324
public static var networkImage: Self {
@@ -353,11 +337,10 @@ extension Markdown {
353337
@available(
354338
*,
355339
unavailable,
356-
message:
340+
message: """
341+
"MarkdownImageHandler" has been superseded by the "ImageProvider" protocol and its conforming
342+
types "DefaultImageProvider" and "AssetImageProvider".
357343
"""
358-
"MarkdownImageHandler" has been superseded by the "ImageProvider" protocol and its conforming
359-
types "DefaultImageProvider" and "AssetImageProvider".
360-
"""
361344
)
362345
public func setImageHandler(
363346
_ imageHandler: MarkdownImageHandler,
@@ -381,11 +364,10 @@ extension View {
381364
@available(
382365
*,
383366
unavailable,
384-
message:
367+
message: """
368+
"MarkdownStyle" and its subtypes have been superseded by the "Theme", "TextStyle", and
369+
"BlockStyle" types.
385370
"""
386-
"MarkdownStyle" and its subtypes have been superseded by the "Theme", "TextStyle", and
387-
"BlockStyle" types.
388-
"""
389371
)
390372
public struct MarkdownStyle: Hashable {
391373
public struct Font: Hashable {
@@ -501,11 +483,10 @@ extension View {
501483
@available(
502484
*,
503485
unavailable,
504-
message:
486+
message: """
487+
"MarkdownStyle" and its subtypes have been superseded by the "Theme", "TextStyle", and
488+
"BlockStyle" types.
505489
"""
506-
"MarkdownStyle" and its subtypes have been superseded by the "Theme", "TextStyle", and
507-
"BlockStyle" types.
508-
"""
509490
)
510491
public func markdownStyle(_ markdownStyle: MarkdownStyle) -> some View {
511492
self

0 commit comments

Comments
 (0)