Skip to content

Commit

Permalink
Add a converter that finds gist URLs and converts these to gist short…
Browse files Browse the repository at this point in the history
…codes for Hugo

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/ashishb/wp2hugo?shareId=XXXX-XXXX-XXXX-XXXX).
  • Loading branch information
lawrencegripper committed Sep 4, 2024
1 parent b64ec2c commit b2fbdb9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/wp2hugo/internal/hugogenerator/hugo_generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,16 @@ func TestFootnote(t *testing.T) {
const expectedMarkdown = "Some text[^1] with a footnote\n\n[^1]: Here we are: the footnote."
assert.True(t, strings.Contains(hugoPage.Markdown(), expectedMarkdown))
}

func TestMarkdownExtractorWithLink1(t *testing.T) {
const sampleHTMLInput = `<p><a href="https://gist.github.com/lawrencegripper/8e701b0d201e65af0f8bc9b8b0b14207">Gist Link</a></p>`
const expectedMarkdownOutput = `{{< gist lawrencegripper 8e701b0d201e65af0f8bc9b8b0b14207 >}}`

url1, err := url.Parse("https://example.com")
assert.Nil(t, err)
page, err := NewPage(nil, *url1, "author", "Title", nil, false, nil, nil, nil, sampleHTMLInput, nil, nil)
assert.Nil(t, err)
md, err := page.getMarkdown(nil, sampleHTMLInput, nil)
assert.Nil(t, err)
assert.Equal(t, expectedMarkdownOutput, *md)
}

0 comments on commit b2fbdb9

Please sign in to comment.