aboutsummaryrefslogtreecommitdiff
path: root/Sources/NorgKit/Models/InlineStyle.swift
diff options
context:
space:
mode:
authorRuben Beltran del Rio <jj@r.bdr.sh>2026-06-16 12:08:21 +0200
committerRuben Beltran del Rio <jj@r.bdr.sh>2026-06-16 12:22:47 +0200
commit501fdce29e4d2c46c4708ad7f44056878e0db3fa (patch)
treedb923b77037db9f5b37600a6e34c3bb2e8a971be /Sources/NorgKit/Models/InlineStyle.swift
Initial extraction from Norganize1.0.0
Diffstat (limited to 'Sources/NorgKit/Models/InlineStyle.swift')
-rw-r--r--Sources/NorgKit/Models/InlineStyle.swift28
1 files changed, 28 insertions, 0 deletions
diff --git a/Sources/NorgKit/Models/InlineStyle.swift b/Sources/NorgKit/Models/InlineStyle.swift
new file mode 100644
index 0000000..807de7b
--- /dev/null
+++ b/Sources/NorgKit/Models/InlineStyle.swift
@@ -0,0 +1,28 @@
+/// Composable inline styles that may be applied to a single run of text.
+public struct InlineStyle: OptionSet, Hashable, Sendable, Codable {
+ public let rawValue: Int
+
+ public init(rawValue: Int) {
+ self.rawValue = rawValue
+ }
+
+ public static let bold = InlineStyle(rawValue: 1 << 0)
+ public static let italic = InlineStyle(rawValue: 1 << 1)
+ public static let underline = InlineStyle(rawValue: 1 << 2)
+ public static let strikethrough = InlineStyle(rawValue: 1 << 3)
+ public static let verbatim = InlineStyle(rawValue: 1 << 4)
+ public static let superscript = InlineStyle(rawValue: 1 << 5)
+ public static let `subscript` = InlineStyle(rawValue: 1 << 6)
+ public static let spoiler = InlineStyle(rawValue: 1 << 7)
+ public static let math = InlineStyle(rawValue: 1 << 8)
+
+ public init(from decoder: Decoder) throws {
+ let container = try decoder.singleValueContainer()
+ self.init(rawValue: try container.decode(Int.self))
+ }
+
+ public func encode(to encoder: Encoder) throws {
+ var container = encoder.singleValueContainer()
+ try container.encode(rawValue)
+ }
+}