Documentation
¶
Overview ¶
Package ud provides rewriters for search and replace.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HtmlRewriter ¶
type HtmlRewriter struct {
// contains filtered or unexported fields
}
HtmlRewriter replaces html tags or their content by id.
func NewHtmlRewriter ¶
func NewHtmlRewriter(id string, child bool, fragment []byte) *HtmlRewriter
NewHtmlRewriter returns a html rewriter. The rewriter can be used multiple times.
func (*HtmlRewriter) Rewrite ¶
Rewrite the incoming stream on r and write it to w.
Example (Child) ¶
r := strings.NewReader(` <html> <body> <h1>Title</h1> <div id="ABC">Old content</div> </body> </html> `) hr := NewHtmlRewriter("ABC", true, []byte(`new stuff`)) hr.Rewrite(os.Stdout, r)
Output: <html> <body> <h1>Title</h1> <div id="ABC">new stuff</div> </body> </html>
Example (Element) ¶
r := strings.NewReader(` <html> <body> <h1>Title</h1> <div id="ABC">Old content</div> </body> </html> `) hr := NewHtmlRewriter("ABC", false, []byte(`new stuff`)) hr.Rewrite(os.Stdout, r)
Output: <html> <body> <h1>Title</h1> new stuff </body> </html>
Click to show internal directories.
Click to hide internal directories.