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

Code parsed incorrectly in excerpts #10498

Closed
nadrane opened this issue Dec 17, 2018 · 5 comments
Closed

Code parsed incorrectly in excerpts #10498

nadrane opened this issue Dec 17, 2018 · 5 comments
Labels
stale? Issue that may be closed soon due to the original author not responding any more. type: bug An issue or pull request relating to a bug in Gatsby

Comments

@nadrane
Copy link
Contributor

nadrane commented Dec 17, 2018

Description

When excerpts are queried from gatsby-transformer-remark using the format: HTML option, the resulting HTML is not parsed correctly.

The system is returning something like this:

<p>We have an Elasticsearch backed search interface ... <code class="language-text">Joe</code>...  that the user cares about.</p>

The problem is that the code tag is being processed as a text node rather than parsed as part of the HTML syntax tree. This is related to work I did adding the format: HTML option in the first place. I'll try to figure it out.

Steps to reproduce

Make a GraphQL request like the following:

  {
    allMarkdownRemark {
          excerpt(format: HTML)
}
@nadrane
Copy link
Contributor Author

nadrane commented Dec 17, 2018

hmm after a little investigation, I think it might be unrelated to the gatsby-transformer-remark package. I think it might actually be a problem is gatsby-remark-prismjs... I'm going to evaluate that next...

@nadrane
Copy link
Contributor Author

nadrane commented Dec 17, 2018

Alright, just confirmed that my suspicion was correct. The issue appears when gatsby-remark-prismjs is enabled

@nadrane
Copy link
Contributor Author

nadrane commented Dec 17, 2018

It turns out that when we were converted the HTML AST to an HTML string, we were not allowing for raw html input nodes. Basically, any raw HTML node was escaped. The attached PR changes this behavior. Note that this modified behavior aligns with how the resolver for the entire HTML document works

@sidharthachatterjee sidharthachatterjee added the type: bug An issue or pull request relating to a bug in Gatsby label Dec 17, 2018
DSchau pushed a commit that referenced this issue Jan 1, 2019
#10499)

fix issue #10498 

The first commit was to fix some tests that were just totally not working. We weren't correctly passing around all of our pluginOptions.

The second commit added a test that validated that `code` tags worked at all. Mostly a sanity check for me. Doesn't add a ton of value overall.

The third commit the fix.

One thing to note here is that I don't actually have a test for this issue. Off the top of my head, I'm not 100% sure how to test it. Maybe inserting raw HTML into the excerpt and expecting it to not get escaped would work?

EDIT: Just added a test that makes sure we can render raw html in excerpts and replaced the less useful test from before.
gpetrioli pushed a commit to gpetrioli/gatsby that referenced this issue Jan 22, 2019
gatsbyjs#10499)

fix issue gatsbyjs#10498 

The first commit was to fix some tests that were just totally not working. We weren't correctly passing around all of our pluginOptions.

The second commit added a test that validated that `code` tags worked at all. Mostly a sanity check for me. Doesn't add a ton of value overall.

The third commit the fix.

One thing to note here is that I don't actually have a test for this issue. Off the top of my head, I'm not 100% sure how to test it. Maybe inserting raw HTML into the excerpt and expecting it to not get escaped would work?

EDIT: Just added a test that makes sure we can render raw html in excerpts and replaced the less useful test from before.
@gatsbot
Copy link

gatsbot bot commented Feb 7, 2019

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

Thanks for being a part of the Gatsby community! 💪💜

@gatsbot gatsbot bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Feb 7, 2019
@gatsbot
Copy link

gatsbot bot commented Feb 18, 2019

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.

Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.

Thanks again for being part of the Gatsby community!

@gatsbot gatsbot bot closed this as completed Feb 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale? Issue that may be closed soon due to the original author not responding any more. type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

2 participants