Files
gitea/skills/html-export/SKILL.md
T
jiantw83andClaude Opus 5 a0c13f807a feat(gitea): 新增 HTML 匯出與範本風格設定
What:新增 html-export 與 html-style 兩支技能、tools/html-render.sh 與 tools/html-style.sh 兩支工具,以及六種版型乘五種風格的 HTML 範本。

Why:wiki 頁與議題要拿給 Gitea 以外的人看時,只能複製 markdown;不同類型的文件也該有各自的版面,不是每份都長一樣。

How:版型(report、slide、dashboard、spec、timeline、onepager)決定內容怎麼排,風格(minimal、corporate、dark、print、vivid)決定看起來長怎樣,兩者自由搭配。哪一種頁面套哪一組由設定決定:專案的 .jsc/html-styles 優先,其次 $JSC_HOME/html-styles.conf,對不到退 DEFAULT,再對不到才用內建的 report/minimal。產出是單一 HTML 檔,CSS 與腳本全部內嵌。

Who:需要把 wiki 頁或議題寄給客戶、主管或跨團隊同事的人。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-26 09:19:25 +08:00

4.0 KiB


html-export — a wiki page or issue becomes one HTML file

The link is the only input. The output is one file that opens anywhere, with no external asset.

Steps

  1. Link gate. Run tools/gitea-link.sh parse {url}. Exit 3 or no link in the request: stop and report it. Never fall back to the working directory's remote or to a page name the user mentioned in passing. Completion condition: kind is wiki or issue, and repo plus page or index are known.

  2. Work out the kind key — it decides which template applies:

    • wiki page → WIKI:{prefix}, where the prefix is the page name up to the first underscore (ANALYZE_D3F1A2B0 → WIKI:ANALYZE; a page with no underscore uses the whole name).
    • issue → run tools/issue.sh labels-of {repo} {index} and try ISSUE:{label} for each label in order; the first one tools/html-style.sh get answers with source project or global wins. No label matches: use ISSUE:DEFAULT.

    Completion condition: exactly one kind key is chosen, and you can say which label or prefix produced it.

  3. Run tools/html-style.sh get {key}. It always prints layout<TAB>style<TAB>source. Read the third column and report it: project or global means the user configured this kind; default means it fell back to the DEFAULT row; builtin means nothing is configured at all and report/minimal was used. For default and builtin, tell the user in one line that jsc-gitea:html-style can set this kind's own template. Completion condition: layout, style and source are reported before anything is rendered.

  4. Fetch the content: jsc-gitea:wiki wiki-get for a page, or tools/issue.sh title plus tools/issue.sh body for an issue. Exit 4 (page missing) or an API failure stops the skill with the page name or issue number in the report. Completion condition: the markdown and the document title are in hand.

  5. Prepare the markdown — this step MUST run as a sub agent. Convert [[display|page]] wiki links to absolute URLs from wiki-url; the renderer does not resolve them, so they would ship as literal brackets. Strip personal data — an exported file travels further than the page it came from. Leave everything else exactly as written; this step never rewrites the content. Completion condition: no [[...]] remains, and the diff against the source is limited to link conversion and personal-data removal.

  6. Ask per jsc-ask:ask rules where the file goes, proposing ./.jsc/html/{page-or-issue}.html. State the impact scope: a path inside a repository gets committed unless it is ignored. Completion condition: the user has confirmed one output path.

  7. Render: tools/html-render.sh --markdown {file} --title {title} --layout {layout} --style {style} --source-url {absolute URL} --out {path}. Exit 1 means Gitea's renderer failed — report it and stop, with no half-rendered file left behind. Completion condition: the file exists, and the report names its path, the layout, the style and where that pair came from.

Rules

  • One link, one file. Batch export is a loop the caller runs, not something this skill decides on its own.
  • The rendered file inlines CSS and scripts on purpose: it is usually sent to someone outside Gitea, and an external asset breaks on their machine.
  • The layout and style are never chosen by inspecting the content. The configuration decides, and jsc-gitea:html-style owns the configuration.