Stacks-Editor icon indicating copy to clipboard operation
Stacks-Editor copied to clipboard

fix(commonmark) nested sub tags getting lost when round-tripping

Open yellis opened this issue 2 years ago • 5 comments

Closes #32

Thus far:

  • Added failing test
  • Fixed issue with sanitizeInlineHtmlTokens to ensure that it doesnt consider a second open tag to be the closing tag for the first matching open tag

@b-kelly from what I was able to determine, this is still failing however, since when it is converted into the prosemirror doc, it becomes a node with the text as the content and sub as the attribute. And seems that it just cant figure out two open tags of the same type.

Looking for advice on where to go from here - assume that I need to add to the prosemirror the ability to recognize this. Does this mean a schema change, to allow a sub to have a child sub? Need to get it recognized both into PM and out of it back to markdown. If there is prior PRs that do this sort of thing that I can study, would appreciate it. Can talk about this in our scheduled time tomorrow.

yellis avatar Jul 12 '22 18:07 yellis

Deploy Preview for nifty-lalande-39c157 ready!

Name Link
Latest commit 5a82d708bc00d0643c801beb8585808279f84e04
Latest deploy log https://app.netlify.com/sites/nifty-lalande-39c157/deploys/62cdb87b99387100081f3cd4
Deploy Preview https://deploy-preview-162--nifty-lalande-39c157.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Jul 12 '22 18:07 netlify[bot]

@b-kelly can you take a look at what I put up? I was going to submit an issue on the prosemirror-markdown project upstream from this, and then saw this case there where they were talking about the same general thing (one tag nested within the same type of tag), and one user recommended adding a nesting function to handle this. I tried to do the same, copying their code, but it didn't change anything. However, I don't totally get what is going on here, so - can you take a look at it and see: maybe we are really close on this (or maybe not)??

yellis avatar Jul 18 '22 14:07 yellis

@yellis I've committed a partial fix along with a few other tests I wrote to help me debug the issue. There are really a few problems here:

  1. opening a mark inside another mark of the same type does not work unless their attributes are different
    • fixed - I'm keeping track of the nesting and setting that value (might be a 50% fix though if there are more sibling marks of the same type at the same nesting level)
  2. closeMark is not taking attributes into account when closing a mark
    • upstream bug - the method is using MarkType.removeFromSet instead of Mark.removeFromSet. The difference being that the former removes all marks of the same type while the latter checks the equality of the Marks before removing them

I'll submit a PR upstream explaining the rationale along with a fix.

b-kelly avatar Jul 19 '22 21:07 b-kelly

@b-kelly sounds good. I'll move this into Beta 3, since the fix is going to be pending upstream fixes.

yellis avatar Jul 20 '22 08:07 yellis

@b-kelly were you able to submit the upstream PR?

yellis avatar Aug 02 '22 07:08 yellis

@b-kelly were you able to submit the upstream PR?

yellis avatar Nov 16 '22 13:11 yellis

Sorry for the delay - this has really gotten away from me. I created an internal Jira ticket (STACKS-121) and tagged you on it so we can assess this during our next backlog grooming session.

b-kelly avatar Nov 16 '22 15:11 b-kelly

I am closing this as there is now an internal Jira ticket to track it.

yellis avatar Mar 19 '23 13:03 yellis