Commit graph

54 commits

Author SHA1 Message Date
Simon Ser
4c040ac99e
Merge 8835a2656b into 04410ff159 2025-03-03 10:41:48 +05:30
yuin
d9c03f07f0 Deprecate Node.Text
Node.Text was intended to get a text value from some inline nodes.
A 'text value' of a Text node is clear.

But

- BaseNode had a default implementation of Node.Text
- Lacks of GoDoc description that Node.Text is valid only for
  some inline nodes

So, some users are using Node.Text for BlockNodes.

A 'text value' for a BlockNode is not clear.

e.g. : Text value of a ListNode

- It should be contains list markers?
- What do characters concatinate List items with? newlines? spaces?
- If it contains codeblocks, codeblocks should be fenced or indented?

Now we would like to avoid such ambiguous method.
2024-10-16 20:47:35 +09:00
yuin
dc32f35808 Fix lint errors 2024-06-23 22:09:11 +09:00
yuin
25bdeb0fee Fixes #456 2024-06-23 21:46:17 +09:00
yuin
a590622b15 Fixes #455 2024-06-14 22:05:13 +09:00
movsb
e405d57be0 make SetAttributeString() accept both []byte and string 2024-04-02 20:00:37 +08:00
yuin
9c9003363f Simplify EastAsianLineBreaks 2023-10-28 17:57:55 +09:00
Yusuke Inuzuka
a89ad04c49
Merge pull request #411 from henry0312/update_cond_east_asian_line_breaks
Define line break styles for east asian characters as options
2023-10-28 17:27:21 +09:00
OMOTO Tsukasa
6b3067e7e7 Implements CSS3Draft 2023-10-24 21:54:35 +09:00
yuin
6442ae1259 Fix #416 2023-10-14 18:02:09 +09:00
OMOTO Tsukasa
8c6830d73b fix errors of lints 2023-09-24 15:07:17 +09:00
OMOTO Tsukasa
9d0b1b6bb8 Define EastAsianLineBreaksStyle to specify behavior of line breaking 2023-09-24 14:25:28 +09:00
OMOTO Tsukasa
2367b9ff46 add comments 2023-09-10 15:17:16 +09:00
OMOTO Tsukasa
6cbcfebb71 Add a WorksEvenWithOneSide option to EastAsianLineBreak 2023-09-10 15:08:57 +09:00
OMOTO Tsukasa
6ef9b10a3a Improve line breaking behavior for east asian characters
This commit aims to produce more natural line breaks in the rendered output.
2023-08-27 15:13:49 +09:00
yuin
9b02182dd0 Apply linters 2023-08-15 18:40:41 +09:00
yuin
254b9f8f77 Fix #403, Fix #406 2023-07-23 22:07:27 +09:00
Joe Mooring
c446c414ef Add role to global HTML attributes
Closes #357
2023-01-27 11:07:07 -08:00
yuin
1dd67d5750 Add CJK extension 2022-09-25 03:31:14 +09:00
yuin
20df1691ad Fix #321 2022-09-02 20:08:28 +09:00
Vincent Bernat
db82c79f20 Fix SVG mime type (image/svg+xml)
In PR #298, I was using image/svg for the MIME type for SVG image.
This is in fact image/svg+xml. Sorry for that.
2022-07-22 21:26:18 +02:00
Simon Ser
8835a2656b renderer: fix panic on unregistered node kind
Renderers can ignore nodes they aren't interested in. However when a
renderer doesn't register the highest node kind traversing a Markdown
document results in the following panic:

    panic: runtime error: index out of range [1] with length 1

    goroutine 1 [running]:
    github.com/yuin/goldmark/renderer.(*renderer).Render.func2({0x9d8630, 0xc0001237a0}, 0x40?)
    	/home/simon/go/pkg/mod/github.com/yuin/goldmark@v1.4.11/renderer/renderer.go:164 +0xd9
    github.com/yuin/goldmark/ast.walkHelper({0x9d8630, 0xc0001237a0}, 0xc000521a48)
    	/home/simon/go/pkg/mod/github.com/yuin/goldmark@v1.4.11/ast/ast.go:492 +0x34
    github.com/yuin/goldmark/ast.Walk(...)
    	/home/simon/go/pkg/mod/github.com/yuin/goldmark@v1.4.11/ast/ast.go:487
    github.com/yuin/goldmark/renderer.(*renderer).Render(0xc0002d80a0?, {0x9d3b60?, 0xc0000744a0?}, {0xc0002f4580?, 0x281?, 0x2c0?}, {0x9d8630?, 0xc0001237a0?})
    	/home/simon/go/pkg/mod/github.com/yuin/goldmark@v1.4.11/renderer/renderer.go:161 +0x225
    github.com/yuin/goldmark.(*markdown).Convert(0xc0001e1d40, {0xc0002f4580, 0x281, 0x2c0}, {0x9d3b60, 0xc0000744a0}, {0x0, 0x0, 0x0})
    	/home/simon/go/pkg/mod/github.com/yuin/goldmark@v1.4.11/markdown.go:117 +0x10b
    main.renderMarkdown({0xc0002f42c0, 0x281})
    	/home/simon/src/hut/markdown.go:16 +0x97
    main.newListsListCommand.func1(0xc000270280?, {0xc778b8, 0x0, 0x0?})
    	/home/simon/src/hut/lists.go:109 +0x2ee
    github.com/spf13/cobra.(*Command).execute(0xc000270280, {0xc778b8, 0x0, 0x0})
    	/home/simon/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:860 +0x663
    github.com/spf13/cobra.(*Command).ExecuteC(0xc000242c80)
    	/home/simon/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:974 +0x3b4
    github.com/spf13/cobra.(*Command).Execute(...)
    	/home/simon/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:902
    github.com/spf13/cobra.(*Command).ExecuteContext(...)
    	/home/simon/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:895
    main.main()
    	/home/simon/src/hut/main.go:49 +0x30b

