2020-07-13 03:09:22 +00:00
|
|
|
//
|
|
|
|
// Document.swift
|
|
|
|
// GeminiFormat
|
|
|
|
//
|
|
|
|
// Created by Shadowfacts on 7/12/20.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
2020-07-13 03:25:20 +00:00
|
|
|
public struct Document {
|
|
|
|
public let url: URL
|
|
|
|
public var lines: [Line]
|
2020-07-13 03:09:22 +00:00
|
|
|
|
|
|
|
init(url: URL, lines: [Line] = []) {
|
|
|
|
self.url = url
|
|
|
|
self.lines = lines
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-13 03:25:20 +00:00
|
|
|
public extension Document {
|
2020-07-13 03:09:22 +00:00
|
|
|
enum Line: Equatable {
|
|
|
|
case text(String)
|
|
|
|
case link(URL, text: String?)
|
|
|
|
case preformattedText(String, alt: String?)
|
|
|
|
case heading(String, level: HeadingLevel)
|
|
|
|
case unorderedListItem(String)
|
|
|
|
case quote(String)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-13 03:25:20 +00:00
|
|
|
public extension Document {
|
2020-07-13 03:09:22 +00:00
|
|
|
enum HeadingLevel: Int {
|
|
|
|
case h1 = 1, h2 = 2, h3 = 3
|
|
|
|
}
|
|
|
|
}
|