765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
|
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
*/
static void endAutoParagraph(Renderer *p){
if( p->inAutoParagraph ){
popStackToTag(p, MARKUP_P);
p->inAutoParagraph = 0;
}
}
/*
** If the input string corresponds to an existing baseline,
** return true.
*/
static int is_valid_uuid(const char *z){
int n = strlen(z);
int rid;
if( n<4 || n>UUID_SIZE ) return 0;
if( !validate16(z, n) ) return 0;
return 1;
}
/*
** Resolve a hyperlink. The argument is the content of the [...]
** in the wiki. Append the URL to the output of the Renderer.
*/
static void resolveHyperlink(const char *zTarget, Renderer *p){
if( strncmp(zTarget, "http:", 5)==0
|| strncmp(zTarget, "https:", 6)==0
|| strncmp(zTarget, "ftp:", 4)==0
|| strncmp(zTarget, "mailto:", 7)==0
){
blob_appendf(p->pOut, zTarget);
}else if( zTarget[0]=='/' ){
blob_appendf(p->pOut, "%s%h", g.zBaseURL, zTarget);
}else if( is_valid_uuid(zTarget) ){
blob_appendf(p->pOut, "%s/info/%s", g.zBaseURL, zTarget);
}else if( wiki_name_is_wellformed(zTarget) ){
blob_appendf(p->pOut, "%s/wiki?name=%T", g.zBaseURL, zTarget);
}else{
blob_appendf(p->pOut, "error");
}
}
|