diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 6b506b0..7f00f3a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,12 +28,15 @@ jobs: - name: Build all documentation run: | export TUNA_TEMP_DIR=$(mktemp -d) + git worktree add --no-checkout --detach "$TUNA_TEMP_DIR" origin/transpiled cat enabled.txt | xargs python global/compile.py -v --lang zh -C dom -C tuna - git checkout transpiled - mv $TUNA_TEMP_DIR/* . - - name: Commit changes - run: | - git config --local user.name "GitHub Actions" - git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" - git add *.md - git commit -am "Auto build for $GITHUB_REPOSITORY@${GITHUB_SHA::7}" && git push || echo "No changes to commit" + git -C "$TUNA_TEMP_DIR" add --all --verbose + if git diff --exit-code --quiet --cached; then + echo "No changes to commit." + exit 0 + fi + git -C "$TUNA_TEMP_DIR" \ + -c user.name="GitHub Actions" \ + -c user.email="github-actions[bot]@users.noreply.github.com" \ + commit -m "Auto build for $GITHUB_REPOSITORY@${GITHUB_SHA::7}" + git -C "$TUNA_TEMP_DIR" push --force origin HEAD:transpiled diff --git a/tuna.py b/tuna.py index d1b3c51..a1d1605 100644 --- a/tuna.py +++ b/tuna.py @@ -1,5 +1,6 @@ import os from pathlib import Path +import bs4 outdir = Path(os.environ.get('TUNA_TEMP_DIR', './tuna/')) @@ -7,16 +8,18 @@ def process(html, config, project, *_): + doc = bs4.BeautifulSoup(html, 'html.parser') + for tmpl in doc.find_all('tmpl'): + tmpl.name = "pre" + tmpl.attrs["class"] = tmpl.attrs.get("class", []) + ["z-tmpl"] + html = str(doc) md = f"""--- category: help layout: help mirrorid: {config.get('mirrorid', project)} --- """ + """ - - - - +
@@ -28,12 +31,12 @@ def process(html, config, project, *_):
- - + +
- - + +
@@ -44,6 +47,6 @@ def process(html, config, project, *_): """ - with open(outdir/f'1970-01-01-{config.get("permalink", project)}.md', 'w') as f: + with open(outdir/f'1970-01-01-{config.get("permalink", project)}.html', 'w') as f: f.write(md) return html