一个用于 Publish 的 PublishingStep
,它使用 SwiftSoup 很好地格式化你网站的 HTML。
要安装此步骤,请将其作为依赖项添加到你的 Package.swift
文件中
let package = Package(
...
dependencies: [
...
.package(url: "https://github.com/john-mueller/TidyHTMLPublishStep", from: "0.1.0")
],
targets: [
.target(
...
dependencies: [
...
"TidyHTMLPublishStep"
]
)
]
...
)
然后在你想使用它的地方导入 TidyHTMLPublishStep
。
tidyHTML(withIndentation:)
步骤应该在 HTML 生成之后插入到你的发布流程中。 如果省略该参数,则默认缩进为一个空格。
import TidyHTMLPublishStep
...
try DeliciousRecipes().publish(using: [
...
.generateHTML(withTheme: .foundation),
...
.tidyHTML(indentedBy: .spaces(4))
...
])
此包还提供了 Website.publish(withTheme:...:additionalSteps:...)
方法的另一种便捷 API,用 preGenerationSteps
和 postGenerationSteps
替换了 additionalSteps
。tidyHTML
步骤应该传递给 postGenerationSteps
参数
import TidyHTMLPublishStep
...
try DeliciousRecipes().publish(
withTheme: theme,
postGenerationSteps: [
.tidyHTML()
]
)