用于 Publish 的整洁 HTML 步骤

一个用于 PublishPublishingStep,它使用 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,用 preGenerationStepspostGenerationSteps 替换了 additionalStepstidyHTML 步骤应该传递给 postGenerationSteps 参数

import TidyHTMLPublishStep
...
try DeliciousRecipes().publish(
    withTheme: theme,
    postGenerationSteps: [
        .tidyHTML()
    ]
)