Example #1
0
/* emblock() -- walk a blocklist, attempting to match emphasis
 */
static void
emblock(MMIOT *f, int first, int last)
{
    int i;
    
    for ( i = first; i <= last; i++ )
	if ( T(f->Q)[i].b_type != bTEXT )
	    emmatch(f, i, last);
    emclose(f, first, last);
} /* emblock */
Example #2
0
/* ___mkd_emblock()
 */
void
___mkd_emblock(MMIOT *f)
{
    int i;
    block *p;

    for (i=0; i < S(f->Q); i++) {
	p = &T(f->Q)[i];
	
	if ( p->b_type != bTEXT ) emmatch(f, i);

	if ( S(p->b_post) ) { SUFFIX(f->out, T(p->b_post), S(p->b_post));
			      DELETE(p->b_post); }
	if ( S(p->b_text) ) { SUFFIX(f->out, T(p->b_text), S(p->b_text));
			      DELETE(p->b_text); }
    }
    S(f->Q) = 0;
}
Example #3
0
/* emmatch() -- match emphasis for a single emphasis token.
 */
static void
emmatch(MMIOT *f, int first, int last)
{
    block *start = &T(f->Q)[first];
    int e, e2, match;

    switch (start->b_count) {
    case 2: if ( e = empair(f,first,last,match=2) )
		break;
    case 1: e = empair(f,first,last,match=1);
	    break;
    case 0: return;
    default:
	    e = empair(f,first,last,1);
	    e2= empair(f,first,last,2);

	    if ( e2 >= e ) {
		e = e2;
		match = 2;
	    } 
	    else
		match = 1;
	    break;
    }

    if ( e ) {
	/* if we found emphasis to match, match it, recursively call
	 * emblock to match emphasis inside the new html block, add
	 * the emphasis markers for the block, then (tail) recursively
	 * call ourself to match any remaining emphasis on this token.
	 */
	block *end = &T(f->Q)[e];

	end->b_count -= match;
	start->b_count -= match;

	emblock(f, first, e);

	PREFIX(start->b_text, emtags[match-1].open, emtags[match-1].size-1);
	SUFFIX(end->b_post, emtags[match-1].close, emtags[match-1].size);

	emmatch(f, first, last);
    }
} /* emmatch */