Coder Social home page Coder Social logo

Comments (5)

marijnh avatar marijnh commented on August 23, 2024

I don't quite understand the problem here. If I add a test for the document you show (in attached patch), that content seems to round-trip just fine, without any extra newlines being inserted.

from prosemirror-markdown.

susnux avatar susnux commented on August 23, 2024

I don't quite understand the problem here

It does not happen when using the provided markdown parser, but if happens if you set the parse options / parse rules of paragraphs to preserveWhitespace: true.

e.g. you want to keep the formatting of a markdown file after a roundtrip you need to keep any additional tabs and spaces and also newlines "soft brakes" like:

hello
world

should stay like this after a roundtrip and not result in

hello world

even if this is syntactically the same.

So the previous example results in:

<p>hello<br />
world</p>

which is this prosemirror state: doc(p("hello", br(), "\nworld")).

And that state would currently be serialized as

hello\

world

(note the additional newline).

See the testcase in the PR:

serialize(doc(p(em("foo", br(), "\nbar"))), "*foo\\\nbar*")

from prosemirror-markdown.

marijnh avatar marijnh commented on August 23, 2024

It does not happen when using the provided markdown parser, but if happens if you set the parse options / parse rules of paragraphs to preserveWhitespace: true.

That's a DOM parser option, though. How does that effect Markdown deserializing?

from prosemirror-markdown.

susnux avatar susnux commented on August 23, 2024

As I said I do not use the provided parser, but plain markdown-it as the project uses quite a lot markdown extensions.

So this is only a problem if you use the to_markdown part of this nice project together with custom markdown parsing.
(I can understand if you decide that this is a won't fix)

from prosemirror-markdown.

marijnh avatar marijnh commented on August 23, 2024

Ah, all right. I think this is something you'll have to address in your custom parser then.

from prosemirror-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.