Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@
/.build
/Packages
/*.xcodeproj
.swiftpm
Package.resolved
16 changes: 4 additions & 12 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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"),
]
)
Expand Down
64 changes: 0 additions & 64 deletions Package@swift-5.5.swift

This file was deleted.

8 changes: 2 additions & 6 deletions Tests/MarkdownTests/Visitors/Everything.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <topic://autolink>.

---

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

This is some <p>inline html</p>.
Expand Down
40 changes: 39 additions & 1 deletion Tests/MarkdownTests/Visitors/MarkupRewriterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 <topic://autolink>.

---

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

This is some <p>inline html</p>.

line
break

soft
break
""")


class MarkupRewriterTests: XCTestCase {
Expand Down
16 changes: 7 additions & 9 deletions Tests/MarkdownTests/Visitors/MarkupTreeDumperTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
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: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() {
Expand Down Expand Up @@ -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
<!-- Copyright (c) 2021 Apple Inc and the Swift Project authors. All Rights Reserved. -->
└─ 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]))
Expand Down
2 changes: 1 addition & 1 deletion bin/check-source
Original file line number Diff line number Diff line change
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