Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertNode ¶
ConvertNode converts a `*html.Node` to a markdown byte slice.
If you have already parsed an HTML page using the `html.Parse()` function from the "golang.org/x/net/html" package then you can pass this node directly to the converter.
Example ¶
package main import ( "fmt" "log" "strings" htmltomarkdown "github.com/JohannesKaufmann/html-to-markdown/v2" "golang.org/x/net/html" ) func main() { input := `<strong>Bold Text</strong>` doc, err := html.Parse(strings.NewReader(input)) if err != nil { log.Fatal(err) } markdown, err := htmltomarkdown.ConvertNode(doc) if err != nil { log.Fatal(err) } fmt.Println(string(markdown)) }
Output: **Bold Text**
func ConvertString ¶
ConvertString converts a html-string to a markdown-string.
Under the hood `html.Parse()` is used to parse the HTML.
Example ¶
package main import ( "fmt" "log" htmltomarkdown "github.com/JohannesKaufmann/html-to-markdown/v2" ) func main() { input := `<strong>Bold Text</strong>` markdown, err := htmltomarkdown.ConvertString(input) if err != nil { log.Fatal(err) } fmt.Println(markdown) }
Output: **Bold Text**
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.