| ︙ | | |
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
|
+
+
+
|
#define MUTYPE_LI 0x0020 /* List items. <li>, <dd>, <dt> */
#define MUTYPE_TABLE 0x0040 /* <table> */
#define MUTYPE_TR 0x0080 /* <tr> */
#define MUTYPE_TD 0x0100 /* <td> or <th> */
#define MUTYPE_SPECIAL 0x0200 /* <nowiki> or <verbatim> */
#define MUTYPE_HYPERLINK 0x0400 /* <a> */
/* MUTYPE values for elements that require strictly nested end-tags */
#define MUTYPE_Nested 0x0656
/*
** These markup types must have an end tag.
*/
#define MUTYPE_STACK (MUTYPE_BLOCK | MUTYPE_FONT | MUTYPE_LIST | MUTYPE_TABLE)
/*
** This markup types are allowed for "inline" text.
|
| ︙ | | |
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
|
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
|
+
|
p->aStack = p->aSpace;
}
/*
** Push a new element onto the tag statk
*/
void html_tagstack_push(HtmlTagStack *p, int e){
if( (aMarkup[e].iType & MUTYPE_Nested)==0 ) return;
if( p->n>=ArraySize(p->aSpace) && p->n>=p->nAlloc ){
if( p->nAlloc==0 ){
int *aNew;
p->nAlloc = 50;
aNew = fossil_malloc( sizeof(p->aStack[0])*p->nAlloc );
memcpy(aNew, p->aStack, sizeof(p->aStack[0])*p->n );
p->aStack = aNew;
|
| ︙ | | |
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
|
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
|
+
-
+
|
** end-tags as you go.
**
** If there is no open-tag for eEnd on the stack, then this
** routine is a no-op.
*/
void html_tagstack_pop(HtmlTagStack *p, Blob *pBlob, int eEnd){
int i;
if( (aMarkup[eEnd].iType & MUTYPE_Nested)==0 ) return;
for(i=p->n-1; i>=0 && p->aStack[i]!=eEnd; i--){}
if( i<0 ){
blob_appendf(pBlob, "<span class='error'></%s></span>",
aMarkup[eEnd].zName);
return;
}
do{
p->n--;
blob_appendf(pBlob, "</%s>", aMarkup[eEnd].zName);
blob_appendf(pBlob, "</%s>", aMarkup[p->aStack[p->n]].zName);
}while( p->aStack[p->n]!=eEnd );
}
/*
** Append HTML text to a Blob object. The appended text is modified
** changed in the following ways:
**
|
| ︙ | | |
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
|
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
|
-
-
+
-
|
blob_appendf(pBlob, "<span class='error'><%.*s></span>",
n-2, zHtml+j+1);
}else{
if( markup.endTag ){
html_tagstack_pop(&s, pBlob, markup.iCode);
}else{
renderMarkup(pBlob, &markup);
if( markup.iType!=MUTYPE_SINGLE ){
html_tagstack_push(&s, markup.iCode);
html_tagstack_push(&s, markup.iCode);
}
}
}
unparseMarkup(&markup);
}
while( s.n>0 ){
s.n--;
blob_appendf(pBlob, "</%s>", aMarkup[s.aStack[s.n]]);
|
| ︙ | | |