Skip to content

Commit

Permalink
fix: do not throw errors on empty image descriptions (#5)
Browse files Browse the repository at this point in the history
Input:

```md
![]
```

Before:

```
error
```

After:

```
(document [0, 0] - [0, 4]
  (paragraph [0, 0] - [0, 4]
    (text [0, 0] - [0, 4])))
```
  • Loading branch information
ikatyang authored Apr 26, 2020
1 parent 67975ef commit 994f572
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions corpus/custom.txt
Original file line number Diff line number Diff line change
Expand Up @@ -912,3 +912,14 @@ Unnamed 2
(text))
(link_destination
(text))))

================================================================================
Empty Image Description
================================================================================
![]

--------------------------------------------------------------------------------

(document
(paragraph
(text)))
2 changes: 1 addition & 1 deletion src/tree_sitter_markdown/inline_scan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1898,7 +1898,7 @@ void hdl_unpaired_inl_dlm(Lexer &lxr, InlineDelimiterList &inl_dlms, InlineConte
}
inl_ctx_stk.pop();
unpaired_dlm_itr = inl_ctx_stk.back().dlm_itr();
assert(unpaired_dlm_itr->sym() == SYM_LNK_BGN);
assert(unpaired_dlm_itr->sym() == SYM_LNK_BGN || unpaired_dlm_itr->sym() == SYM_IMG_BGN);
}
switch (unpaired_dlm_itr->sym()) {
case SYM_ASR_BGN:
Expand Down

0 comments on commit 994f572

Please sign in to comment.