Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* udan-jayanith
* @udan-jayanith
22 changes: 13 additions & 9 deletions FUTURE-CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
## v0.0.1-beta.1
- bug fix: style attribute not get serialized correctly.
## v0.0.0-beta.3 <- current

## v0.0.1
DecodeHeader only serializes only up to head. And return a node with only head and it's child nodes.
* DecodeHeader
## v0.0.0
Delete deletes the branch without connecting sibling nodes.
* Delete

## v0.0.2
QuerySelector takes attribute name and regexp for the value and returns the first node that matches the regexp.
* QuerySelector

Expand All @@ -15,7 +13,7 @@ QuerySelectorAll takes two regexps and returns all nodes that matches the regexp
Closest returns the closest node that matches the className.
* Closest

## v0.0.3
## v0.0.1
AddClass add the given class name to the node.
* AddClass

Expand All @@ -28,10 +26,16 @@ HasClass returns a boolean value specifying whether the node has the specified c
GetClassList returns a map of class names in the specified node.
* GetClassList

## v0.0.4
## v0.0.2
* GetElementById
* GetElementByClassName
* GetElementByTagName
* GetElementsById
* GetElementsByClassName
* GetElementsByTagName
* GetElementsByTagName

## v0.0.3
DecodeHeader only serializes only up to head. And return a node with only head and it's child nodes.
* DecodeOnly
* DecodeOnlyByClassName
* DecodeHeader
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![GoHTML logo](https://raw.githubusercontent.com/udan-jayanith/GoHTML/a4ea865d453ddb3f12d31686193f1d5abde9df3a/assets/media/Transparent%20Black%20version.svg)
![GoHTML logo](https://raw.githubusercontent.com/udan-jayanith/GoHTML/46044619ab943b8ae00301565cc37566d5f2ffa4/assets/media/Black-text%20version.svg)
# GoHTML
A powerful and comprehensive HTML parser and DOM manipulation library for Go, bringing JavaScript-like DOM operations to the Go ecosystem.

Expand Down
Binary file added assets/media/Black-text version.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions assets/media/Black-text version.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/media/Favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions assets/media/Favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/media/Transparent Black version.png
Binary file not shown.
10 changes: 0 additions & 10 deletions assets/media/Transparent Black version.svg

This file was deleted.

Binary file removed assets/media/White version.png
Binary file not shown.
11 changes: 0 additions & 11 deletions assets/media/White version.svg

This file was deleted.

Binary file added assets/media/White-text version.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions assets/media/White-text version.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 16 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
/*
A powerful and comprehensive HTML parser and DOM manipulation library for Go,
A powerful and comprehensive HTML parser and DOM manipulation library for Go,
bringing JavaScript-like DOM operations to the Go ecosystem.
*/
package GoHtml

import (
"fmt"
"regexp"
"strings"
"sync"
)

var (
SyntaxError error = fmt.Errorf("Syntax error")
)

//CreateNode returns a initialized new node.
func CreateNode(tagName string) *Node {
return &Node{
Expand Down Expand Up @@ -67,3 +73,12 @@ func ApplySaveChanges(node *Node){
parentNode.rwMutex.Unlock()
}
}

func isQuote(chr string) bool {
return chr == `"` || chr == `'` || chr == "`"
}

func isDigit(value string) bool {
reg := regexp.MustCompile(`^[\d\.]+$`)
return reg.Match([]byte(value))
}
16 changes: 11 additions & 5 deletions node-tree.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package GoHtml

import (
"strings"
"sync"
)

Expand Down Expand Up @@ -78,6 +79,10 @@ func (node *Node) GetTagName() string{
node.rwMutex.Lock()
defer node.rwMutex.Unlock()

if strings.ToUpper(node.tagName) == DOCTYPEDTD{
return strings.ToUpper(node.tagName)
}

return node.tagName
}

Expand All @@ -86,15 +91,16 @@ func (node *Node) SetTagName(tagName string){
node.rwMutex.Lock()
defer node.rwMutex.Unlock()

node.tagName = tagName
node.tagName = strings.TrimSpace(strings.ToLower(tagName))
}

//GetAttribute returns the specified attribute form the node.
func (node *Node) GetAttribute(attributeName string) string{
//GetAttribute returns the specified attribute value form the node.
func (node *Node) GetAttribute(attributeName string) (string, bool){
node.rwMutex.Lock()
defer node.rwMutex.Unlock()

return node.attributes[attributeName]
v, ok := node.attributes[attributeName]
return v, ok
}

//RemoveAttribute remove or delete the specified attribute.
Expand All @@ -120,7 +126,7 @@ func (node *Node) SetAttribute(attribute, value string){
node.rwMutex.Lock()
defer node.rwMutex.Unlock()

node.attributes[attribute] = value
node.attributes[strings.TrimSpace(attribute)] = strings.TrimSpace(value)
}

//GetText returns text on the node. This does not returns text on it's child nodes. If you also wants child nodes text use GetInnerText method on the node.
Expand Down
Loading