Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug][preset-commonmark] Unable to use non-paragraph elements as the first element inside a list item #1276

Closed
2 tasks done
gudzpoz opened this issue Mar 22, 2024 · 0 comments · Fixed by #1300
Closed
2 tasks done
Assignees
Labels
bug Something isn't working

Comments

@gudzpoz
Copy link

gudzpoz commented Mar 22, 2024

Initial checklist

  • I agree to follow the code of conduct
  • I searched issues and discussions and couldn’t find anything (or linked relevant results below)

Affected packages and versions

@milkdown/preset-commonmark@^7.3.0

Link to runnable example

No response

Steps to reproduce

Open Milkdown playground.

From Markdown

  1. Try Example 293 in the CommonMark Spec:

    > 1. > Blockquote
    > continued here.
  2. Observe that an empty paragraph is automatically inserted upon modification.

From Milkdown Editor

  1. Focus the editor and type in the following:

    1. > text
  2. Observe that one cannot use codeblocks as the first element inside a list item.

Expected behavior

One should be able to use non-paragraph elements as the first element inside a list item, since the Commonmark spec does not pose a limit on it if I understand correctly.

Actually, after applying a simple patch to preset-commonmark, the widget still seems to work fine. Are there other considerations behind this restriction?

--- a/src/node/list-item.ts
+++ b/src/node/list-item.ts
@@ -18,7 +18,7 @@ withMeta(listItemAttr, {
 /// Schema for list item node.
 export const listItemSchema = $nodeSchema('list_item', ctx => ({
   group: 'listItem',
-  content: 'paragraph block*',
+  content: 'block+',
   attrs: {
     label: {
       default: '•',

Actual behavior

As seems to be specified here:

content: 'paragraph block*',

Milkdown requires the first element inside a list item to be a paragraph.

Runtime

Firefox

OS

Linux

Build and bundle tools

Vite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants