Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize some things. #96

Merged
merged 8 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from 7 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
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -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@v2
- 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/[email protected]
- 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 }}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,4 @@ fastlane/test_output

.DS_Store
Packages/*
Package.resolved
.swiftpm
22 changes: 0 additions & 22 deletions Html.playground/Contents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
16 changes: 16 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -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
}
4 changes: 2 additions & 2 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:5.5
import PackageDescription

let package = Package(
Expand All @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion Sources/Html/ChildOf.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<div>` element wraps a group, that is part of a term-description group in a description list (`<dl>` 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 (`<dl>` or `dd` elements).
Expand Down
58 changes: 29 additions & 29 deletions Tests/HtmlTests/ElementsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ final class ElementsTests: XCTestCase {
func testBase64Snapshot() {
XCTAssertEqual(
"""
<img src="data:image/png;base64,ZnVuY3Rpb25z" alt class="fun">
""",
<img src="data:image/png;base64,ZnVuY3Rpb25z" alt class="fun">
""",
render(.img(base64: "ZnVuY3Rpb25z", type: .image(.png), alt: "", attributes: [.class("fun")]))
)
}

func testXmlRender() {
XCTAssertEqual(
#"""
Expand All @@ -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(
"""
<dl><div><dt>Last modified time</dt><dd>2004-12-23T23:33Z</dd></div><div><dt>Recommended update interval</dt><dd>60s</dd></div><div><dt>Authors</dt><dt>Editors</dt><dd>Robert Rothman</dd><dd>Daniel Jackson</dd></div></dl>
""",
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(
"""
<dl><div><dt>Last modified time</dt><dd>2004-12-23T23:33Z</dd></div><div><dt>Recommended update interval</dt><dd>60s</dd></div><div><dt>Authors</dt><dt>Editors</dt><dd>Robert Rothman</dd><dd>Daniel Jackson</dd></div></dl>
""",
render(doc)
)
}
}