StackExchange / StackExchange/Stacks-Editor
feat/bug(commonmark] Block elements (including indented code blocks) under list items
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 437
- Forks
- 61
- Avg merge
- 16h 2m
- Merged PRs (30d)
- 8
Description
Is your feature request related to a problem? Please describe.
Cannot make block elements under list items (works in old editor)
Example scenarios that aren't working:
(1) (from https://meta.stackexchange.com/a/380355/51) Put in this text
You can solve this in the following ways:
1. println("Hello, world!")
2. System.out.println("Hello, world!")
switch to RT and it shows code blocks on new lines after the list items. Switch back and it stays that way in markdown.

We could say that if you want a code block inside a list item, you need to use backticks (the commonmark spec does not require indented code blocks in list items, though it is ambiguous). Or we could allow it (preferred, to be same as old editor). But either way, round-trip shouldn't change anything.
(2) From https://meta.stackexchange.com/a/380344/51, notes that the old editor allowed block elements (code block / heading / blockquote / table) inside list items, and the new one pushes them to new lines (as seen in the previous issue). Indeed, the menu items for block elements are turned of in RT mode when the cursor is inside a list item. Would be good if we can add this capability back, for parity. See that post for screenshots.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the two examples in the editor, switching between rich-text and Markdown modes to observe how block elements inside list items are moved. The work is done when code blocks and other block elements can remain inside list items and round-tripping no longer changes their placement.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100