Skip to content

Commit e059d5e

Browse files
authored
Correctly handle *ast.AutoLink nodes in the plainmarkdown function (#361)
* Write the node URL for `AutoLink` nodes * Add changelog entry
1 parent c8e5e1f commit e059d5e

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: BUG FIXES
2+
body: 'generate: fixed a bug where the `plainmarkdown` function did not output plain
3+
URLs'
4+
time: 2024-04-19T15:42:26.250348-04:00
5+
custom:
6+
Issue: "361"

internal/mdplain/renderer.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,12 @@ func (r *TextRender) Render(w io.Writer, source []byte, n ast.Node) error {
6161
return ast.WalkSkipChildren, nil
6262
}
6363
return ast.WalkContinue, nil
64-
case *ast.AutoLink, *extAST.Strikethrough:
64+
case *extAST.Strikethrough:
6565
out.Write(node.Text(source))
6666
return ast.WalkContinue, nil
67+
case *ast.AutoLink:
68+
out.Write(node.URL(source))
69+
return ast.WalkSkipChildren, nil
6770
case *ast.CodeSpan:
6871
out.Write(node.Text(source))
6972
return ast.WalkSkipChildren, nil

internal/mdplain/testdata/markdown.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ These are the elements outlined in John Gruber’s original design document. All
5050

5151
[Relative Link](#Code)
5252

53+
Plain URL: https://www.markdownguide.org
5354

5455
### Image
5556

internal/mdplain/testdata/mdplain.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Horizontal Rule
2323
Link
2424
Markdown Guide https://www.markdownguide.org
2525
Relative Link
26+
Plain URL: https://www.markdownguide.org
2627
Image
2728

2829
Extended Syntax

0 commit comments

Comments
 (0)