Fossil SCM

Remove the incomplete @tag support. Add some sample inputs to the [/wiki?name=branch/markdown-tagrefs|branch/markdown-tagrefs] page.

stephan 2024-07-03 09:35 markdown-tagrefs
Commit 4d7c408f529d23014e2081116d6cda23f53f2d5b56962a0ddb5b5fa4b72b97fe
+3 -3
--- src/backlink.c
+++ src/backlink.c
@@ -285,12 +285,12 @@
285285
static int mkdn_noop_r_html_tag(Blob *b1, Blob *b2, void *v){ return 1; }
286286
static int (*mkdn_noop_tri_emphas)(Blob*, Blob*, char,
287287
void*) = mkdn_noop_emphasis;
288288
static int mkdn_noop_footnoteref(Blob *b1, const Blob *b2, const Blob *b3,
289289
int i1, int i2, void *v){ return 1; }
290
-static int mkdn_noop_tagref(Blob*,Blob*, enum mkd_tagspan,
291
- void*){ return 1; }
290
+static int mkdn_noop_tagref(Blob *b1,Blob *b2, enum mkd_tagspan t,
291
+ void *p){ return 1; }
292292
293293
/*
294294
** Scan markdown text and add self-hyperlinks to the BACKLINK table.
295295
*/
296296
void markdown_extract_links(
@@ -321,11 +321,11 @@
321321
/* emphasis */ mkdn_noop_emphasis,
322322
/* image */ mkdn_noop_image,
323323
/* linebreak */ mkdn_noop_linebreak,
324324
/* link */ backlink_md_link,
325325
/* r_html_tag */ mkdn_noop_r_html_tag,
326
- /* @/#tags */ mkdn_noop_tagref,
326
+ /* #tags */ mkdn_noop_tagref,
327327
/* tri_emphas */ mkdn_noop_tri_emphas,
328328
/* footnoteref*/ mkdn_noop_footnoteref,
329329
330330
0, /* entity */
331331
0, /* normal_text */
332332
--- src/backlink.c
+++ src/backlink.c
@@ -285,12 +285,12 @@
285 static int mkdn_noop_r_html_tag(Blob *b1, Blob *b2, void *v){ return 1; }
286 static int (*mkdn_noop_tri_emphas)(Blob*, Blob*, char,
287 void*) = mkdn_noop_emphasis;
288 static int mkdn_noop_footnoteref(Blob *b1, const Blob *b2, const Blob *b3,
289 int i1, int i2, void *v){ return 1; }
290 static int mkdn_noop_tagref(Blob*,Blob*, enum mkd_tagspan,
291 void*){ return 1; }
292
293 /*
294 ** Scan markdown text and add self-hyperlinks to the BACKLINK table.
295 */
296 void markdown_extract_links(
@@ -321,11 +321,11 @@
321 /* emphasis */ mkdn_noop_emphasis,
322 /* image */ mkdn_noop_image,
323 /* linebreak */ mkdn_noop_linebreak,
324 /* link */ backlink_md_link,
325 /* r_html_tag */ mkdn_noop_r_html_tag,
326 /* @/#tags */ mkdn_noop_tagref,
327 /* tri_emphas */ mkdn_noop_tri_emphas,
328 /* footnoteref*/ mkdn_noop_footnoteref,
329
330 0, /* entity */
331 0, /* normal_text */
332
--- src/backlink.c
+++ src/backlink.c
@@ -285,12 +285,12 @@
285 static int mkdn_noop_r_html_tag(Blob *b1, Blob *b2, void *v){ return 1; }
286 static int (*mkdn_noop_tri_emphas)(Blob*, Blob*, char,
287 void*) = mkdn_noop_emphasis;
288 static int mkdn_noop_footnoteref(Blob *b1, const Blob *b2, const Blob *b3,
289 int i1, int i2, void *v){ return 1; }
290 static int mkdn_noop_tagref(Blob *b1,Blob *b2, enum mkd_tagspan t,
291 void *p){ return 1; }
292
293 /*
294 ** Scan markdown text and add self-hyperlinks to the BACKLINK table.
295 */
296 void markdown_extract_links(
@@ -321,11 +321,11 @@
321 /* emphasis */ mkdn_noop_emphasis,
322 /* image */ mkdn_noop_image,
323 /* linebreak */ mkdn_noop_linebreak,
324 /* link */ backlink_md_link,
325 /* r_html_tag */ mkdn_noop_r_html_tag,
326 /* #tags */ mkdn_noop_tagref,
327 /* tri_emphas */ mkdn_noop_tri_emphas,
328 /* footnoteref*/ mkdn_noop_footnoteref,
329
330 0, /* entity */
331 0, /* normal_text */
332
+6 -46
--- src/markdown.c
+++ src/markdown.c
@@ -42,11 +42,10 @@
4242
MKDA_IMPLICIT_EMAIL /* e-mail link without mailto: */
4343
};
4444
4545
/* mkd_tagspan -- type of tagged <span> */
4646
enum mkd_tagspan {
47
- MKDT_ATREF, /* @name references, as in /chat attention targeting */
4847
MKDT_HASHTAG, /* #hashtags */
4948
MKDT_NUMTAG /* #123[.456] /chat or /forum message IDs. */
5049
};
5150
5251
/* mkd_renderer -- functions for rendering parsed data */
@@ -960,48 +959,10 @@
960959
blob_append(ob, data, end);
961960
}
962961
return end;
963962
}
964963
965
-/* char_atref_tag -- '@' followed by "word" characters to tag
966
- * at-references */
967
-static size_t char_atref_tag(
968
- struct Blob *ob,
969
- struct render *rndr,
970
- char *data,
971
- size_t offset,
972
- size_t size
973
-){
974
- size_t end;
975
- struct Blob work = BLOB_INITIALIZER;
976
-
977
- if(offset>0 && !fossil_isspace(data[-1])){
978
- /* Only ever match if the *previous* character is
979
- whitespace or we're at the start of the input. */
980
- return 0;
981
- }
982
- /*fprintf(stderr,"@-REF: %.*s\n", (int)size, data);*/
983
- if (size < 2 || !fossil_isalpha(data[1])) return 0;
984
- for (end = 2; (end < size)
985
- && (fossil_isalnum(data[end])
986
- /* TODO: email addresses are legal fossil user names, but
987
- parsing those is beyond our current ambitions.
988
- Similarly, non-ASCII names are legal, but not
989
- currently handled here. */
990
- /*|| data[end] == '.' || data[end] == '_'
991
- || data[end] == '-'*/);
992
- ++end);
993
- if(end<size){
994
- if(!fossil_isspace(data[end])){
995
- return 0;
996
- }
997
- }
998
- blob_init(&work, data + 1, end - 1);
999
- rndr->make.tagspan(ob, &work, MKDT_ATREF, rndr->make.opaque);
1000
- return end;
1001
-}
1002
-
1003964
/* char_hashref_tag -- '#' followed by "word" characters to tag
1004965
** post numbers, hashtags, etc.
1005966
**
1006967
** Basic syntax:
1007968
**
@@ -1038,14 +999,14 @@
1038999
int nUscore = 0; /* Consecutive underscore counter */
10391000
int numberMode = 0 /* 0 for normal, 1 for #NNN numeric,
10401001
and 2 for #NNN.NNN. */;
10411002
if(offset>0 && !fossil_isspace(data[-1])){
10421003
/* Only ever match if the *previous* character is whitespace or
1043
- we're at the start of the input. Note that we rely on fossil
1044
- processing emphasis markup before reaching this function, so
1045
- *#Hash* will Do The Right Thing. Not that this means that
1046
- "#Hash." will match while ".#Hash" won't. That's okay. */
1004
+ ** we're at the start of the input. Note that we rely on fossil
1005
+ ** processing emphasis markup before reaching this function, so
1006
+ ** *#Hash* will Do The Right Thing. Not that this means that
1007
+ ** "#Hash." will match while ".#Hash" won't. That's okay. */
10471008
return 0;
10481009
}
10491010
assert( '#' == data[0] );
10501011
if(size < 2) return 0;
10511012
end = 2;
@@ -1052,12 +1013,12 @@
10521013
if(fossil_isdigit(data[1])){
10531014
numberMode = 1;
10541015
}else if(!fossil_isalpha(data[1])){
10551016
switch(data[1] & 0xF0){
10561017
/* Reminder: UTF8 char lengths can be determined by
1057
- masking against 0xF0: 0xf0==4, 0xe0==3, 0xc0==2,
1058
- else 1. */
1018
+ ** masking against 0xF0: 0xf0==4, 0xe0==3, 0xc0==2,
1019
+ ** else 1. */
10591020
case 0xF0: end+=3; break;
10601021
case 0xE0: end+=2; break;
10611022
case 0xC0: end+=1; break;
10621023
default: return 0;
10631024
}
@@ -2886,11 +2847,10 @@
28862847
}
28872848
}
28882849
if( rndr.make.codespan ) rndr.active_char['`'] = char_codespan;
28892850
if( rndr.make.linebreak ) rndr.active_char['\n'] = char_linebreak;
28902851
if( rndr.make.image || rndr.make.link ) rndr.active_char['['] = char_link;
2891
- rndr.active_char['@'] = char_atref_tag;
28922852
rndr.active_char['#'] = char_hashref_tag;
28932853
if( rndr.make.footnote_ref ) rndr.active_char['('] = char_footnote;
28942854
rndr.active_char['<'] = char_langle_tag;
28952855
rndr.active_char['\\'] = char_escape;
28962856
rndr.active_char['&'] = char_entity;
28972857
--- src/markdown.c
+++ src/markdown.c
@@ -42,11 +42,10 @@
42 MKDA_IMPLICIT_EMAIL /* e-mail link without mailto: */
43 };
44
45 /* mkd_tagspan -- type of tagged <span> */
46 enum mkd_tagspan {
47 MKDT_ATREF, /* @name references, as in /chat attention targeting */
48 MKDT_HASHTAG, /* #hashtags */
49 MKDT_NUMTAG /* #123[.456] /chat or /forum message IDs. */
50 };
51
52 /* mkd_renderer -- functions for rendering parsed data */
@@ -960,48 +959,10 @@
960 blob_append(ob, data, end);
961 }
962 return end;
963 }
964
965 /* char_atref_tag -- '@' followed by "word" characters to tag
966 * at-references */
967 static size_t char_atref_tag(
968 struct Blob *ob,
969 struct render *rndr,
970 char *data,
971 size_t offset,
972 size_t size
973 ){
974 size_t end;
975 struct Blob work = BLOB_INITIALIZER;
976
977 if(offset>0 && !fossil_isspace(data[-1])){
978 /* Only ever match if the *previous* character is
979 whitespace or we're at the start of the input. */
980 return 0;
981 }
982 /*fprintf(stderr,"@-REF: %.*s\n", (int)size, data);*/
983 if (size < 2 || !fossil_isalpha(data[1])) return 0;
984 for (end = 2; (end < size)
985 && (fossil_isalnum(data[end])
986 /* TODO: email addresses are legal fossil user names, but
987 parsing those is beyond our current ambitions.
988 Similarly, non-ASCII names are legal, but not
989 currently handled here. */
990 /*|| data[end] == '.' || data[end] == '_'
991 || data[end] == '-'*/);
992 ++end);
993 if(end<size){
994 if(!fossil_isspace(data[end])){
995 return 0;
996 }
997 }
998 blob_init(&work, data + 1, end - 1);
999 rndr->make.tagspan(ob, &work, MKDT_ATREF, rndr->make.opaque);
1000 return end;
1001 }
1002
1003 /* char_hashref_tag -- '#' followed by "word" characters to tag
1004 ** post numbers, hashtags, etc.
1005 **
1006 ** Basic syntax:
1007 **
@@ -1038,14 +999,14 @@
1038 int nUscore = 0; /* Consecutive underscore counter */
1039 int numberMode = 0 /* 0 for normal, 1 for #NNN numeric,
1040 and 2 for #NNN.NNN. */;
1041 if(offset>0 && !fossil_isspace(data[-1])){
1042 /* Only ever match if the *previous* character is whitespace or
1043 we're at the start of the input. Note that we rely on fossil
1044 processing emphasis markup before reaching this function, so
1045 *#Hash* will Do The Right Thing. Not that this means that
1046 "#Hash." will match while ".#Hash" won't. That's okay. */
1047 return 0;
1048 }
1049 assert( '#' == data[0] );
1050 if(size < 2) return 0;
1051 end = 2;
@@ -1052,12 +1013,12 @@
1052 if(fossil_isdigit(data[1])){
1053 numberMode = 1;
1054 }else if(!fossil_isalpha(data[1])){
1055 switch(data[1] & 0xF0){
1056 /* Reminder: UTF8 char lengths can be determined by
1057 masking against 0xF0: 0xf0==4, 0xe0==3, 0xc0==2,
1058 else 1. */
1059 case 0xF0: end+=3; break;
1060 case 0xE0: end+=2; break;
1061 case 0xC0: end+=1; break;
1062 default: return 0;
1063 }
@@ -2886,11 +2847,10 @@
2886 }
2887 }
2888 if( rndr.make.codespan ) rndr.active_char['`'] = char_codespan;
2889 if( rndr.make.linebreak ) rndr.active_char['\n'] = char_linebreak;
2890 if( rndr.make.image || rndr.make.link ) rndr.active_char['['] = char_link;
2891 rndr.active_char['@'] = char_atref_tag;
2892 rndr.active_char['#'] = char_hashref_tag;
2893 if( rndr.make.footnote_ref ) rndr.active_char['('] = char_footnote;
2894 rndr.active_char['<'] = char_langle_tag;
2895 rndr.active_char['\\'] = char_escape;
2896 rndr.active_char['&'] = char_entity;
2897
--- src/markdown.c
+++ src/markdown.c
@@ -42,11 +42,10 @@
42 MKDA_IMPLICIT_EMAIL /* e-mail link without mailto: */
43 };
44
45 /* mkd_tagspan -- type of tagged <span> */
46 enum mkd_tagspan {
 
47 MKDT_HASHTAG, /* #hashtags */
48 MKDT_NUMTAG /* #123[.456] /chat or /forum message IDs. */
49 };
50
51 /* mkd_renderer -- functions for rendering parsed data */
@@ -960,48 +959,10 @@
959 blob_append(ob, data, end);
960 }
961 return end;
962 }
963
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
964 /* char_hashref_tag -- '#' followed by "word" characters to tag
965 ** post numbers, hashtags, etc.
966 **
967 ** Basic syntax:
968 **
@@ -1038,14 +999,14 @@
999 int nUscore = 0; /* Consecutive underscore counter */
1000 int numberMode = 0 /* 0 for normal, 1 for #NNN numeric,
1001 and 2 for #NNN.NNN. */;
1002 if(offset>0 && !fossil_isspace(data[-1])){
1003 /* Only ever match if the *previous* character is whitespace or
1004 ** we're at the start of the input. Note that we rely on fossil
1005 ** processing emphasis markup before reaching this function, so
1006 ** *#Hash* will Do The Right Thing. Not that this means that
1007 ** "#Hash." will match while ".#Hash" won't. That's okay. */
1008 return 0;
1009 }
1010 assert( '#' == data[0] );
1011 if(size < 2) return 0;
1012 end = 2;
@@ -1052,12 +1013,12 @@
1013 if(fossil_isdigit(data[1])){
1014 numberMode = 1;
1015 }else if(!fossil_isalpha(data[1])){
1016 switch(data[1] & 0xF0){
1017 /* Reminder: UTF8 char lengths can be determined by
1018 ** masking against 0xF0: 0xf0==4, 0xe0==3, 0xc0==2,
1019 ** else 1. */
1020 case 0xF0: end+=3; break;
1021 case 0xE0: end+=2; break;
1022 case 0xC0: end+=1; break;
1023 default: return 0;
1024 }
@@ -2886,11 +2847,10 @@
2847 }
2848 }
2849 if( rndr.make.codespan ) rndr.active_char['`'] = char_codespan;
2850 if( rndr.make.linebreak ) rndr.active_char['\n'] = char_linebreak;
2851 if( rndr.make.image || rndr.make.link ) rndr.active_char['['] = char_link;
 
