Coder Social home page Coder Social logo

Comments (9)

marijnh avatar marijnh commented on July 21, 2024 1

And done!

from prosemirror-markdown.

DouweM avatar DouweM commented on July 21, 2024

@marijnh Can you please share some thoughts on how you would implement this?

In the PR mentioned above, you suggested "giving the function that produces the delimiters access to the inline node(s) that the mark applies to."

If I'm understanding correctly, that would mean that when we come across a new mark, we immediately look ahead to find all the following nodes that mark applies to, so we can pass these to the before function, and we'd keep track of them somehow so we can also pass them to the after function later. The functions would then look at the text content of these nodes, and compare it to the mark's src, to determine how to render the link.

Assuming we don't want to make the implementation of this node-tracking too specific to links, how do you imagine us keeping track of these nodes across nested and overlapping marks?

from prosemirror-markdown.

marijnh avatar marijnh commented on July 21, 2024

Hm, good question. I think the most reasonable way to support this without adding a lot of complexity or expensive node-enumerating for every mark is to pass the context fragment and index to the callbacks that create the open/close strings. I should have used that for backtick counting as well, I suppose, but unfortunately didn't, so now for backwards compat the interface got kind of clumsy, but that's survivable. Does attached patch look reasonable to you?

from prosemirror-markdown.

marijnh avatar marijnh commented on July 21, 2024

Oh, hold on, I never released that backtick patch yet, so I can still break compatibility!

from prosemirror-markdown.

marijnh avatar marijnh commented on July 21, 2024

That's better. Let me know if these work for you, and I'll release them.

from prosemirror-markdown.

DouweM avatar DouweM commented on July 21, 2024

@marijnh Thanks! The behavior is exactly what I was looking for, so in that sense they certainly work for me.

I still somewhat prefer my own approach at generic support for dynamic delimiters, because it's easier to write before/after functions that deal with text content, than with parent and index, and we don't end up with a text argument that's only provided in some cases (escape: false), but not all, but ultimately that doesn't matter so much because few people will be adding their own marks with dynamic behavior anyway. I also think the logic around expelEnclosingWhitespace is a lot easier to understand in my version than the current master, but that may just be me.

Either way, if you release a new version with the patches you've added, I can move forward with https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22797 and I'll be very happy!

from prosemirror-markdown.

marijnh avatar marijnh commented on July 21, 2024

we don't end up with a text argument that's only provided in some cases

Since the latest patch, that's no longer the case.

I've released this as 1.3.0

from prosemirror-markdown.

DouweM avatar DouweM commented on July 21, 2024

@marijnh Perfect, thank you!

from prosemirror-markdown.

marijnh avatar marijnh commented on July 21, 2024

Hold on, I messed something up. Re-doing the release

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.