The reference-style link the ']' at s[i] ends, when the text after it or * the bracket text itself is a label: full `[text][label]`, collapsed * `[label][]`, shortcut `[label]`. *made is set when it is one; returns where * scanning continues. */
| 1929 | * `[label][]`, shortcut `[label]`. *made is set when it is one; returns where |
| 1930 | * scanning continues. */ |
| 1931 | static uint32_t rs_inline_reference(rs_inline_t *in, const rs_opener_t *op, uint32_t i, |
| 1932 | bool *made) { |
| 1933 | const char *s = in->s; |
| 1934 | const char *text = s + op->pos + SKIP_ONE; |
| 1935 | uint32_t text_len = i - op->pos - SKIP_ONE; |
| 1936 | uint32_t after = i + SKIP_ONE; |
| 1937 | bool text_is_label = rs_label_clean(text, text_len); |
| 1938 | if (after < in->n && s[after] == '[') { |
| 1939 | uint32_t close = rs_label_end(s, in->n, after + SKIP_ONE); |
| 1940 | if (close != UINT32_MAX && close > after + SKIP_ONE) { |
| 1941 | *made = true; |
| 1942 | if (!op->image) { |
| 1943 | rs_emit_reference(in->sink, RS_LINK_REFERENCE, s + after + SKIP_ONE, |
| 1944 | close - after - SKIP_ONE, op->pos); |
| 1945 | } |
| 1946 | return close + SKIP_ONE; |
| 1947 | } |
| 1948 | if (close == after + SKIP_ONE && text_is_label) { |
| 1949 | *made = true; |
| 1950 | if (!op->image) { |
| 1951 | rs_emit_reference(in->sink, RS_LINK_COLLAPSED, text, text_len, op->pos); |
| 1952 | } |
| 1953 | return close + SKIP_ONE; |
| 1954 | } |
| 1955 | } |
| 1956 | if (text_is_label) { |
| 1957 | *made = true; |
| 1958 | if (!op->image) { |
| 1959 | rs_emit_reference(in->sink, RS_LINK_SHORTCUT, text, text_len, op->pos); |
| 1960 | } |
| 1961 | } |
| 1962 | return i + SKIP_ONE; |
| 1963 | } |
| 1964 | |
| 1965 | /* The ']' at s[i]: make a link of the bracket pair it closes, when it is one. |
| 1966 | * Returns where scanning continues. */ |
no test coverage detected