Skip to content

Commit

Permalink
Link label comparision fixes.
Browse files Browse the repository at this point in the history
 * md_link_label_cmp: To match the labels, the loop has to reach ends of
   the labels for both of them.

 * md_link_label_cmp_load_fold_info: Collapse consequtive whitespace
   into a single ' ' for the label comparison purposes.

Fixes #96.
  • Loading branch information
mity committed Nov 3, 2019
1 parent 0354e1a commit e97d025
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Fixes:
* [#95](https://github.com/mity/md4c/issues/95):
`md_is_container_mark()`: Ordered list mark requires at least one digit.

* [#96](https://github.com/mity/md4c/issues/96):
Some fixes for link label comparison.


## Version 0.3.4

Expand Down
6 changes: 3 additions & 3 deletions md4c/md4c.c
Original file line number Diff line number Diff line change
Expand Up @@ -1530,7 +1530,7 @@ md_link_label_cmp_load_fold_info(const CHAR* label, OFF off, SZ size,
SZ char_size;

if(off >= size) {
/* Treat end of link label as a whitespace. */
/* Treat end of a link label as a whitespace. */
goto whitespace;
}

Expand All @@ -1554,7 +1554,7 @@ md_link_label_cmp_load_fold_info(const CHAR* label, OFF off, SZ size,
whitespace:
fold_info->codepoints[0] = _T(' ');
fold_info->n_codepoints = 1;
return off;
return md_skip_unicode_whitespace(label, off, size);
}

static int
Expand All @@ -1572,7 +1572,7 @@ md_link_label_cmp(const CHAR* a_label, SZ a_size, const CHAR* b_label, SZ b_size

a_off = md_skip_unicode_whitespace(a_label, 0, a_size);
b_off = md_skip_unicode_whitespace(b_label, 0, b_size);
while(!a_reached_end && !b_reached_end) {
while(!a_reached_end || !b_reached_end) {
/* If needed, load fold info for next char. */
if(a_fi_off >= a_fi.n_codepoints) {
a_fi_off = 0;
Expand Down
17 changes: 17 additions & 0 deletions test/coverage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,23 @@ foo
````````````````````````````````


### [Issue 96](https://github.com/mity/md4c/issues/96)

```````````````````````````````` example
[ab]: /foo
[a] [ab] [abc]
.
<p>[a] <a href="/foo">ab</a> [abc]</p>
````````````````````````````````

```````````````````````````````` example
[a b]: /foo
[a b]
.
<p><a href="/foo">a b</a></p>
````````````````````````````````


## Code coverage

### `md_is_unicode_whitespace__()`
Expand Down

0 comments on commit e97d025

Please sign in to comment.