-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7075cc
commit 65e1ff9
Showing
17 changed files
with
227 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule data
updated
12 files
+21 −0 | CHANGELOG.md | |
+0 −195 | css/at-rules.json | |
+2 −2 | css/functions.json | |
+6 −37 | css/properties.json | |
+3 −4 | css/properties.schema.json | |
+0 −18 | css/selectors.json | |
+2 −2 | css/syntaxes.json | |
+9 −9 | css/types.json | |
+25 −24 | docs/updating_css_json.md | |
+14 −24 | l10n/css.json | |
+1 −1 | package-lock.json | |
+1 −1 | package.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Submodule interactive-examples
updated
11 files
Submodule original-content
updated
94 files
5 changes: 4 additions & 1 deletion
5
...eprocessors/src/helpers/get_section_id.go → revamp/helpers/get_section_id.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package main | ||
|
||
import ( | ||
"strings" | ||
"webdoky3/revamp/helpers" | ||
|
||
"github.com/PuerkitoBio/goquery" | ||
) | ||
|
||
func fixCyrillicIds(doc *goquery.Document) error { | ||
doc.Find("[id]").Each(func(i int, selection *goquery.Selection) { | ||
id, _ := selection.Attr("id") | ||
// if id has a cyrillic letter | ||
if strings.ContainsAny(id, "абвгдеєжзиіїйклмнопрстуфхцчшщьюя") { | ||
fixedId := helpers.GetSectionId(id) | ||
selection.SetAttr("id", fixedId) | ||
} | ||
}) | ||
// Also fix Cyrillic anchor links | ||
doc.Find("a[href^=\"#\"]").Each(func(i int, selection *goquery.Selection) { | ||
href, _ := selection.Attr("href") | ||
id := strings.TrimPrefix(href, "#") | ||
// if id has a cyrillic letter | ||
if strings.ContainsAny(id, "абвгдеєжзиіїйклмнопрстуфхцчшщьюя") { | ||
fixedId := helpers.GetSectionId(id) | ||
selection.SetAttr("href", "#"+fixedId) | ||
} | ||
}) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"strings" | ||
"webdoky3/revamp/helpers" | ||
|
||
"github.com/PuerkitoBio/goquery" | ||
"golang.org/x/exp/slices" | ||
"golang.org/x/net/html" | ||
) | ||
|
||
func fixDefinitions(doc *goquery.Document) error { | ||
lis := doc.Find("li") | ||
pseudoDls := []*goquery.Selection{} | ||
lis.Each(func(i int, li *goquery.Selection) { | ||
// if li starts with ": " | ||
if !strings.HasPrefix(li.Text(), ": ") { | ||
return | ||
} | ||
pseudoDl := li.Closest("ul").Parent().Closest("ul") | ||
if !slices.Contains(pseudoDls, pseudoDl) { | ||
pseudoDls = append(pseudoDls, pseudoDl) | ||
} | ||
}) | ||
for _, pseudoDl := range pseudoDls { | ||
dlHtml := "" | ||
pseudoDefinitions := pseudoDl.ChildrenFiltered("li") | ||
successMarker := true | ||
pseudoDefinitions.Each(func(i int, pseudoDefinition *goquery.Selection) { | ||
term := "" | ||
definition := "" | ||
htmlCode, err := pseudoDefinition.Html() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
pseudoDefinition.Contents().Each(func(i int, selection *goquery.Selection) { | ||
nodeHtml, err := selection.Html() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
if nodeHtml == "" { | ||
nodeHtml = selection.Text() | ||
} | ||
log.Printf("selection, %d: %s", selection.Nodes[0].Type, nodeHtml) | ||
if selection.Nodes[0].Type != html.ElementNode || !selection.Is("ul") { | ||
term += nodeHtml | ||
} else { | ||
selection.Find("ul > li").Each(func(i int, li *goquery.Selection) { | ||
li.AddSelection(li.Find("p")).Each(func(i int, textContainer *goquery.Selection) { | ||
if strings.HasPrefix(textContainer.Text(), ": ") { | ||
textHtml, err := textContainer.Html() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
textContainer.SetHtml(strings.TrimPrefix(textHtml, ": ")) | ||
} | ||
}) | ||
|
||
liHtml, err := li.Html() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
definition += liHtml | ||
}) | ||
} | ||
}) | ||
if term == "" { | ||
log.Println("term is empty. " + htmlCode) | ||
successMarker = false | ||
} | ||
if definition == "" { | ||
log.Println("definition is empty. " + htmlCode) | ||
successMarker = false | ||
} | ||
dlHtml += "<dt id=\"" + helpers.GetSectionId(term) + "\">" + term + "</dt><dd>" + definition + "</dd>" | ||
}) | ||
dlHtml = "<dl>" + dlHtml + "</dl>" | ||
if !successMarker { | ||
continue | ||
} | ||
// Replace pseudoDl with dlHtml | ||
pseudoDl.ReplaceWithHtml(dlHtml) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
|
||
"github.com/PuerkitoBio/goquery" | ||
) | ||
|
||
func main() { | ||
err := filepath.Walk("book/uk/docs", func(path string, info os.FileInfo, err error) error { | ||
if err != nil { | ||
return err | ||
} | ||
if info.Name() != "index.html" { | ||
return nil | ||
} | ||
log.Println(path) | ||
htmlCode, err := os.ReadFile(path) | ||
if err != nil { | ||
return err | ||
} | ||
page, err := goquery.NewDocumentFromReader(strings.NewReader(string(htmlCode))) | ||
if err != nil { | ||
return err | ||
} | ||
err = fixDefinitions(page) | ||
if err != nil { | ||
return err | ||
} | ||
err = fixCyrillicIds(page) | ||
if err != nil { | ||
return err | ||
} | ||
// Write page back into file | ||
html, err := page.Html() | ||
if err != nil { | ||
return err | ||
} | ||
err = os.WriteFile(path, []byte(html), 0644) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
}) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.