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

Markdown not displaying as expected #17

Closed
dderooy opened this issue Dec 19, 2018 · 6 comments
Closed

Markdown not displaying as expected #17

dderooy opened this issue Dec 19, 2018 · 6 comments
Labels
question Further information is requested

Comments

@dderooy
Copy link

dderooy commented Dec 19, 2018

Styles in 'src/global.css.js' are overriding markdown formatting. Markdown lists and headers etc are displaying as plain text. Is there a way to ignore the global style for all markdown content?

ps. great template by the way

@gjhltn
Copy link

gjhltn commented Dec 19, 2018

Im having a similar issue, but (in my case) the markdown isn't being overridden, it's not being transformed.

Steps to reproduce:

  1. gatsby new my-site https://github.com/fabe/gatsby-universal
  2. in (eg) ~/content/home/intro.md add
# Broken :-(

[link](https://www.google.com)
  1. Expected:
<h1>Broken :-(</h1>
<a href="https://www.google.com">link</a>

screenshot 2018-12-19 at 17 08 52

EDIT: poorly chosen example because this is actually inside an h2 tag, but the same problem, occurs everywhere

UPDATE: My mistake - this is expected! Sorry. To get rendered markdown. change the template to

{data.homeJson.content.childMarkdownRemark.html}

@fabe
Copy link
Owner

fabe commented Dec 19, 2018

@dderooy global.css.js is basically just a CSS reset. Feel free to just edit the file, for example add this to the end of the stylesheet:

ul {
  list-style: square;
}

That stylesheet is definitely meant to be overwritten by you 🙂

If you don't want to touch that file, you can also add some rules for that in component stylesheets, for example box.css.js:

export const Container = styled.div`
  padding: 2rem 4rem;
  max-width: 700px;

  ul {
    list-style: square;
  }
`;

Then only the lists inside <Box/> components are being styled!


@gswirrl You can use the HTML by querying for it in the page query and referencing it in the template. I'm not actually using converted markdown on the homepage. For example:

src/pages/about.js
<div
  dangerouslySetInnerHTML={{
    __html: data.aboutJson.content.childMarkdownRemark.html, // <- HTML
  }}
/>

This uses markdown converted to HTML.

src/pages/index.js
<Title as="h2" size="large">
  {data.homeJson.content.childMarkdownRemark.rawMarkdownBody} // <- Raw Markdown, not converted to HTML
</Title>

This is just using raw markdown. You can get the HTML by getting the .html value instead of the .rawMarkdownBody value.

@fabe fabe added the question Further information is requested label Dec 19, 2018
@gjhltn
Copy link

gjhltn commented Dec 19, 2018

@fabe thanks so much for the full reply - id just figured it out and was editing my comment! :-) d'oh!

once again, thank you - love the starter!

@dderooy
Copy link
Author

dderooy commented Dec 19, 2018

@fabe Thank you for the help. I have it displaying properly now 😄 👍

@dderooy dderooy closed this as completed Dec 19, 2018
@fabe
Copy link
Owner

fabe commented Dec 19, 2018

@gswirrl @dderooy Thanks, let me know if anything else comes up! 🙂

@dannycahyo
Copy link

dannycahyo commented Apr 22, 2021

I have the same issues. I've already used HTML to display my markdown file. For example like this :
<div dangerouslySetInnerHTML={{ __html: html }} />
I still can't display the markdown file properly, here is the case. I want to display ## Heading 2, but it just shows Heading 2, which is just plain text.
Besides, I also use Chakra UI.

Can anyone give me the solution, please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants