diff --git a/Sources/HTMLStreamer/AttributedStringConverter.swift b/Sources/HTMLStreamer/AttributedStringConverter.swift
index 0fe7609..14edbb3 100644
--- a/Sources/HTMLStreamer/AttributedStringConverter.swift
+++ b/Sources/HTMLStreamer/AttributedStringConverter.swift
@@ -11,7 +11,7 @@ import UIKit
import AppKit
#endif
-struct AttributedStringConverter {
+public struct AttributedStringConverter {
private let configuration: AttributedStringConverterConfiguration
private var tokenizer: Tokenizer
private let str = NSMutableAttributedString()
@@ -21,16 +21,16 @@ struct AttributedStringConverter {
// The current run of text w/o styles changing
private var currentRun: String = ""
- init(html: String, configuration: AttributedStringConverterConfiguration) where Callbacks == DefaultCallbacks {
+ public init(html: String, configuration: AttributedStringConverterConfiguration) where Callbacks == DefaultCallbacks {
self.init(html: html, configuration: configuration, callbacks: DefaultCallbacks.self)
}
- init(html: String, configuration: AttributedStringConverterConfiguration, callbacks _: Callbacks.Type = Callbacks.self) {
+ public init(html: String, configuration: AttributedStringConverterConfiguration, callbacks _: Callbacks.Type = Callbacks.self) {
self.configuration = configuration
self.tokenizer = Tokenizer(chars: html.makeIterator())
}
- mutating func convert() -> NSAttributedString {
+ public mutating func convert() -> NSAttributedString {
while let token = tokenizer.next() {
switch token {
case .character(let c):
@@ -265,12 +265,12 @@ struct AttributedStringConverter {
}
}
-protocol AttributedStringCallbacks {
+public protocol AttributedStringCallbacks {
static func makeURL(string: String) -> URL?
static func elementAction(name: String, attributes: InlineArray3) -> ElementAction
}
-enum ElementAction: Equatable {
+public enum ElementAction: Equatable {
case `default`
case skip
case replace(String)
@@ -284,7 +284,7 @@ enum ElementAction: Equatable {
}
}
-extension AttributedStringCallbacks {
+public extension AttributedStringCallbacks {
static func makeURL(string: String) -> URL? {
URL(string: string)
}
@@ -293,20 +293,36 @@ extension AttributedStringCallbacks {
}
}
-struct DefaultCallbacks: AttributedStringCallbacks {
+public struct DefaultCallbacks: AttributedStringCallbacks {
}
-struct AttributedStringConverterConfiguration {
+public struct AttributedStringConverterConfiguration {
#if os(iOS)
- var font: UIFont
- var monospaceFont: UIFont
- var color: UIColor
+ public var font: UIFont
+ public var monospaceFont: UIFont
+ public var color: UIColor
#elseif os(macOS)
- var font: NSFont
- var monospaceFont: NSFont
- var color: NSColor
+ public var font: NSFont
+ public var monospaceFont: NSFont
+ public var color: NSColor
+ #endif
+ public var paragraphStyle: NSParagraphStyle
+
+ #if os(iOS)
+ public init(font: UIFont, monospaceFont: UIFont, color: UIColor, paragraphStyle: NSParagraphStyle) {
+ self.font = font
+ self.monospaceFont = monospaceFont
+ self.color = color
+ self.paragraphStyle = paragraphStyle
+ }
+ #elseif os(macOS)
+ public init(font: NSFont, monospaceFont: NSFont, color: NSColor, paragraphStyle: NSParagraphStyle) {
+ self.font = font
+ self.monospaceFont = monospaceFont
+ self.color = color
+ self.paragraphStyle = paragraphStyle
+ }
#endif
- var paragraphStyle: NSParagraphStyle
}
#if os(macOS)
@@ -372,7 +388,7 @@ private enum Style {
}
extension Collection where Element == Attribute {
- func attributeValue(for name: String) -> String? {
+ public func attributeValue(for name: String) -> String? {
first(where: { $0.name == name })?.value
}
}
diff --git a/Sources/HTMLStreamer/InlineArray3.swift b/Sources/HTMLStreamer/InlineArray3.swift
index d579649..8e77855 100644
--- a/Sources/HTMLStreamer/InlineArray3.swift
+++ b/Sources/HTMLStreamer/InlineArray3.swift
@@ -12,10 +12,10 @@ import Foundation
/// If the array grows beyond 3 elements, it will be stored out-of-line.
/// Once that happens, the array will never return to being stored inline,
/// since the allocation cost has already been paid.
-struct InlineArray3 {
+public struct InlineArray3 {
private var storage: Storage
- init() {
+ public init() {
self.storage = .inline(nil, nil, nil)
}
}
@@ -28,7 +28,7 @@ extension InlineArray3 {
}
extension InlineArray3: ExpressibleByArrayLiteral {
- init(arrayLiteral elements: Element...) {
+ public init(arrayLiteral elements: Element...) {
switch elements.count {
case 0:
self.storage = .inline(nil, nil, nil)
@@ -45,11 +45,11 @@ extension InlineArray3: ExpressibleByArrayLiteral {
}
extension InlineArray3: MutableCollection {
- typealias Element = E
- typealias Index = Int
- typealias Indices = Range
+ public typealias Element = E
+ public typealias Index = Int
+ public typealias Indices = Range
- subscript(position: Int) -> Element {
+ public subscript(position: Int) -> Element {
_read {
precondition(position < endIndex)
switch storage {
@@ -94,11 +94,11 @@ extension InlineArray3: MutableCollection {
}
}
- var startIndex: Int {
+ public var startIndex: Int {
0
}
- var endIndex: Int {
+ public var endIndex: Int {
switch storage {
case .inline(let a, let b, let c):
a == nil ? 0 : b == nil ? 1 : c == nil ? 2 : 3
@@ -115,7 +115,7 @@ extension InlineArray3: RandomAccessCollection {
}
extension InlineArray3: RangeReplaceableCollection {
- mutating func replaceSubrange(_ subrange: Range, with newElements: C) where C: Collection, Element == C.Element {
+ public mutating func replaceSubrange(_ subrange: Range, with newElements: C) where C: Collection, Element == C.Element {
switch storage {
case .array(var arr):
arr.replaceSubrange(subrange, with: newElements)
@@ -201,7 +201,7 @@ extension InlineArray3: Equatable where E: Equatable {
}
extension InlineArray3: CustomStringConvertible {
- var description: String {
+ public var description: String {
switch storage {
case .inline(nil, nil, nil):
return "[]"
diff --git a/Sources/HTMLStreamer/Tokenizer.swift b/Sources/HTMLStreamer/Tokenizer.swift
index f39a878..dfc0e5b 100644
--- a/Sources/HTMLStreamer/Tokenizer.swift
+++ b/Sources/HTMLStreamer/Tokenizer.swift
@@ -200,9 +200,9 @@ enum Token: Equatable {
case doctype(String, forceQuirks: Bool, publicIdentifier: String?, systemIdentifier: String?)
}
-struct Attribute: Equatable {
- var name: String
- var value: String
+public struct Attribute: Equatable {
+ public var name: String
+ public var value: String
}
private enum State {