diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c7c9805..ba82cd3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,11 +3,15 @@ name: CI on: push: branches: - - master + - main pull_request: branches: - '*' +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + jobs: build: name: MacOS diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..fa9bde8 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,31 @@ +name: Format + +on: + push: + branches: + - main + +concurrency: + group: format-${{ github.ref }} + cancel-in-progress: true + +jobs: + swift_format: + name: swift-format + runs-on: macos-12 + steps: + - uses: actions/checkout@v3 + - name: Xcode Select + run: sudo xcode-select -s /Applications/Xcode_14.0.1.app + - name: Tap + run: brew tap pointfreeco/formulae + - name: Install + run: brew install Formulae/swift-format@5.7 + - name: Format + run: make format + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Run swift-format + branch: 'main' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 515454d..69efab9 100644 --- a/.gitignore +++ b/.gitignore @@ -69,5 +69,4 @@ fastlane/test_output .DS_Store Packages/* -Package.resolved .swiftpm diff --git a/Html.playground/Contents.swift b/Html.playground/Contents.swift index 380c086..d414f09 100644 --- a/Html.playground/Contents.swift +++ b/Html.playground/Contents.swift @@ -115,28 +115,6 @@ render(unexclaim(document)) ) ) -// Based on https://html.spec.whatwg.org/multipage/grouping-content.html#the-dl-element -let dl_exmaple_with_div: Node = .dl( - .div( - .dt("Last modified time"), - .dd("2004-12-23T23:33Z") - ), - .div( - .dt("Recommended update interval"), - .dd("60s") - ), - .div( - .dt("Authors"), - .dt("Editors"), - .dd("Robert Rothman"), - .dd("Daniel Jackson") - ) -) - -render(dl_exmaple_with_div) - - - /// A function that "redacts" an HTML document by transforming all text nodes /// into █-sequences of characters. func redacted(node: Node) -> Node { diff --git a/Makefile b/Makefile index 363d3e3..47cdfee 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,8 @@ test-linux: --rm \ -v "$(PWD):$(PWD)" \ -w "$(PWD)" \ - swift:5.3 \ - bash -c 'make test-swift' + swift:5.7-focal \ + bash -c 'swift test' test-macos: xcodeproj set -o pipefail && \ diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 0000000..b4b8f7e --- /dev/null +++ b/Package.resolved @@ -0,0 +1,16 @@ +{ + "object": { + "pins": [ + { + "package": "swift-snapshot-testing", + "repositoryURL": "https://github.com/pointfreeco/swift-snapshot-testing.git", + "state": { + "branch": null, + "revision": "cef5b3f6f11781dd4591bdd1dd0a3d22bd609334", + "version": "1.11.0" + } + } + ] + }, + "version": 1 +} diff --git a/Package.swift b/Package.swift index b51013a..a855819 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.3 +// swift-tools-version:5.5 import PackageDescription let package = Package( @@ -17,7 +17,7 @@ let package = Package( targets: ["HtmlSnapshotTesting"]), ], dependencies: [ - .package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.10.0"), + .package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.11.0"), ], targets: [ .target( diff --git a/Sources/Html/ChildOf.swift b/Sources/Html/ChildOf.swift index 4b953a0..6aff8a7 100644 --- a/Sources/Html/ChildOf.swift +++ b/Sources/Html/ChildOf.swift @@ -89,10 +89,11 @@ extension ChildOf where Element == Tag.Dl { } } -// https://html.spec.whatwg.org/multipage/grouping-content.html#the-dl-element extension ChildOf where Element == Tag.Dl { /// The `
` element wraps a group, that is part of a term-description group in a description list (`
` element). /// + /// This is allowed according to the HTML spec: // https://html.spec.whatwg.org/multipage/grouping-content.html#the-dl-element + /// /// - Parameters: /// - attributes: Attributes. /// - content: Child nodes (`
` or `dd` elements). diff --git a/Tests/HtmlTests/ElementsTests.swift b/Tests/HtmlTests/ElementsTests.swift index 32c292f..2dbe966 100644 --- a/Tests/HtmlTests/ElementsTests.swift +++ b/Tests/HtmlTests/ElementsTests.swift @@ -5,12 +5,12 @@ final class ElementsTests: XCTestCase { func testBase64Snapshot() { XCTAssertEqual( """ - -""", + + """, render(.img(base64: "ZnVuY3Rpb25z", type: .image(.png), alt: "", attributes: [.class("fun")])) ) } - + func testXmlRender() { XCTAssertEqual( #""" @@ -21,30 +21,30 @@ final class ElementsTests: XCTestCase { ) ) } - - func testDlwithDiv() { - let dl_exmaple_with_div: Node = .dl( - .div( - .dt("Last modified time"), - .dd("2004-12-23T23:33Z") - ), - .div( - .dt("Recommended update interval"), - .dd("60s") - ), - .div( - .dt("Authors"), - .dt("Editors"), - .dd("Robert Rothman"), - .dd("Daniel Jackson") - ) - ) - - XCTAssertEqual( - """ -
Last modified time
2004-12-23T23:33Z
Recommended update interval
60s
Authors
Editors
Robert Rothman
Daniel Jackson
- """, - render(dl_exmaple_with_div) - ) - } + + func testDiv_InsideDL() { + let doc = Node.dl( + .div( + .dt("Last modified time"), + .dd("2004-12-23T23:33Z") + ), + .div( + .dt("Recommended update interval"), + .dd("60s") + ), + .div( + .dt("Authors"), + .dt("Editors"), + .dd("Robert Rothman"), + .dd("Daniel Jackson") + ) + ) + + XCTAssertEqual( + """ +
Last modified time
2004-12-23T23:33Z
Recommended update interval
60s
Authors
Editors
Robert Rothman
Daniel Jackson
+ """, + render(doc) + ) + } }