From 0132bb8147c49abf73ac282980caeb69c24275d4 Mon Sep 17 00:00:00 2001 From: Abhigyan Kumar <44155310+AbhigyanKumar@users.noreply.github.com> Date: Thu, 24 Sep 2020 19:10:37 +0530 Subject: [PATCH] Go syntax Go syntax colouring added. --- doc/tips.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/tips.md b/doc/tips.md index 4e78952..590da12 100644 --- a/doc/tips.md +++ b/doc/tips.md @@ -4,13 +4,13 @@ The `go.net/html` package used by `goquery` requires that the html document is UTF-8 encoded. When you know the encoding of the html page is not UTF-8, you can use the `iconv` package to convert it to UTF-8 (there are various implementation of the `iconv` API, see [godoc.org][iconv] for other options): -``` +```bash $ go get -u github.com/djimenez/iconv-go ``` and then: -``` +```golang // Load the URL res, err := http.Get(url) if err != nil { @@ -51,7 +51,7 @@ You can find a code example using `otto` [in this gist][exotto]. Thanks to githu If all you need is a normal `for` loop over all nodes in the current selection, where `Map/Each`-style iteration is not necessary, you can use the following: -``` +```golang sel := Doc().Find(".selector") for i := range sel.Nodes { single := sel.Eq(i)