Fossil SCM
Bug fixes in Pandoc identifier generation.
Commit
77cbe291af18a151c8c604925f7ec5b94d6876aef57619b6ed749d878211cc97
Parent
6142e11d202d9a3…
1 file changed
+13
-12
+13
-12
| --- src/markdown_html.c | ||
| +++ src/markdown_html.c | ||
| @@ -99,43 +99,43 @@ | ||
| 99 | 99 | ** * Replace all whitespace sequences with a single "-" |
| 100 | 100 | ** * Remove all characters other than alphanumeric, "_", "-", and ".". |
| 101 | 101 | ** * Convert all alphabetics to lower case. |
| 102 | 102 | ** * If nothing remains, use "section" as the identifier. |
| 103 | 103 | */ |
| 104 | - while( nText>0 && !fossil_isalpha(zText[nText-1]) ){ nText--; } | |
| 105 | 104 | memcpy(pNew->zTag, zText, nText); |
| 106 | 105 | pNew->zTag[nText] = 0; |
| 107 | 106 | zTag = pNew->zTag; |
| 108 | 107 | for(i=j=0; zTag[i]; i++){ |
| 109 | - if( fossil_isupper(zTag[i]) ){ | |
| 108 | + char c = zTag[i]; | |
| 109 | + if( fossil_isupper(c) ){ | |
| 110 | 110 | if( !seenChar ){ j = 0; seenChar = 1; } |
| 111 | - zTag[j++] = fossil_tolower(zTag[i]); | |
| 111 | + zTag[j++] = fossil_tolower(c); | |
| 112 | 112 | continue; |
| 113 | 113 | } |
| 114 | - if( fossil_islower(zTag[i]) ){ | |
| 114 | + if( fossil_islower(c) ){ | |
| 115 | 115 | if( !seenChar ){ j = 0; seenChar = 1; } |
| 116 | - zTag[j++] = zTag[i]; | |
| 116 | + zTag[j++] = c; | |
| 117 | 117 | continue; |
| 118 | 118 | } |
| 119 | - if( zTag[i]=='<' ){ | |
| 119 | + if( c=='<' ){ | |
| 120 | 120 | i += html_tag_length(zTag+i) - 1; |
| 121 | 121 | continue; |
| 122 | 122 | } |
| 123 | - if( zTag[i]=='&' ){ | |
| 123 | + if( c=='&' ){ | |
| 124 | 124 | while( zTag[i] && zTag[i]!=';' ){ i++; } |
| 125 | 125 | if( zTag[i]==0 ) break; |
| 126 | 126 | continue; |
| 127 | 127 | } |
| 128 | - if( fossil_isspace(zTag[i]) ){ | |
| 129 | - zTag[j++] = '-'; | |
| 128 | + if( fossil_isspace(c) ){ | |
| 129 | + if( j && zTag[j-1]!='-' ) zTag[j++] = '-'; | |
| 130 | 130 | while( fossil_isspace(zTag[i+1]) ){ i++; } |
| 131 | 131 | continue; |
| 132 | 132 | } |
| 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++] = '-'; | |
| 135 | 135 | }else{ |
| 136 | - zTag[j++] = zTag[i]; | |
| 136 | + zTag[j++] = c; | |
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | if( j==0 || !seenChar ){ |
| 140 | 140 | memcpy(zTag, "section", 7); |
| 141 | 141 | j = 7; |
| @@ -146,10 +146,11 @@ | ||
| 146 | 146 | /* Search for duplicate identifiers and disambiguate */ |
| 147 | 147 | pNew->nth = 0; |
| 148 | 148 | for(pSearch=pNew->pPrev; pSearch; pSearch=pSearch->pPrev){ |
| 149 | 149 | if( strcmp(pSearch->zTag,zTag)==0 ){ |
| 150 | 150 | pNew->nth = pSearch->nth+1; |
| 151 | + break; | |
| 151 | 152 | } |
| 152 | 153 | } |
| 153 | 154 | } |
| 154 | 155 | |
| 155 | 156 | |
| 156 | 157 |
| --- 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 |