Fossil SCM

Fixes to the rendering of <verbatim> and <nowiki>

drh 2007-10-28 21:09 trunk
Commit e75f9a2ab45aa3b47bb0ac6043bd42118d77f9ea
1 file changed +8 -9
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -512,11 +512,11 @@
512512
513513
/*
514514
** z points to the start of a token. Return the number of
515515
** characters in that token. Write the token type into *pTokenType.
516516
*/
517
-static int nextToken(const char *z, int state, int *pTokenType){
517
+static int nextToken(const char *z, Renderer *p, int *pTokenType){
518518
int n;
519519
if( z[0]=='<' ){
520520
n = markupLength(z);
521521
if( n>0 ){
522522
*pTokenType = TOKEN_MARKUP;
@@ -524,15 +524,15 @@
524524
}else{
525525
*pTokenType = TOKEN_CHARACTER;
526526
return 1;
527527
}
528528
}
529
- if( z[0]=='&' && !isElement(z) ){
529
+ if( z[0]=='&' && (p->inVerbatim || !isElement(z)) ){
530530
*pTokenType = TOKEN_CHARACTER;
531531
return 1;
532532
}
533
- if( (state & ALLOW_WIKI)!=0 ){
533
+ if( (p->state & ALLOW_WIKI)!=0 ){
534534
if( z[0]=='\n' ){
535535
n = paragraphBreakLength(z);
536536
if( n>0 ){
537537
*pTokenType = TOKEN_PARAGRAPH;
538538
return n;
@@ -539,12 +539,11 @@
539539
}else if( isspace(z[1]) ){
540540
*pTokenType = TOKEN_NEWLINE;
541541
return 1;
542542
}
543543
}
544
- if( (state & AT_NEWLINE)!=0 /* && (state & (AT_PARAGRAPH|IN_LIST))!=0 */
545
- && isspace(z[0]) ){
544
+ if( (p->state & AT_NEWLINE)!=0 && isspace(z[0]) ){
546545
n = bulletLength(z);
547546
if( n>0 ){
548547
*pTokenType = TOKEN_BULLET;
549548
return n;
550549
}
@@ -552,11 +551,11 @@
552551
if( n>0 ){
553552
*pTokenType = TOKEN_ENUM;
554553
return n;
555554
}
556555
}
557
- if( (state & AT_PARAGRAPH)!=0 && isspace(z[0]) ){
556
+ if( (p->state & AT_PARAGRAPH)!=0 && isspace(z[0]) ){
558557
n = indentLength(z);
559558
if( n>0 ){
560559
*pTokenType = TOKEN_INDENT;
561560
return n;
562561
}
@@ -565,11 +564,11 @@
565564
*pTokenType = TOKEN_LINK;
566565
return n;
567566
}
568567
}
569568
*pTokenType = TOKEN_TEXT;
570
- return 1 + textLength(z+1, state & ALLOW_WIKI);
569
+ return 1 + textLength(z+1, p->state & ALLOW_WIKI);
571570
}
572571
573572
/*
574573
** A single markup is parsed into an instance of the following
575574
** structure.
@@ -824,11 +823,11 @@
824823
int tokenType;
825824
ParsedMarkup markup;
826825
int n;
827826
828827
while( z[0] ){
829
- n = nextToken(z, p->state, &tokenType);
828
+ n = nextToken(z, p, &tokenType);
830829
p->state &= ~(AT_NEWLINE|AT_PARAGRAPH);
831830
switch( tokenType ){
832831
case TOKEN_PARAGRAPH: {
833832
if( p->wikiList ){
834833
popStackToTag(p, p->wikiList);
@@ -950,11 +949,11 @@
950949
/* Do nothing */
951950
}else if( markup.iCode==MARKUP_NOWIKI ){
952951
if( markup.endTag ){
953952
p->state |= ALLOW_WIKI;
954953
}else{
955
- p->state &= ALLOW_WIKI;
954
+ p->state &= ~ALLOW_WIKI;
956955
}
957956
}else if( markup.endTag ){
958957
popStackToTag(p, markup.iCode);
959958
}else if( markup.iCode==MARKUP_VERBATIM ){
960959
if( markup.nAttr==1 ){
961960
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -512,11 +512,11 @@
512
513 /*
514 ** z points to the start of a token. Return the number of
515 ** characters in that token. Write the token type into *pTokenType.
516 */
517 static int nextToken(const char *z, int state, int *pTokenType){
518 int n;
519 if( z[0]=='<' ){
520 n = markupLength(z);
521 if( n>0 ){
522 *pTokenType = TOKEN_MARKUP;
@@ -524,15 +524,15 @@
524 }else{
525 *pTokenType = TOKEN_CHARACTER;
526 return 1;
527 }
528 }
529 if( z[0]=='&' && !isElement(z) ){
530 *pTokenType = TOKEN_CHARACTER;
531 return 1;
532 }
533 if( (state & ALLOW_WIKI)!=0 ){
534 if( z[0]=='\n' ){
535 n = paragraphBreakLength(z);
536 if( n>0 ){
537 *pTokenType = TOKEN_PARAGRAPH;
538 return n;
@@ -539,12 +539,11 @@
539 }else if( isspace(z[1]) ){
540 *pTokenType = TOKEN_NEWLINE;
541 return 1;
542 }
543 }
544 if( (state & AT_NEWLINE)!=0 /* && (state & (AT_PARAGRAPH|IN_LIST))!=0 */
545 && isspace(z[0]) ){
546 n = bulletLength(z);
547 if( n>0 ){
548 *pTokenType = TOKEN_BULLET;
549 return n;
550 }
@@ -552,11 +551,11 @@
552 if( n>0 ){
553 *pTokenType = TOKEN_ENUM;
554 return n;
555 }
556 }
557 if( (state & AT_PARAGRAPH)!=0 && isspace(z[0]) ){
558 n = indentLength(z);
559 if( n>0 ){
560 *pTokenType = TOKEN_INDENT;
561 return n;
562 }
@@ -565,11 +564,11 @@
565 *pTokenType = TOKEN_LINK;
566 return n;
567 }
568 }
569 *pTokenType = TOKEN_TEXT;
570 return 1 + textLength(z+1, state & ALLOW_WIKI);
571 }
572
573 /*
574 ** A single markup is parsed into an instance of the following
575 ** structure.
@@ -824,11 +823,11 @@
824 int tokenType;
825 ParsedMarkup markup;
826 int n;
827
828 while( z[0] ){
829 n = nextToken(z, p->state, &tokenType);
830 p->state &= ~(AT_NEWLINE|AT_PARAGRAPH);
831 switch( tokenType ){
832 case TOKEN_PARAGRAPH: {
833 if( p->wikiList ){
834 popStackToTag(p, p->wikiList);
@@ -950,11 +949,11 @@
950 /* Do nothing */
951 }else if( markup.iCode==MARKUP_NOWIKI ){
952 if( markup.endTag ){
953 p->state |= ALLOW_WIKI;
954 }else{
955 p->state &= ALLOW_WIKI;
956 }
957 }else if( markup.endTag ){
958 popStackToTag(p, markup.iCode);
959 }else if( markup.iCode==MARKUP_VERBATIM ){
960 if( markup.nAttr==1 ){
961
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -512,11 +512,11 @@
512
513 /*
514 ** z points to the start of a token. Return the number of
515 ** characters in that token. Write the token type into *pTokenType.
516 */
517 static int nextToken(const char *z, Renderer *p, int *pTokenType){
518 int n;
519 if( z[0]=='<' ){
520 n = markupLength(z);
521 if( n>0 ){
522 *pTokenType = TOKEN_MARKUP;
@@ -524,15 +524,15 @@
524 }else{
525 *pTokenType = TOKEN_CHARACTER;
526 return 1;
527 }
528 }
529 if( z[0]=='&' && (p->inVerbatim || !isElement(z)) ){
530 *pTokenType = TOKEN_CHARACTER;
531 return 1;
532 }
533 if( (p->state & ALLOW_WIKI)!=0 ){
534 if( z[0]=='\n' ){
535 n = paragraphBreakLength(z);
536 if( n>0 ){
537 *pTokenType = TOKEN_PARAGRAPH;
538 return n;
@@ -539,12 +539,11 @@
539 }else if( isspace(z[1]) ){
540 *pTokenType = TOKEN_NEWLINE;
541 return 1;
542 }
543 }
544 if( (p->state & AT_NEWLINE)!=0 && isspace(z[0]) ){
 
545 n = bulletLength(z);
546 if( n>0 ){
547 *pTokenType = TOKEN_BULLET;
548 return n;
549 }
@@ -552,11 +551,11 @@
551 if( n>0 ){
552 *pTokenType = TOKEN_ENUM;
553 return n;
554 }
555 }
556 if( (p->state & AT_PARAGRAPH)!=0 && isspace(z[0]) ){
557 n = indentLength(z);
558 if( n>0 ){
559 *pTokenType = TOKEN_INDENT;
560 return n;
561 }
@@ -565,11 +564,11 @@
564 *pTokenType = TOKEN_LINK;
565 return n;
566 }
567 }
568 *pTokenType = TOKEN_TEXT;
569 return 1 + textLength(z+1, p->state & ALLOW_WIKI);
570 }
571
572 /*
573 ** A single markup is parsed into an instance of the following
574 ** structure.
@@ -824,11 +823,11 @@
823 int tokenType;
824 ParsedMarkup markup;
825 int n;
826
827 while( z[0] ){
828 n = nextToken(z, p, &tokenType);
829 p->state &= ~(AT_NEWLINE|AT_PARAGRAPH);
830 switch( tokenType ){
831 case TOKEN_PARAGRAPH: {
832 if( p->wikiList ){
833 popStackToTag(p, p->wikiList);
@@ -950,11 +949,11 @@
949 /* Do nothing */
950 }else if( markup.iCode==MARKUP_NOWIKI ){
951 if( markup.endTag ){
952 p->state |= ALLOW_WIKI;
953 }else{
954 p->state &= ~ALLOW_WIKI;
955 }
956 }else if( markup.endTag ){
957 popStackToTag(p, markup.iCode);
958 }else if( markup.iCode==MARKUP_VERBATIM ){
959 if( markup.nAttr==1 ){
960

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button