Exemplo n.º 1
0
static Line *
definition_block(Paragraph *top, int clip, MMIOT *f, int kind)
{
    ParagraphRoot d = { 0, 0 };
    Paragraph *p;
    Line *q = top->text, *text = 0, *labels;
    int z, para;

    while (( labels = q )) {

        if ( (q = isdefinition(labels, &z, &kind)) == 0 )
            break;

        if ( (text = skipempty(q->next)) == 0 )
            break;

        if (( para = (text != q->next) ))
            ___mkd_freeLineRange(q, text);

        q->next = 0;
        if ( kind == 1 /* discount dl */ )
            for ( q = labels; q; q = q->next ) {
                CLIP(q->text, 0, 1);
                UNCHECK(q);
                S(q->text)--;
            }

dd_block:
        p = Pp(&d, text, LISTITEM);

        text = listitem(p, clip, f->flags, (kind==2) ? is_extra_dd : 0);
        p->down = compile(p->text, 0, f);
        p->text = labels;
        labels = 0;

        if ( para && p->down ) p->down->align = PARA;

        if ( (q = skipempty(text)) == 0 )
            break;

        if (( para = (q != text) )) {
            Line anchor;

            anchor.next = text;
            ___mkd_freeLineRange(&anchor,q);
            text = q;

        }

        if ( kind == 2 && is_extra_dd(q) )
            goto dd_block;
    }
    top->text = 0;
    top->down = T(d);
    return text;
}
Exemplo n.º 2
0
static int
islist(Line *t, int *clip, DWORD flags, int *list_type)
{
    int i, j;
    char *q;
    
    if ( end_of_block(t) )
	return 0;

    if ( !(flags & (MKD_NODLIST|MKD_STRICT)) && isdefinition(t,clip,list_type) )
	return DL;

    if ( strchr("*-+", T(t->text)[t->dle]) && isspace(T(t->text)[t->dle+1]) ) {
	i = nextnonblank(t, t->dle+1);
	*clip = (i > 4) ? 4 : i;
	*list_type = UL;
	return AL;
    }

    if ( (j = nextblank(t,t->dle)) > t->dle ) {
	if ( T(t->text)[j-1] == '.' ) {

	    if ( !(flags & (MKD_NOALPHALIST|MKD_STRICT))
				    && (j == t->dle + 2)
			  && isalpha(T(t->text)[t->dle]) ) {
		j = nextnonblank(t,j);
		*clip = (j > 4) ? 4 : j;
		*list_type = AL;
		return AL;
	    }

	    strtoul(T(t->text)+t->dle, &q, 10);
	    if ( (q > T(t->text)+t->dle) && (q == T(t->text) + (j-1)) ) {
		j = nextnonblank(t,j);
		/* *clip = j; */
		*clip = (j > 4) ? 4 : j;
		*list_type = OL;
		return AL;
	    }
	}
    }
    return 0;
}