md2html

package module
Version: v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2022 License: AGPL-3.0 Imports: 3 Imported by: 0

README

Go report Go Reference Release License

md2html is a golang library for converting Markdown to HTML.

Install

go get github.com/lcomrade/md2html

Example

package main

import(
	"github.com/lcomrade/md2html"
)

const myMarkdown = `
# Title
Some text here.

*Italic*
**Bold**
~~Strikethrough~~

1. level 1
2. level 1
3. level 1
    1. level 2
    2. level 2
        1. level 3
        2. level 3
`

func main() {
	result := md2html.Convert(myMarkdown)
	println(result)
}

Documentation

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(text string) string

Convert Markdown to HTML.

Headers:

# This is a H1 header
## This is a H2 header
### This is a H3 header
#### This is a H4 header
##### This is a H5 header
###### This is a H6 header

Text style ('*' may be replaced by '_'):

*Italic text*
**Bold text**
***Bold and italic text***
~~Strikethrough text~~

Link and image:

[Example link](https://example.org)
![Alt text](https://example.org/image.png)

Autolink:

admin@example.org
http://example.org
https://example.org
ftp://ftp.mozilla.org
irc://irc.debian.org/debian

Code:

`Code quote`

```
go doc
go tool dist list
go help build
```

Unordered list ('-' may be replaced by '+' or '*'):

  • level 1
  • level 1
  • level 2
  • level 2 ^^^^ (4 spaces)

Numbered list:

  1. level 1
  2. level 1
  3. level 2
  4. level 2 ^^^^ (4 spaces)
Example
package main

import (
	"fmt"
	"github.com/lcomrade/md2html"
)

func main() {
	result := md2html.Convert(`
# Header H1
## Header H2
### Header H3
#### Header H4
##### Header H5
###### Header H6

- *Italic* and _Italic_
- **Bold** and __Bold__
- ~~Strikethrough~~

[Example link](https://example.org)

1. level 1
2. level 1
    1. level 2
    2. level 2
`)

	fmt.Println(result)
}
Output:

func ConvertFile

func ConvertFile(path string) (string, error)

Reads a file from the disk and converts it using 'Convert' function.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL