Closed jepser closed 3 years ago
@jepser this is to spec. Commonmark has a paragraph there as well https://spec.commonmark.org/dingus/?text=*%20hola%0A*%20adios%0A%0A
If you need it removed, a remark plugin can remove it from the syntax tree, see https://unifiedjs.com/learn for creating a plugin.
Use this codesandbox: https://codesandbox.io/s/confident-allen-1iqpv?file=/src/App.js
I'm not sure how this sandbox relates? here are the imports from the sandbox:
import React, { useState, useCallback, useMemo } from "react";
import { Slate, Editable, withReact } from "slate-react";
import { Node, Editor, Transforms, Range, Point, createEditor } from "slate";
import { withHistory } from "slate-history";
It doesn't use remark or unified.
Sorry my fault, I didn't updated the codesandox 🙈, it should be updated with the code I'm referring to. But you're right I think if that's common mark I will need to create a plugin that removes that, thanks!
For future reference, I used this mdast-flatten-listitem-paragraphs npm package to fix the problem.
@jepser Thanks for that! I've had this issue halting progress with slate for months now.
For future reference: Deserialised Markdown to slate/mdast object issue with creating new list item, inserts empty paragraph, breaking layout and consecutive new list items. Initial listitem state broken after deserialisation.
y’all should really solve this in the slate transform.
listItem adds an extra paragraph node
I'm using remark with slate.js, using
remark-parse
with unified:unified().use(markdown).use(gfm).use(remarkToSlate)
While parsing a list:
I found that the behaviour of slate wasn't the expected, I thought was something related to slate or remarkToSlate, but after checking the parser I found the issue is with
listItem
node fromremark-parse
Your environment
Steps to reproduce
Use this codesandbox: https://codesandbox.io/s/confident-allen-1iqpv?file=/src/App.js
This is the structure that
remark-parse
is handling to the next processor in the pipe (check the extra paragraph node inside listItem):And this is the final result (play with the
Expected behavior
No paragraph node inside listItem but a direct text node descendant
Actual behavior
An extra paragraph item inside listItem