Fossil SCM

Update the built-in pikchr.c to the latest version that supports alternative spellings for "<-", "->", and "<->" tokens.

drh 2021-06-11 15:32 trunk
Commit 76e421bbd5bb4cdaf5be126ae88c2d538f2c89cf3dd1243fe4cb7e28f6a42d67
1 file changed +42 -1
+42 -1
--- src/pikchr.c
+++ src/pikchr.c
@@ -7308,10 +7308,28 @@
73087308
}else{
73097309
pToken->eType = T_LT;
73107310
return 1;
73117311
}
73127312
}
7313
+ case 0xe2: {
7314
+ if( z[1]==0x86 ){
7315
+ if( z[2]==0x90 ){
7316
+ pToken->eType = T_LARROW; /* <- */
7317
+ return 3;
7318
+ }
7319
+ if( z[2]==0x92 ){
7320
+ pToken->eType = T_RARROW; /* -> */
7321
+ return 3;
7322
+ }
7323
+ if( z[2]==0x94 ){
7324
+ pToken->eType = T_LRARROW; /* <-> */
7325
+ return 3;
7326
+ }
7327
+ }
7328
+ pToken->eType = T_ERROR;
7329
+ return 1;
7330
+ }
73137331
case '{': {
73147332
int len, depth;
73157333
i = 1;
73167334
if( bAllowCodeBlock ){
73177335
depth = 1;
@@ -7332,10 +7350,33 @@
73327350
pToken->eType = T_ERROR;
73337351
return 1;
73347352
}
73357353
pToken->eType = T_CODEBLOCK;
73367354
return i;
7355
+ }
7356
+ case '&': {
7357
+ static const struct {
7358
+ int nByte; /* Number of bytes in zEntity */
7359
+ int eCode; /* Corresponding token code */
7360
+ const char *zEntity; /* Name of the HTML entity */
7361
+ } aEntity[] = {
7362
+ /* 123456789 1234567 */
7363
+ { 6, T_RARROW, "&rarr;" }, /* Same as -> */
7364
+ { 12, T_RARROW, "&rightarrow;" }, /* Same as -> */
7365
+ { 6, T_LARROW, "&larr;" }, /* Same as <- */
7366
+ { 11, T_LARROW, "&leftarrow;" }, /* Same as <- */
7367
+ { 16, T_LRARROW, "&leftrightarrow;" }, /* Same as <-> */
7368
+ };
7369
+ unsigned int i;
7370
+ for(i=0; i<sizeof(aEntity)/sizeof(aEntity[0]); i++){
7371
+ if( strncmp((const char*)z,aEntity[i].zEntity,aEntity[i].nByte)==0 ){
7372
+ pToken->eType = aEntity[i].eCode;
7373
+ return aEntity[i].nByte;
7374
+ }
7375
+ }
7376
+ pToken->eType = T_ERROR;
7377
+ return 1;
73377378
}
73387379
default: {
73397380
c = z[0];
73407381
if( c=='.' ){
73417382
unsigned char c1 = z[1];
@@ -7960,6 +8001,6 @@
79608001
79618002
79628003
#endif /* PIKCHR_TCL */
79638004
79648005
7965
-#line 7990 "pikchr.c"
8006
+#line 8031 "pikchr.c"
79668007
--- src/pikchr.c
+++ src/pikchr.c
@@ -7308,10 +7308,28 @@
7308 }else{
7309 pToken->eType = T_LT;
7310 return 1;
7311 }
7312 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7313 case '{': {
7314 int len, depth;
7315 i = 1;
7316 if( bAllowCodeBlock ){
7317 depth = 1;
@@ -7332,10 +7350,33 @@
7332 pToken->eType = T_ERROR;
7333 return 1;
7334 }
7335 pToken->eType = T_CODEBLOCK;
7336 return i;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7337 }
7338 default: {
7339 c = z[0];
7340 if( c=='.' ){
7341 unsigned char c1 = z[1];
@@ -7960,6 +8001,6 @@
7960
7961
7962 #endif /* PIKCHR_TCL */
7963
7964
7965 #line 7990 "pikchr.c"
7966
--- src/pikchr.c
+++ src/pikchr.c
@@ -7308,10 +7308,28 @@
7308 }else{
7309 pToken->eType = T_LT;
7310 return 1;
7311 }
7312 }
7313 case 0xe2: {
7314 if( z[1]==0x86 ){
7315 if( z[2]==0x90 ){
7316 pToken->eType = T_LARROW; /* <- */
7317 return 3;
7318 }
7319 if( z[2]==0x92 ){
7320 pToken->eType = T_RARROW; /* -> */
7321 return 3;
7322 }
7323 if( z[2]==0x94 ){
7324 pToken->eType = T_LRARROW; /* <-> */
7325 return 3;
7326 }
7327 }
7328 pToken->eType = T_ERROR;
7329 return 1;
7330 }
7331 case '{': {
7332 int len, depth;
7333 i = 1;
7334 if( bAllowCodeBlock ){
7335 depth = 1;
@@ -7332,10 +7350,33 @@
7350 pToken->eType = T_ERROR;
7351 return 1;
7352 }
7353 pToken->eType = T_CODEBLOCK;
7354 return i;
7355 }
7356 case '&': {
7357 static const struct {
7358 int nByte; /* Number of bytes in zEntity */
7359 int eCode; /* Corresponding token code */
7360 const char *zEntity; /* Name of the HTML entity */
7361 } aEntity[] = {
7362 /* 123456789 1234567 */
7363 { 6, T_RARROW, "&rarr;" }, /* Same as -> */
7364 { 12, T_RARROW, "&rightarrow;" }, /* Same as -> */
7365 { 6, T_LARROW, "&larr;" }, /* Same as <- */
7366 { 11, T_LARROW, "&leftarrow;" }, /* Same as <- */
7367 { 16, T_LRARROW, "&leftrightarrow;" }, /* Same as <-> */
7368 };
7369 unsigned int i;
7370 for(i=0; i<sizeof(aEntity)/sizeof(aEntity[0]); i++){
7371 if( strncmp((const char*)z,aEntity[i].zEntity,aEntity[i].nByte)==0 ){
7372 pToken->eType = aEntity[i].eCode;
7373 return aEntity[i].nByte;
7374 }
7375 }
7376 pToken->eType = T_ERROR;
7377 return 1;
7378 }
7379 default: {
7380 c = z[0];
7381 if( c=='.' ){
7382 unsigned char c1 = z[1];
@@ -7960,6 +8001,6 @@
8001
8002
8003 #endif /* PIKCHR_TCL */
8004
8005
8006 #line 8031 "pikchr.c"
8007

Keyboard Shortcuts

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