Skip to content

Commit

Permalink
Correctly handle *ast.AutoLink nodes in the plainmarkdown function (
Browse files Browse the repository at this point in the history
#361)

* Write the node URL for `AutoLink` nodes

* Add changelog entry
  • Loading branch information
SBGoods committed Apr 19, 2024
1 parent c8e5e1f commit e059d5e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changes/unreleased/BUG FIXES-20240419-154226.yaml
@@ -0,0 +1,6 @@
kind: BUG FIXES
body: 'generate: fixed a bug where the `plainmarkdown` function did not output plain
URLs'
time: 2024-04-19T15:42:26.250348-04:00
custom:
Issue: "361"
5 changes: 4 additions & 1 deletion internal/mdplain/renderer.go
Expand Up @@ -61,9 +61,12 @@ func (r *TextRender) Render(w io.Writer, source []byte, n ast.Node) error {
return ast.WalkSkipChildren, nil
}
return ast.WalkContinue, nil
case *ast.AutoLink, *extAST.Strikethrough:
case *extAST.Strikethrough:
out.Write(node.Text(source))
return ast.WalkContinue, nil
case *ast.AutoLink:
out.Write(node.URL(source))
return ast.WalkSkipChildren, nil
case *ast.CodeSpan:
out.Write(node.Text(source))
return ast.WalkSkipChildren, nil
Expand Down
1 change: 1 addition & 0 deletions internal/mdplain/testdata/markdown.md
Expand Up @@ -50,6 +50,7 @@ These are the elements outlined in John Gruber’s original design document. All

[Relative Link](#Code)

Plain URL: https://www.markdownguide.org

### Image

Expand Down
1 change: 1 addition & 0 deletions internal/mdplain/testdata/mdplain.txt
Expand Up @@ -23,6 +23,7 @@ Horizontal Rule
Link
Markdown Guide https://www.markdownguide.org
Relative Link
Plain URL: https://www.markdownguide.org
Image

Extended Syntax
Expand Down

0 comments on commit e059d5e

Please sign in to comment.