2852 rndr.active_char['#'] = char_hashref_tag;
2853 if( rndr.make.footnote_ref ) rndr.active_char['('] = char_footnote;
2854 rndr.active_char['<'] = char_langle_tag;
2855 rndr.active_char['\\'] = char_escape;
2856 rndr.active_char['&'] = char_entity;
2857
--- src/markdown_html.c
+++ src/markdown_html.c
@@ -847,12 +847,10 @@
847847
/* no-op */
848848
}else{
849849
char cPrefix = '!';
850850
blob_append_literal(ob, "<span data-");
851851
switch (type) {
852
- case MKDT_ATREF:
853
- cPrefix = '@'; blob_append_literal(ob, "atref"); break;
854852
case MKDT_HASHTAG:
855853
cPrefix = '#'; blob_append_literal(ob, "hashtag"); break;
856854
case MKDT_NUMTAG:
857855
cPrefix = '#'; blob_append_literal(ob, "numtag"); break;
858856
}
859857
--- src/markdown_html.c
+++ src/markdown_html.c
@@ -847,12 +847,10 @@
847 /* no-op */
848 }else{
849 char cPrefix = '!';
850 blob_append_literal(ob, "<span data-");
851 switch (type) {
852 case MKDT_ATREF:
853 cPrefix = '@'; blob_append_literal(ob, "atref"); break;
854 case MKDT_HASHTAG:
855 cPrefix = '#'; blob_append_literal(ob, "hashtag"); break;
856 case MKDT_NUMTAG:
857 cPrefix = '#'; blob_append_literal(ob, "numtag"); break;
858 }
859
--- src/markdown_html.c
+++ src/markdown_html.c
@@ -847,12 +847,10 @@
847 /* no-op */
848 }else{
849 char cPrefix = '!';
850 blob_append_literal(ob, "<span data-");
851 switch (type) {
 
 
852 case MKDT_HASHTAG:
853 cPrefix = '#'; blob_append_literal(ob, "hashtag"); break;
854 case MKDT_NUMTAG:
855 cPrefix = '#'; blob_append_literal(ob, "numtag"); break;
856 }
857

Keyboard Shortcuts

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