Fossil SCM

Bug fixes in Pandoc identifier generation.

drh 2020-09-15 20:10 auto-toc
Commit 77cbe291af18a151c8c604925f7ec5b94d6876aef57619b6ed749d878211cc97
1 file changed +13 -12
--- src/markdown_html.c
+++ src/markdown_html.c
@@ -99,43 +99,43 @@
9999
** * Replace all whitespace sequences with a single "-"
100100
** * Remove all characters other than alphanumeric, "_", "-", and ".".
101101
** * Convert all alphabetics to lower case.
102102
** * If nothing remains, use "section" as the identifier.
103103
*/
104
- while( nText>0 && !fossil_isalpha(zText[nText-1]) ){ nText--; }
105104
memcpy(pNew->zTag, zText, nText);
106105
pNew->zTag[nText] = 0;
107106
zTag = pNew->zTag;
108107
for(i=j=0; zTag[i]; i++){
109
- if( fossil_isupper(zTag[i]) ){
108
+ char c = zTag[i];
109
+ if( fossil_isupper(c) ){
110110
if( !seenChar ){ j = 0; seenChar = 1; }
111
- zTag[j++] = fossil_tolower(zTag[i]);
111
+ zTag[j++] = fossil_tolower(c);
112112
continue;
113113
}
114
- if( fossil_islower(zTag[i]) ){
114
+ if( fossil_islower(c) ){
115115
if( !seenChar ){ j = 0; seenChar = 1; }
116
- zTag[j++] = zTag[i];
116
+ zTag[j++] = c;
117117
continue;
118118
}
119
- if( zTag[i]=='<' ){
119
+ if( c=='<' ){
120120
i += html_tag_length(zTag+i) - 1;
121121
continue;
122122
}
123
- if( zTag[i]=='&' ){
123
+ if( c=='&' ){
124124
while( zTag[i] && zTag[i]!=';' ){ i++; }
125125
if( zTag[i]==0 ) break;
126126
continue;
127127
}
128
- if( fossil_isspace(zTag[i]) ){
129
- zTag[j++] = '-';
128
+ if( fossil_isspace(c) ){
129
+ if( j && zTag[j-1]!='-' ) zTag[j++] = '-';
130130
while( fossil_isspace(zTag[i+1]) ){ i++; }
131131
continue;
132132
}
133
- if( !fossil_isalnum(zTag[i]) && zTag[i]!='.' && zTag[i]!='_' ){
134
- zTag[j++] = '-';
133
+ if( !fossil_isalnum(c) && c!='.' && c!='_' && c!='-' ){
134
+ if( j && zTag[j-1]!='-' ) zTag[j++] = '-';
135135
}else{
136
- zTag[j++] = zTag[i];
136
+ zTag[j++] = c;
137137
}
138138
}
139139
if( j==0 || !seenChar ){
140140
memcpy(zTag, "section", 7);
141141
j = 7;
@@ -146,10 +146,11 @@
146146
/* Search for duplicate identifiers and disambiguate */
147147
pNew->nth = 0;
148148
for(pSearch=pNew->pPrev; pSearch; pSearch=pSearch->pPrev){
149149
if( strcmp(pSearch->zTag,zTag)==0 ){
150150
pNew->nth = pSearch->nth+1;
151
+ break;
151152
}
152153
}
153154
}
154155
155156
156157
--- src/markdown_html.c
+++ src/markdown_html.c
@@ -99,43 +99,43 @@
99 ** * Replace all whitespace sequences with a single "-"
100 ** * Remove all characters other than alphanumeric, "_", "-", and ".".
101 ** * Convert all alphabetics to lower case.
102 ** * If nothing remains, use "section" as the identifier.
103 */
104 while( nText>0 && !fossil_isalpha(zText[nText-1]) ){ nText--; }
105 memcpy(pNew->zTag, zText, nText);
106 pNew->zTag[nText] = 0;
107 zTag = pNew->zTag;
108 for(i=j=0; zTag[i]; i++){
109 if( fossil_isupper(zTag[i]) ){
 
110 if( !seenChar ){ j = 0; seenChar = 1; }
111 zTag[j++] = fossil_tolower(zTag[i]);
112 continue;
113 }
114 if( fossil_islower(zTag[i]) ){
115 if( !seenChar ){ j = 0; seenChar = 1; }
116 zTag[j++] = zTag[i];
117 continue;
118 }
119 if( zTag[i]=='<' ){
120 i += html_tag_length(zTag+i) - 1;
121 continue;
122 }
123 if( zTag[i]=='&' ){
124 while( zTag[i] && zTag[i]!=';' ){ i++; }
125 if( zTag[i]==0 ) break;
126 continue;
127 }
128 if( fossil_isspace(zTag[i]) ){
129 zTag[j++] = '-';
130 while( fossil_isspace(zTag[i+1]) ){ i++; }
131 continue;
132 }
133 if( !fossil_isalnum(zTag[i]) && zTag[i]!='.' && zTag[i]!='_' ){
134 zTag[j++] = '-';
135 }else{
136 zTag[j++] = zTag[i];
137 }
138 }
139 if( j==0 || !seenChar ){
140 memcpy(zTag, "section", 7);
141 j = 7;
@@ -146,10 +146,11 @@
146 /* Search for duplicate identifiers and disambiguate */
147 pNew->nth = 0;
148 for(pSearch=pNew->pPrev; pSearch; pSearch=pSearch->pPrev){
149 if( strcmp(pSearch->zTag,zTag)==0 ){
150 pNew->nth = pSearch->nth+1;
 
151 }
152 }
153 }
154
155
156
--- src/markdown_html.c
+++ src/markdown_html.c
@@ -99,43 +99,43 @@
99 ** * Replace all whitespace sequences with a single "-"
100 ** * Remove all characters other than alphanumeric, "_", "-", and ".".
101 ** * Convert all alphabetics to lower case.
102 ** * If nothing remains, use "section" as the identifier.
103 */
 
104 memcpy(pNew->zTag, zText, nText);
105 pNew->zTag[nText] = 0;
106 zTag = pNew->zTag;
107 for(i=j=0; zTag[i]; i++){
108 char c = zTag[i];
109 if( fossil_isupper(c) ){
110 if( !seenChar ){ j = 0; seenChar = 1; }
111 zTag[j++] = fossil_tolower(c);
112 continue;
113 }
114 if( fossil_islower(c) ){
115 if( !seenChar ){ j = 0; seenChar = 1; }
116 zTag[j++] = c;
117 continue;
118 }
119 if( c=='<' ){
120 i += html_tag_length(zTag+i) - 1;
121 continue;
122 }
123 if( c=='&' ){
124 while( zTag[i] && zTag[i]!=';' ){ i++; }
125 if( zTag[i]==0 ) break;
126 continue;
127 }
128 if( fossil_isspace(c) ){
129 if( j && zTag[j-1]!='-' ) zTag[j++] = '-';
130 while( fossil_isspace(zTag[i+1]) ){ i++; }
131 continue;
132 }
133 if( !fossil_isalnum(c) && c!='.' && c!='_' && c!='-' ){
134 if( j && zTag[j-1]!='-' ) zTag[j++] = '-';
135 }else{
136 zTag[j++] = c;
137 }
138 }
139 if( j==0 || !seenChar ){
140 memcpy(zTag, "section", 7);
141 j = 7;
@@ -146,10 +146,11 @@
146 /* Search for duplicate identifiers and disambiguate */
147 pNew->nth = 0;
148 for(pSearch=pNew->pPrev; pSearch; pSearch=pSearch->pPrev){
149 if( strcmp(pSearch->zTag,zTag)==0 ){
150 pNew->nth = pSearch->nth+1;
151 break;
152 }
153 }
154 }
155
156
157

Keyboard Shortcuts

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