From 81bf1a2c3c5e2065dbce5130512b71a7d2975b8c Mon Sep 17 00:00:00 2001 From: Makoto Emura Date: Sun, 29 Oct 2023 22:35:06 -0700 Subject: [PATCH] Fix search results --- _static/searchtools.js | 5 ++- codeblock-format/main.go | 67 ---------------------------------------- 2 files changed, 2 insertions(+), 70 deletions(-) delete mode 100644 codeblock-format/main.go diff --git a/_static/searchtools.js b/_static/searchtools.js index 4350579a8..24d76a344 100644 --- a/_static/searchtools.js +++ b/_static/searchtools.js @@ -66,7 +66,6 @@ const _displayItem = (item, searchTerms, highlightTerms) => { const docFileSuffix = DOCUMENTATION_OPTIONS.FILE_SUFFIX; const docLinkSuffix = DOCUMENTATION_OPTIONS.LINK_SUFFIX; const showSearchSummary = DOCUMENTATION_OPTIONS.SHOW_SEARCH_SUMMARY; - const contentRoot = document.documentElement.dataset.content_root; const [docName, title, anchor, descr, score, _filename] = item; @@ -79,11 +78,11 @@ const _displayItem = (item, searchTerms, highlightTerms) => { if (dirname.match(/\/index\/$/)) dirname = dirname.substring(0, dirname.length - 6); else if (dirname === "index/") dirname = ""; - requestUrl = contentRoot + dirname; + requestUrl = dirname; linkUrl = requestUrl; } else { // normal html builders - requestUrl = contentRoot + docName + docFileSuffix; + requestUrl = docName + docFileSuffix; linkUrl = docName + docLinkSuffix; } let linkEl = listItem.appendChild(document.createElement("a")); diff --git a/codeblock-format/main.go b/codeblock-format/main.go deleted file mode 100644 index 3f0e5077e..000000000 --- a/codeblock-format/main.go +++ /dev/null @@ -1,67 +0,0 @@ -package main - -import ( - "fmt" - "io/fs" - "os" - "os/exec" - "path/filepath" - "strings" -) - -func getWalkFunc() fs.WalkDirFunc { - return func(path string, d fs.DirEntry, err error) error { - if err != nil { - return err - } - - if d.IsDir() || d.Name() == "index.md" { - return nil - } - - b, err := os.ReadFile(path) - if err != nil { - return err - } - text := string(b) - - startIndex := strings.Index(text, "typedef") - if startIndex < 0 { - panic("not found") - } - - endIndex := strings.Index(text, ";\r\n\r\n##") - if endIndex < 0 { - panic("not found") - } - endIndex += 1 - - codeBlock := text[startIndex:endIndex] - codeBlock = strings.NewReplacer( - "\\", "", - "\r\n\r\n", "\n", - "\u00a0", " ", - ).Replace(codeBlock) - - command := exec.Command("clang-format", "--style={BasedOnStyle: LLVM, UseTab: ForIndentation, IndentWidth: 4, TabWidth: 4, AlignTrailingComments: false, PointerAlignment: Left}") - command.Stdin = strings.NewReader(codeBlock) - formatted, err := command.Output() - if err != nil { - return err - } - - parts := []string{text[:startIndex], "```\n", string(formatted), "\n```", text[endIndex:]} - newText := strings.Join(parts, "") - - return os.WriteFile(path, []byte(newText), 0666) - } -} - -func main() { - for _, language := range []string{"en", "ja", "ko", "zh-cn", "zh-tw"} { - path := fmt.Sprintf(`C:\Users\MakotoEmura\Documents\emeditor-help\%s\plugin\structure`, language) - if err := filepath.WalkDir(path, getWalkFunc()); err != nil { - panic(err) - } - } -}