Skip to content

Commit

Permalink
Update structure a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
khlopko committed Mar 17, 2024
1 parent b84e795 commit c58c6da
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
1 change: 1 addition & 0 deletions Sources/marker/App.swift → Cli/App.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import DotMd

@main
struct App {
Expand Down
16 changes: 8 additions & 8 deletions Sources/marker/Markdown.swift → Markdown/Markdown.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@

import Foundation

struct Markdown {
let blocks: [Block]
public struct Markdown {
public let blocks: [Block]

init(path: String) throws {
public init(path: String) throws {
let contents = try String(contentsOfFile: path)
var parser = MarkdownParser(contents: Array(contents))
self.blocks = parser.parse()
}
}

extension Markdown: CustomStringConvertible {
var description: String {
public var description: String {
blocks.map { block in
block.description
}.joined(separator: "\n")
}
}

enum Block: Equatable {
public enum Block: Equatable {
case p([Block])
case text(String, TextStyle)
indirect case h(HeaderLevel, Block)
}

extension Block: CustomStringConvertible {
var description: String {
public var description: String {
switch self {
case let .p(blocks):
return blocks.map { block in
Expand All @@ -41,7 +41,7 @@ extension Block: CustomStringConvertible {
}
}

enum HeaderLevel: Int, Equatable {
public enum HeaderLevel: Int, Equatable {
case h1 = 1
case h2
case h3
Expand All @@ -50,7 +50,7 @@ enum HeaderLevel: Int, Equatable {
case h6
}

enum TextStyle: Equatable {
public enum TextStyle: Equatable {
case regular
}

Expand Down
17 changes: 13 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,23 @@ let package = Package(
],
targets: [
.executableTarget(
name: "Marker"
name: "Marker",
dependencies: [
.target(name: "DotMd"),
],
path: "Cli"
),
.target(
name: "DotMd",
path: "Markdown"
),
.testTarget(
name: "MarkerTests",
name: "DotMdTests",
dependencies: [
.target(name: "Marker"),
.target(name: "DotMd"),
.product(name: "Testing", package: "swift-testing"),
]
],
path: "Tests/MarkdownTests"
),
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Testing

@testable import Marker
@testable import DotMd

@Suite("MarkdownParserTests")
struct MarkdownParserTests {
Expand Down
File renamed without changes.

0 comments on commit c58c6da

Please sign in to comment.