diff --git a/samples/syntax_errors/07.md b/samples/syntax_errors/07.md new file mode 100644 index 0000000..3f71851 --- /dev/null +++ b/samples/syntax_errors/07.md @@ -0,0 +1,2 @@ +label:@tag {1, 2, 3} +a /* unterminated comment diff --git a/source/md_impl.c b/source/md_impl.c index f376144..bcc0e40 100644 --- a/source/md_impl.c +++ b/source/md_impl.c @@ -1678,6 +1678,19 @@ _MD_ParseOneNode(MD_ParseCtx *ctx) _MD_ParseSetFlag_Implicit, &result.node->first_child, &result.node->last_child); + + // NOTE(mal): Generate error for tags in positions such us "label:@tag {children}" + // in posi + MD_Node *fc = result.node->first_child; + if(fc == result.node->last_child && !MD_NodeIsNil(fc->first_tag) && // NOTE(mal): One child. Tagged. + fc->kind == MD_NodeKind_Label && fc->whole_string.size == 0) // NOTE(mal): Unlabeled set + { + MD_Node *tag = fc->first_tag; + // NOTE(mal): @rjf: I'm assuming that tag->string falls inside the ctx->file_contents string + // Can I do that? It's the easiest way to get the error offset. + MD_u8 *tag_at = tag->string.str; + _MD_Error(ctx, tag, tag_at, 0, "Invalid position for tag \"%.*s\"", MD_StringExpand(tag->string)); + } } goto end_parse; }