Skip to content

Commit

Permalink
Revert "Revert "Bump Swift version (#4)" (#11)"
Browse files Browse the repository at this point in the history
This reverts commit c061d9f.
  • Loading branch information
Kyle-Ye authored and QuietMisdreavus committed Nov 10, 2021
1 parent 019b480 commit 1d2f926
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 53 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -10,3 +10,5 @@
/.build
/Packages
/*.xcodeproj
.swiftpm
Package.resolved
16 changes: 12 additions & 4 deletions Package.swift
@@ -1,4 +1,4 @@
// swift-tools-version:4.2
// swift-tools-version:5.3
/*
This source file is part of the Swift.org open source project
Expand All @@ -25,13 +25,21 @@ let package = Package(
targets: [
.target(
name: "Markdown",
dependencies: ["cmark-gfm", "cmark-gfm-extensions", "CAtomic"]),
dependencies: [
"CAtomic",
.product(name: "cmark-gfm", package: "swift-cmark"),
.product(name: "cmark-gfm-extensions", package: "swift-cmark"),
]),
.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"]),
dependencies: ["Markdown"],
resources: [.process("Visitors/Everything.md")]),
.target(name: "CAtomic"),
]
)
Expand Down
64 changes: 64 additions & 0 deletions Package@swift-5.5.swift
@@ -0,0 +1,64 @@
// 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"),
]
}
8 changes: 6 additions & 2 deletions Tests/MarkdownTests/Visitors/Everything.md
Expand Up @@ -13,15 +13,19 @@
> BlockQuote
```swift
func foo() { let x = 1 }
func foo() {
let x = 1
}
```

// Is this real code? Or just fantasy?

This is an <topic://autolink>.

---

<a href="foo.png">
An HTML Block.
An HTML Block.
</a>

This is some <p>inline html</p>.
Expand Down
40 changes: 1 addition & 39 deletions Tests/MarkdownTests/Visitors/MarkupRewriterTests.swift
Expand Up @@ -12,45 +12,7 @@ import XCTest
@testable import Markdown

/// A `Document` that has every kind of element in it at least once.
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 <topic://autolink>.
---
<a href="foo.png">
An HTML Block.
</a>
This is some <p>inline html</p>.
line
break
soft
break
""")
let everythingDocument = Document(parsing: try! String(contentsOf: Bundle.module.url(forResource: "Everything", withExtension: "md")!))


class MarkupRewriterTests: XCTestCase {
Expand Down
16 changes: 9 additions & 7 deletions Tests/MarkdownTests/Visitors/MarkupTreeDumperTests.swift
Expand Up @@ -14,7 +14,7 @@ import XCTest
final class MarkupTreeDumperTests: XCTestCase {
func testDumpEverything() {
let expectedDump = """
Document @1:1-37:6 Root #\(everythingDocument.raw.metadata.id.rootId) #0
Document @1:1-39:90 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
Expand Down Expand Up @@ -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:14 #38
│ └─ Paragraph @13:3-13:14 #39
├─ BlockQuote @13:1-13:13 #38
│ └─ Paragraph @13:3-13:13 #39
│ └─ Text @13:3-13:13 #40 "BlockQuote"
├─ CodeBlock @15:1-19:4 #41 language: swift
│ func foo() {
Expand Down Expand Up @@ -81,10 +81,12 @@ 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"
├─ 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
<!-- Copyright (c) 2021 Apple Inc and the Swift Project authors. All Rights Reserved. -->
"""
print(everythingDocument.debugDescription(options: [.printEverything]))
XCTAssertEqual(expectedDump, everythingDocument.debugDescription(options: [.printEverything]))
Expand Down
2 changes: 1 addition & 1 deletion bin/check-source
Expand Up @@ -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"
/*
Expand Down

0 comments on commit 1d2f926

Please sign in to comment.