Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown #24

Merged
merged 53 commits into from
Aug 18, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
4a26e3f
add markdown develop
tiechui1994 Jul 13, 2020
a6edcfe
text convert to pdf
tiechui1994 Jul 13, 2020
d571d34
update
tiechui1994 Jul 14, 2020
e78ca4d
build new component
tiechui1994 Jul 15, 2020
35e6e6a
update
tiechui1994 Jul 15, 2020
852e8fc
add header componet
tiechui1994 Jul 16, 2020
37b6d6d
rename file name
tiechui1994 Jul 16, 2020
f7572bb
use re
tiechui1994 Jul 16, 2020
c4831d8
update
tiechui1994 Jul 17, 2020
388bd3c
add regex for md elements
tiechui1994 Jul 17, 2020
49df65e
add new method to regex block
tiechui1994 Jul 18, 2020
36fa19f
use js's markdown library to parse markdown text
tiechui1994 Jul 19, 2020
5db4ef2
update
tiechui1994 Jul 20, 2020
9a7a629
add lex params
tiechui1994 Jul 20, 2020
63d2c5b
update
tiechui1994 Jul 21, 2020
393be1b
update
tiechui1994 Jul 22, 2020
b9c43ae
update
tiechui1994 Jul 23, 2020
95f1477
add regex2 support
tiechui1994 Jul 25, 2020
131e835
update
tiechui1994 Jul 25, 2020
77a0268
add lex
tiechui1994 Jul 25, 2020
e8c42e1
add new test for lex
tiechui1994 Aug 5, 2020
6a698ac
add test for basic markdown
tiechui1994 Aug 7, 2020
de332de
update
tiechui1994 Aug 7, 2020
3266cb3
add list
tiechui1994 Aug 7, 2020
137322b
add more picture type support
tiechui1994 Aug 7, 2020
532f13d
add new picture type
tiechui1994 Aug 8, 2020
26ad5a8
update text component
tiechui1994 Aug 8, 2020
c4b506a
update js script
tiechui1994 Aug 8, 2020
b361ad6
add new content:
tiechui1994 Aug 8, 2020
8a66387
remove unued js file and update markdown
tiechui1994 Aug 9, 2020
d510266
add default picture for image not exist
tiechui1994 Aug 10, 2020
259ba09
add new picture line
tiechui1994 Aug 11, 2020
149aee8
update image auto break
tiechui1994 Aug 11, 2020
54c78dd
update util method
tiechui1994 Aug 11, 2020
eac9cc3
remove redundant code
tiechui1994 Aug 12, 2020
7bbbcd0
add support netest blockquote
tiechui1994 Aug 12, 2020
d796bd2
update
tiechui1994 Aug 12, 2020
3fa57bd
remove js redument code
tiechui1994 Aug 12, 2020
cc44e59
update
tiechui1994 Aug 12, 2020
b1dae13
add raw style validation
tiechui1994 Aug 13, 2020
7c15a43
update
tiechui1994 Aug 13, 2020
93ebb62
update
tiechui1994 Aug 14, 2020
c4264f1
rename lex to token and add some convert function
tiechui1994 Aug 15, 2020
83b5cd4
add lex for convert function
tiechui1994 Aug 15, 2020
2a5cfe5
rebuild regex2
tiechui1994 Aug 15, 2020
9485e02
add regex for 'g' params
tiechui1994 Aug 16, 2020
0ab3f1f
update
tiechui1994 Aug 16, 2020
849b6de
add test fuction
tiechui1994 Aug 16, 2020
3599ecf
add log for js and success to export data from golang js
tiechui1994 Aug 16, 2020
e0b38f4
can convert basic markdown doc
tiechui1994 Aug 17, 2020
6c48f87
redefine token
tiechui1994 Aug 17, 2020
c8cb4a8
update
tiechui1994 Aug 17, 2020
deed1c2
rename dir name
tiechui1994 Aug 18, 2020
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
Prev Previous commit
Next Next commit
add default picture for image not exist
  • Loading branch information
tiechui1994 committed Aug 18, 2020
commit d5102666e11abada1581b701d8e802d1a20faea4
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
module github.com/tiechui1994/gopdf

go 1.14

require (
github.com/signintech/gopdf v0.9.8
golang.org/x/image v0.0.0-20200801110659-972c09e46d76
)
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
github.com/phpdave11/gofpdi v1.0.8 h1:9HRg0Z0qDfWeMU7ska+YNQ13RHxTxqP5KTg/dBl4o7c=
github.com/phpdave11/gofpdi v1.0.8/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/signintech/gopdf v0.9.8 h1:tafWEjYhorfHMl9JT9II43fvf5XhUwrjUKVNwQqqyJQ=
github.com/signintech/gopdf v0.9.8/go.mod h1:MrARAC6LaOgbnV6vrC5885VuoWCXazhAqx8L8zmjYy4=
golang.org/x/image v0.0.0-20200801110659-972c09e46d76 h1:U7GPaoQyQmX+CBRWXKrvRzWTbd+slqeSh8uARsIyhAw=
golang.org/x/image v0.0.0-20200801110659-972c09e46d76/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
6 changes: 4 additions & 2 deletions image.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ type Image struct {

func NewImage(path string, pdf *core.Report) *Image {
if _, err := os.Stat(path); err != nil {
panic(fmt.Sprintf("the path error, %v", path))
path = fmt.Sprintf("/tmp/%v.png", time.Now().Unix())
DrawPNG(path)
}

dstPath := fmt.Sprintf("/tmp/%v.jpeg", time.Now().UnixNano())
Expand Down Expand Up @@ -55,7 +56,8 @@ func NewImageWithWidthAndHeight(path string, width, height float64, pdf *core.Re
}

if _, err := os.Stat(path); err != nil {
panic("the path error")
path = fmt.Sprintf("/tmp/%v.png", time.Now().Unix())
DrawPNG(path)
}

dstPath := fmt.Sprintf("/tmp/%v.jpeg", time.Now().UnixNano())
Expand Down
8 changes: 6 additions & 2 deletions markdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"testing"
"io/ioutil"
"encoding/json"
"bytes"
"fmt"
"log"

"github.com/tiechui1994/gopdf/core"
"bytes"
"fmt"
)

func init() {
Expand Down Expand Up @@ -85,3 +85,7 @@ func TestTokens(t *testing.T) {
fmt.Printf("\n")
}
}

func TestDrawJPEG(t *testing.T) {
DrawPNG("./test.png")
}
23 changes: 16 additions & 7 deletions picture.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"golang.org/x/image/bmp"
"golang.org/x/image/webp"
"golang.org/x/image/tiff"
"math"
)

const (
Expand Down Expand Up @@ -178,8 +179,8 @@ func ConvertTIFF2JPEG(srcPath, dstPath string) (err error) {

func DrawPNG(srcPath string) {
const (
width = 300
height = 500
width = 200
height = 200
)

// 文件
Expand All @@ -188,13 +189,21 @@ func DrawPNG(srcPath string) {

// Image, 进行绘图操作
pngImage := image.NewRGBA(image.Rect(0, 0, width, height))
for y := 0; y < height; y++ {
for x := 0; x < width; x++ {
draw.Draw(pngImage, pngImage.Bounds(), image.White, image.ZP, draw.Src)

pngImage.Set(x, y, color.RGBA{uint8(256 % (x + 1)), uint8(y % 256), uint8((x ^ y) % 256), uint8((x ^ y) % 256)})
}
a, b, c := 5.70, 7.0, 2.2
for p := 0.0; p <= 720.0; p += 0.03125 {
x := int(20*((a-b)*math.Cos(p)+c*math.Cos((a/b-1)*p))) + 100
y := int(20*((a-b)*math.Sin(p)-c*math.Sin((a/b-1)*p))) + 100

pngImage.Set(x, y, color.RGBA{
R: uint8(250),
G: uint8(4),
B: uint8(4),
A: uint8(255),
})
}

// 以png的格式写入文件
// 以 png 的格式写入文件
png.Encode(pngFile, pngImage)
}
215 changes: 215 additions & 0 deletions vendor/golang.org/x/image/cmd/webp-manual-test/main.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions vendor/golang.org/x/image/draw/draw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading