Skip to content

Correctly handle *ast.AutoLink nodes in the plainmarkdown function #361

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

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions .changes/unreleased/BUG FIXES-20240419-154226.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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