The ']' at s[i]: make a link of the bracket pair it closes, when it is one. * Returns where scanning continues. */
| 1965 | /* The ']' at s[i]: make a link of the bracket pair it closes, when it is one. |
| 1966 | * Returns where scanning continues. */ |
| 1967 | static uint32_t rs_inline_close(rs_inline_t *in, uint32_t i) { |
| 1968 | if (in->nopen == 0) { |
| 1969 | return i + SKIP_ONE; |
| 1970 | } |
| 1971 | int idx = --in->nopen; |
| 1972 | rs_opener_t op = in->open[idx]; |
| 1973 | bool dead = idx < in->dead && !op.image; /* inside a link: links do not nest */ |
| 1974 | if (in->dead > in->nopen) { |
| 1975 | in->dead = in->nopen; |
| 1976 | } |
| 1977 | if (dead) { |
| 1978 | return i + SKIP_ONE; |
| 1979 | } |
| 1980 | uint32_t after = i + SKIP_ONE; |
| 1981 | const char *dest = NULL; |
| 1982 | uint32_t dest_len = 0; |
| 1983 | uint32_t end = 0; |
| 1984 | bool made = false; |
| 1985 | if (after < in->n && in->s[after] == '(' && rs_inline_dest(in, after, &dest, &dest_len, &end)) { |
| 1986 | made = true; |
| 1987 | if (!op.image) { |
| 1988 | rs_emit_link(in->sink, RS_LINK_INLINE, dest, dest_len, false, op.pos); |
| 1989 | } |
| 1990 | } else { |
| 1991 | end = rs_inline_reference(in, &op, i, &made); |
| 1992 | } |
| 1993 | if (made && !op.image) { |
| 1994 | in->dead = in->nopen; /* every '[' still open encloses this link */ |
| 1995 | } |
| 1996 | return end; |
| 1997 | } |
| 1998 | |
| 1999 | /* Find the links of one paragraph. */ |
| 2000 | static void rs_inline_scan(rs_inline_t *in) { |
no test coverage detected