GithubHelp home page GithubHelp logo

Comments (3)

arvinio avatar arvinio commented on August 16, 2024 2

@rexxars

Sorry for not responding to this earlier. Life, and such.

Can't seem to reproduce this?

<ReactMarkdown
  source="Espen *initiated* this, but has had several **contributors**",
  allowedTypes={['Text', 'Paragraph']},
  unwrapDisallowed
/>

Renders:

<p>Espen initiated this, but has had several contributors</p>

Emphasis and Strong are not part of the allowed types, but the text node children are unwrapped.

If you have a reproducible test case, please comment and I'll reopen.

Just pitching in to let you know that I'm experiencing a similar problem.
Version 4.0.6.

Problem: If my source starts with 4 whitespaces, it will be treated as code and disappear.

Eg.

<ReactMarkdown
  source="    Test sentence.",
  allowedTypes={['Text', 'Paragraph']},
  unwrapDisallowed
/>

Expected output:

<p>Test sentence</p>

Actual Output:

<p></p>

My dirty fix:

<ReactMarkdown
  source={source}
  allowedTypes={['text', 'paragraph', 'code']}
  renderers={{code: () => source}}
  unwrapDisallowed
/>

Returns the expected output.

from react-markdown.

rexxars avatar rexxars commented on August 16, 2024

Sorry for not responding to this earlier. Life, and such.

Can't seem to reproduce this?

<ReactMarkdown
  source="Espen *initiated* this, but has had several **contributors**",
  allowedTypes={['Text', 'Paragraph']},
  unwrapDisallowed
/>

Renders:

<p>Espen initiated this, but has had several contributors</p>

Emphasis and Strong are not part of the allowed types, but the text node children are unwrapped.

If you have a reproducible test case, please comment and I'll reopen.

from react-markdown.

ajbeaven avatar ajbeaven commented on August 16, 2024

Just getting around to playing around with this project again, hence the slow response. It still seems to occur in v2.4.2. Apologies, I should have added my test case to the OP.

<ReactMarkdown 
  source="_You_ want to tell me, and I have no objection to hearing it."
  containerTagName="span"
  unwrapDisallowed={true}
  allowTypes={['Emph']}
  escapeHtml={true} 
/>

Renders (incorrectly):

<span>
  <p>
    <em>You</em> want to tell me, and I have no objection to hearing it.”
  </p>
</span>

I wouldn't expect that the <p> tags would be there as I have not explicitly allowed Paragraph in allowTypes.

Instead, I have to accomplish this like so:

<ReactMarkdown 
  source="_You_ want to tell me, and I have no objection to hearing it."
  containerTagName="span"
  unwrapDisallowed={true}
  disallowedTypes={['Paragraph']}
  escapeHtml={true} 
/>

Renders (correctly):

<span>
    <em>You</em> want to tell me, and I have no objection to hearing it.”
</span>

Using allowTypes is a far safer approach so I'd much prefer to use that if I can.

from react-markdown.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.