Goodbye legacy DokuWiki translators...

This commit is contained in:
2026-05-24 07:32:56 +02:00
parent 025995815d
commit 418cd2fa69
6 changed files with 451 additions and 289 deletions
+18 -9
View File
@@ -421,13 +421,18 @@ func collectLocalPages(sourceDir string, namespaces []string) (map[string]wikiDe
return nil
}
}
indexEntry := pageIndex[pageID]
publicPath := extractWikiPagePublicPath(content)
if publicPath == "" {
publicPath = pageIndex[pageID].PublicPath
publicPath = indexEntry.PublicPath
}
title := strings.TrimSpace(indexEntry.Title)
if title == "" {
title = extractPageTitle(content, pageID)
}
pages[pageID] = wikiDeployPage{
PageID: pageID,
Title: extractPageTitle(content, pageID),
Title: title,
PublicPath: publicPath,
Namespace: namespace,
Content: content,
@@ -1278,13 +1283,17 @@ func extractMarkdownTitle(content string) string {
func extractHTMLTitle(content, fallback string) string {
lower := strings.ToLower(content)
start := strings.Index(lower, "<h1>")
end := strings.Index(lower, "</h1>")
if start >= 0 && end > start {
title := strings.TrimSpace(content[start+len("<h1>") : end])
title = strings.ReplaceAll(title, "\n", " ")
if title != "" {
return html.UnescapeString(stripSimpleTags(title))
for _, tag := range []string{"h1", "h2"} {
open := "<" + tag + ">"
close := "</" + tag + ">"
start := strings.Index(lower, open)
end := strings.Index(lower, close)
if start >= 0 && end > start {
title := strings.TrimSpace(content[start+len(open) : end])
title = strings.ReplaceAll(title, "\n", " ")
if title != "" {
return html.UnescapeString(stripSimpleTags(title))
}
}
}
parts := strings.Split(fallback, ":")