Code Monkey home page Code Monkey logo

Comments (10)

quantizor avatar quantizor commented on August 30, 2024 1

from markdown-to-jsx.

quantizor avatar quantizor commented on August 30, 2024

Hmm, you mean using the compiler in this library for all createElement if the sole child is a string?

from markdown-to-jsx.

quantizor avatar quantizor commented on August 30, 2024

Ah nvm I understand. This appears to be a bug.

from markdown-to-jsx.

quantizor avatar quantizor commented on August 30, 2024

Looking into this further, it's a tough one. We're currently parsing the contents of html blocks as inline unless another HTML tag is detected. If we change that behavior, the whitespace of the HTML starts to matter.

For instance, if a nested HTML tag has 4 spaces in front of it, that technically makes it an indented code block. Things get progressively more complex from there with the various edge cases and now having to start being aware of what whitespace is worth paying attention to and what should be discarded...

This is one spot where the GFM markdown spec is somewhat incompatible with arbitrary HTML. I'm not sure there's a solution that will work for all use cases, so my inclination is to leave things as-is or disallow indented code blocks inside arbitrary HTML, which might be surprising. But, then again, block syntax didn't work inside this context before so it would be more of a partial mitigation I guess.

from markdown-to-jsx.

pravdomil avatar pravdomil commented on August 30, 2024

my inclination is to leave things as-is

you meant leave it to render 4 space indents as code blocks in any cases?

from markdown-to-jsx.

quantizor avatar quantizor commented on August 30, 2024

Yup. You can see the PR I made which fixes this use case, but it just introduces a new edge case of intentional indented code blocks not working inside HTML since we have to choose.

That being said, I’m open to merging the PR since HTML in markdown is a hack as-is and just add a note somewhere describing caveats.

from markdown-to-jsx.

pravdomil avatar pravdomil commented on August 30, 2024

yes that's what I would do and what others do (try stackedit.io)

from markdown-to-jsx.

ivan-kleshnin avatar ivan-kleshnin commented on August 30, 2024

Is there a way to disable this behavior? I need the MD syntax to stay untouched inside my component:

<MyOwnSyntax>
  * Foo
  * Bar
  * Baz
  
  **test**
</MyOwnSyntax>

It's get parsed to ul before MyOwnSyntax component gets a chance to handle it.

Tbh. nested markdown is kinda an anti-pattern and it's not enabled by default (if supported at all) in any other MD parser. Why? Well MD is whitespace sensitive and HTML is not. The mix of two mutually exclusive paradigms is basically a recipe for endless bugs and edge cases.

It's not limited to code blocks by far. Nested lists are whitespace sensitive.

this kind of title
--

is whitespace sensitive. And so on and so forth... :(

from markdown-to-jsx.

quantizor avatar quantizor commented on August 30, 2024

from markdown-to-jsx.

ivan-kleshnin avatar ivan-kleshnin commented on August 30, 2024

Each of them will add two lines to MD content. And I'll have multiple cases like this per file:

<Quiz>
* Option-1
* Option-2
* Option-3
</Quiz>

<Quiz>
* Option-1
* Option-2
* Option-3
</Quiz>

vs

<Quiz>
'''
* Option-1
* Option-2
* Option-3
'''
</Quiz>

<Quiz>
'''
* Option-1
* Option-2
* Option-3
'''
</Quiz>

– quite a burden.

from markdown-to-jsx.

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.