diff --git a/.gitignore b/.gitignore index 19e900a1..dfe1e4bd 100644 --- a/.gitignore +++ b/.gitignore @@ -10,5 +10,3 @@ /.build /Packages /*.xcodeproj -.swiftpm -Package.resolved diff --git a/Package.swift b/Package.swift index 0b52b1e6..c1153796 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.3 +// swift-tools-version:4.2 /* This source file is part of the Swift.org open source project @@ -25,21 +25,13 @@ let package = Package( targets: [ .target( name: "Markdown", - dependencies: [ - "CAtomic", - .product(name: "cmark-gfm", package: "swift-cmark"), - .product(name: "cmark-gfm-extensions", package: "swift-cmark"), - ]), + dependencies: ["cmark-gfm", "cmark-gfm-extensions", "CAtomic"]), .target( name: "markdown-tool", - dependencies: [ - "Markdown", - .product(name: "ArgumentParser", package: "swift-argument-parser") - ]), + dependencies: ["Markdown", .product(name: "ArgumentParser", package: "swift-argument-parser")]), .testTarget( name: "MarkdownTests", - dependencies: ["Markdown"], - resources: [.process("Visitors/Everything.md")]), + dependencies: ["Markdown"]), .target(name: "CAtomic"), ] ) diff --git a/Package@swift-5.5.swift b/Package@swift-5.5.swift deleted file mode 100644 index 41b055e2..00000000 --- a/Package@swift-5.5.swift +++ /dev/null @@ -1,64 +0,0 @@ -// swift-tools-version:5.5 -// In order to support users running on the latest Xcodes, please ensure that -// Package@swift-5.5.swift is kept in sync with this file. -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2021 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See https://swift.org/LICENSE.txt for license information - See https://swift.org/CONTRIBUTORS.txt for Swift project authors -*/ - -import PackageDescription -import class Foundation.ProcessInfo - -let package = Package( - name: "swift-markdown", - products: [ - .library( - name: "Markdown", - targets: ["Markdown"]), - .executable( - name: "markdown-tool", - targets: ["markdown-tool"]), - ], - targets: [ - .target( - name: "Markdown", - dependencies: [ - "CAtomic", - .product(name: "cmark-gfm", package: "swift-cmark"), - .product(name: "cmark-gfm-extensions", package: "swift-cmark"), - ]), - .executableTarget( - name: "markdown-tool", - dependencies: [ - "Markdown", - .product(name: "ArgumentParser", package: "swift-argument-parser") - ]), - .testTarget( - name: "MarkdownTests", - dependencies: ["Markdown"], - resources: [.process("Visitors/Everything.md")]), - .target(name: "CAtomic"), - ] -) - -// If the `SWIFTCI_USE_LOCAL_DEPS` environment variable is set, -// we're building in the Swift.org CI system alongside other projects in the Swift toolchain and -// we can depend on local versions of our dependencies instead of fetching them remotely. -if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil { - // Building standalone, so fetch all dependencies remotely. - package.dependencies += [ - .package(url: "https://github.com/apple/swift-cmark.git", .branch("gfm")), - .package(url: "https://github.com/apple/swift-argument-parser", .upToNextMinor(from: "0.4.4")), - ] -} else { - // Building in the Swift.org CI system, so rely on local versions of dependencies. - package.dependencies += [ - .package(path: "../swift-cmark-gfm"), - .package(path: "../swift-argument-parser"), - ] -} diff --git a/Tests/MarkdownTests/Visitors/Everything.md b/Tests/MarkdownTests/Visitors/Everything.md index bd810706..e15ed011 100644 --- a/Tests/MarkdownTests/Visitors/Everything.md +++ b/Tests/MarkdownTests/Visitors/Everything.md @@ -13,19 +13,15 @@ > BlockQuote ```swift -func foo() { - let x = 1 -} +func foo() { let x = 1 } ``` - // Is this real code? Or just fantasy? - This is an . --- -An HTML Block. + An HTML Block. This is some

inline html

. diff --git a/Tests/MarkdownTests/Visitors/MarkupRewriterTests.swift b/Tests/MarkdownTests/Visitors/MarkupRewriterTests.swift index 13a41094..975db00b 100644 --- a/Tests/MarkdownTests/Visitors/MarkupRewriterTests.swift +++ b/Tests/MarkdownTests/Visitors/MarkupRewriterTests.swift @@ -12,7 +12,45 @@ import XCTest @testable import Markdown /// A `Document` that has every kind of element in it at least once. -let everythingDocument = Document(parsing: try! String(contentsOf: Bundle.module.url(forResource: "Everything", withExtension: "md")!)) +let everythingDocument = Document(parsing: """ + # Header + + *Emphasized* **strong** `inline code` [link](foo) ![image](foo). + + - this + - is + - a + - list + + 1. eggs + 1. milk + + > BlockQuote + + ```swift + func foo() { + let x = 1 + } + ``` + + // Is this real code? Or just fantasy? + + This is an . + + --- + + + An HTML Block. + + + This is some

inline html

. + + line + break + + soft + break + """) class MarkupRewriterTests: XCTestCase { diff --git a/Tests/MarkdownTests/Visitors/MarkupTreeDumperTests.swift b/Tests/MarkdownTests/Visitors/MarkupTreeDumperTests.swift index edf0514f..d2a588bc 100644 --- a/Tests/MarkdownTests/Visitors/MarkupTreeDumperTests.swift +++ b/Tests/MarkdownTests/Visitors/MarkupTreeDumperTests.swift @@ -14,7 +14,7 @@ import XCTest final class MarkupTreeDumperTests: XCTestCase { func testDumpEverything() { let expectedDump = """ - Document @1:1-39:90 Root #\(everythingDocument.raw.metadata.id.rootId) #0 + Document @1:1-37:6 Root #\(everythingDocument.raw.metadata.id.rootId) #0 ├─ Heading @1:1-1:9 #1 level: 1 │ └─ Text @1:3-1:9 #2 "Header" ├─ Paragraph @3:1-3:65 #3 @@ -52,8 +52,8 @@ final class MarkupTreeDumperTests: XCTestCase { │ └─ ListItem @11:1-12:1 #35 │ └─ Paragraph @11:4-11:8 #36 │ └─ Text @11:4-11:8 #37 "milk" - ├─ BlockQuote @13:1-13:13 #38 - │ └─ Paragraph @13:3-13:13 #39 + ├─ BlockQuote @13:1-13:14 #38 + │ └─ Paragraph @13:3-13:14 #39 │ └─ Text @13:3-13:13 #40 "BlockQuote" ├─ CodeBlock @15:1-19:4 #41 language: swift │ func foo() { @@ -81,12 +81,10 @@ final class MarkupTreeDumperTests: XCTestCase { │ ├─ Text @33:1-33:7 #57 "line" │ ├─ LineBreak #58 │ └─ Text @34:1-34:6 #59 "break" - ├─ Paragraph @36:1-37:6 #60 - │ ├─ Text @36:1-36:5 #61 "soft" - │ ├─ SoftBreak #62 - │ └─ Text @37:1-37:6 #63 "break" - └─ HTMLBlock @39:1-39:90 #64 - + └─ Paragraph @36:1-37:6 #60 + ├─ Text @36:1-36:5 #61 "soft" + ├─ SoftBreak #62 + └─ Text @37:1-37:6 #63 "break" """ print(everythingDocument.debugDescription(options: [.printEverything])) XCTAssertEqual(expectedDump, everythingDocument.debugDescription(options: [.printEverything])) diff --git a/bin/check-source b/bin/check-source index 531ab7b6..632b1183 100755 --- a/bin/check-source +++ b/bin/check-source @@ -49,7 +49,7 @@ for language in swift-or-c bash md-or-tutorial html docker; do reader=head case "$language" in swift-or-c) - exceptions=( -name 'Package*.swift') + exceptions=( -name Package.swift) matching_files=( -name '*.swift' -o -name '*.c' -o -name '*.h' ) cat > "$tmp" <<"EOF" /*