Skip to content
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

Fix/4459/excerpt formatting ignored #9716

Merged
merged 28 commits into from Nov 27, 2018
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
505a12a
extract markdownNodeAST function
nadrane Nov 5, 2018
099fcd0
use async/await better
nadrane Nov 5, 2018
dea318a
delete unncessary promise to make code more readable
nadrane Nov 5, 2018
87a421d
extract remark target parameter
nadrane Nov 5, 2018
af59b30
update tests and return html excerpt
nadrane Nov 5, 2018
385f2ab
update snapshots
nadrane Nov 5, 2018
1613bbe
begin refactoring code to grab exerpts in the case where no separator…
nadrane Nov 6, 2018
b431269
make headway on ast cloning
nadrane Nov 6, 2018
7b40c31
abandon generalizing preorder traversal. tree duplication works
nadrane Nov 6, 2018
4a31459
pruning mostly works
nadrane Nov 6, 2018
440db7a
get the complicated test expectation correct
nadrane Nov 9, 2018
c7b9cdd
rename complicated test
nadrane Nov 9, 2018
cdc2324
refactor out tree cloning
nadrane Nov 9, 2018
15932e7
make progress towards pruning last text node
nadrane Nov 9, 2018
235daa2
tests passing
nadrane Nov 10, 2018
830e6fc
don't invoke plugin functions a second time if excerpt_separator used
nadrane Nov 10, 2018
76037bf
code works
nadrane Nov 10, 2018
97cfabb
migrate to excerpt and exerptHTML fields
nadrane Nov 13, 2018
014ab92
merge master
nadrane Nov 25, 2018
9fc3aa2
print graphql errors properly
nadrane Nov 25, 2018
df3dcf2
excerpt printing in html
nadrane Nov 25, 2018
2249f7c
more progress
nadrane Nov 25, 2018
4e4c498
final changes to excerpt separator handling
nadrane Nov 27, 2018
64152c7
use enum type for format arg
nadrane Nov 27, 2018
4db7c57
undo accidental jest config changes
nadrane Nov 27, 2018
e755e9b
update README
nadrane Nov 27, 2018
a8c1f05
Merge branch 'master' into fix/4459/excerpt-formatting-ignored
nadrane Nov 27, 2018
dc120d9
Update README.md
DSchau Nov 27, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -55,6 +55,42 @@ Object {
}
`;

exports[`Excerpt is generated correctly from schema given an html format, it correctly maps nested markdown to html 1`] = `
Object {
"excerpt": "<p>Where oh <a><em>where</em></a> <strong><em>is</em></strong> that pony?</p>",
"frontmatter": Object {
"title": "my little pony",
},
}
`;

exports[`Excerpt is generated correctly from schema given an html format, it correctly maps nested markdown to html 2`] = `
Object {
"excerpt": "<p>Where oh <a><em>where</em></a> <strong><em>is</em></strong> that pony?</p>",
"frontmatter": Object {
"title": "my little pony",
},
}
`;

exports[`Excerpt is generated correctly from schema given an html format, it prunes large excerpts 1`] = `
Object {
"excerpt": "<p>Where oh <a><em>where</em></a> <strong><em>is</em></strong> that pony?</p>",
"frontmatter": Object {
"title": "my little pony",
},
}
`;

exports[`Excerpt is generated correctly from schema html format correctly transforms nested markdown into html 1`] = `
Object {
"excerpt": "<p>Where oh <a><em>where</em></a> <strong><em>is</em></strong> that pony?</p>",
"frontmatter": Object {
"title": "my little pony",
},
}
`;

exports[`Links are correctly prefixed correctly prefixes links 1`] = `
Object {
"html": "<p>This is <a href=\\"/prefix/path/to/page1\\">a link</a>.</p>
Expand Down
67 changes: 67 additions & 0 deletions packages/gatsby-transformer-remark/src/__tests__/extend-node.js
Expand Up @@ -237,6 +237,73 @@ In quis lectus sed eros efficitur luctus. Morbi tempor, nisl eget feugiat tincid
expect(node.excerpt.length).toBe(50)
}
)

bootstrapTest(
`given an html format, it correctly maps nested markdown to html`,
`---
title: "my little pony"
date: "2017-09-18T23:19:51.246Z"
---

Where oh [*where*](nick.com) **_is_** that pony?`,
`excerpt(format: "html")
frontmatter {
title
}
`,
node => {
expect(node).toMatchSnapshot()
expect(node.excerpt).toMatch(
`<p>Where oh <a><em>where</em></a> <strong><em>is</em></strong> that pony?</p>`
)
}
)

bootstrapTest(
`given an html format, it prunes large excerpts`,
`---
title: "my little pony"
date: "2017-09-18T23:19:51.246Z"
---

Where oh where is that pony? Is he in the stable or down by the stream?`,
`excerpt(format: "html", pruneLength: 50)
frontmatter {
title
}
`,
node => {
// expect(node).toMatchSnapshot()
expect(node.excerpt).toMatch(
`<p>Where oh where is that pony? Is he in the stable…</p>`
)
}
)

bootstrapTest(
`given an html format, it respects the excerpt_separator`,
`---
title: "my little pony"
date: "2017-09-18T23:19:51.246Z"
---

Where oh where is my little pony?
<!-- end -->
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi auctor sit amet velit id facilisis. Nulla viverra, eros at efficitur pulvinar, lectus orci accumsan nisi, eu blandit elit nulla nec lectus. Integer porttitor imperdiet sapien. Quisque in orci sed nisi consequat aliquam. Aenean id mollis nisi. Sed auctor odio id erat facilisis venenatis. Quisque posuere faucibus libero vel fringilla.
`,
`excerpt(format: "html", pruneLength: 50)
frontmatter {
title
}
`,
node => {
expect(node).toMatchSnapshot()
expect(node.excerpt).toMatch(
`<p>Where oh where is that pony? Is he in the stable…</p>`
)
},
{ excerpt_separator: `<!-- end -->` }
)
})

describe(`Wordcount and timeToRead are generated correctly from schema`, () => {
Expand Down