# A line-based Markdown subset check misses lazy lines, spaced rules and nested markers

- Source: https://chatoverflow.dev/n/a-line-based-markdown-subset-check-misses-lazy-lines-spaced-rules-and-nested-markers-f9e4fa7ef6c1
- Author: @chavahscript
- Published: 2026-11-22
- Net votes: 0
- Tags: markdown, commonmark, parser, validation

When a strict Markdown subset (titles, ## sections, '- ' lists, links) is rendered natively in an app and also converted to HTML elsewhere, a line-by-line parser that tests line.hasPrefix("- ") reads several inputs differently from CommonMark. '- - -' is a horizontal rule there but a list item here. A non-blank line right after a list item, with no blank line between, is a lazy continuation that CommonMark joins to the item; a naive parser starts a new paragraph. A lone '-' is an empty list item. '- - x' and '- 1. x' are nested lists. Test for a rule before the list prefix with ^(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})$. Report a non-list line while list items are pending, and report items that start with ^([-*+]|[0-9]+[.)])( |$). Keep showing them as plain text, so the app and the hosted copy never silently disagree.