Make sure r.nodeRendererFuncs is large enough before trying to access it.
2022-04-04 15:23:03 +02:00
Vincent Bernat
fc877ab357 renderer: image/svg is also safe
When used in an image context, SVG cannot execute scripts, be styled
or fetch additional resources. So, they are as safe as other formats.

When used in a `<a>` tag, it could starts executing JS, but only in
its own context, so it shouldn't be dangerous either.

This raises the question on which image format is dangerous.
2022-04-03 23:34:20 +02:00
Yusuke Inuzuka
67340c7d10
Merge branch 'master' into add-global-attributes 2022-03-20 17:57:16 +09:00
Joe Mooring
8da81dfae2 Add global HTML attributes
Closes #291
2022-03-18 12:39:30 -07:00
Joe Mooring
3563ceb58e Remove obsolete global attributes
Closes #289
2022-03-18 12:01:33 -07:00
yuin
f6e93ffd8f Fix #274, Fix #275 2022-02-08 17:15:15 +09:00
yuin
beafde4b8f #248 - 6 2021-10-16 20:12:16 +09:00
yuin
bc90544cef #248 - 3 2021-10-16 18:56:49 +09:00
yuin
a8ed3c4205 Fix #245 - 9 2021-09-11 12:31:18 +09:00
yuin
7efc483c26 Fix #245 - 5 2021-09-11 11:45:00 +09:00
yuin
351308fb72 Fix #245 - 4 2021-09-11 11:20:50 +09:00
Joe Mooring
3fcf875f9f Add "type" to the list attribute filter
Closes #206
2021-03-31 12:47:01 -07:00
jsteuer
b91c802b8c html escape img alt attribute 2020-07-11 23:54:26 +02:00
pzl
8bdab9449a
documentation typo fixes 2020-02-14 22:03:49 -05:00
zzwx
224bf7d721 Additional attributes render with comments 2019-12-24 19:37:21 -05:00
yuin
7d8bee11ca Closes #33 : Now NodeRenderers render attributes 2019-12-08 18:53:01 +09:00
Yusuke Inuzuka
a47a029d55
Fix typo 2019-12-06 18:23:52 +09:00
Cameron Moore
3dc5ebdb17 Fix golint issues 2019-11-29 13:31:28 -06:00
Yusuke Inuzuka
667a2920f2 Change attribute parsing strategy 2019-08-28 20:29:23 +09:00
Liang Ding
6f6884271d
✏️ Fix typos 2019-08-07 18:15:09 +08:00
yuin
883918a85c Fix bugs found in fuzzing 2019-07-18 18:01:01 +09:00
yuin
05645dd3c4 Add String node 2019-05-30 16:07:04 +09:00
yuin
2ddc99baff Add extension tests, Fix bugs in extensions 2019-05-16 19:46:36 +09:00
yuin
1963434c50 Fix some vet errors, Improve attributes on ATXHeadings 2019-05-16 12:37:49 +09:00
yuin
d9164d2556 Rename options names 2019-05-06 01:14:17 +09:00
yuin
28b28e34bb Add Typographer extension 2019-05-06 00:53:22 +09:00
yuin
08a89f162a Refactoring 2019-05-05 15:08:50 +09:00
yuin
785421acb4 Add WithAttribute 2019-05-05 13:42:39 +09:00
yuin
45222d6b03 Refactoring 2019-05-04 19:27:13 +09:00