File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -220,7 +220,13 @@ class _RelativeUrlRewriter extends html_parsing.TreeVisitor {
220
220
super .visitElement (element);
221
221
222
222
// check current element
223
- if (element.localName == 'a' ) {
223
+ if (element.localName == 'a' &&
224
+ element.attributes.length == 1 &&
225
+ element.attributes.containsKey ('name' ) &&
226
+ element.attributes['name' ]! .isNotEmpty &&
227
+ element.nodes.isEmpty) {
228
+ // allow name anchor without any other attribute or content
229
+ } else if (element.localName == 'a' ) {
224
230
_updateUrlAttributes (element, 'href' );
225
231
} else if (element.localName == 'img' ) {
226
232
_updateUrlAttributes (element, 'src' , raw: true );
Original file line number Diff line number Diff line change @@ -27,6 +27,16 @@ void main() {
27
27
'</ul>\n ' ,
28
28
);
29
29
});
30
+
31
+ test ('named anchor' , () {
32
+ expect (
33
+ markdownToHtml ('<a name="abc"></a>' ), '<p><a name="abc"></a></p>\n ' );
34
+ });
35
+
36
+ test ('named anchor with other content' , () {
37
+ expect (markdownToHtml ('<a name="abc" other="1"></a>' ), '<p></p>\n ' );
38
+ expect (markdownToHtml ('<a name="abc">x</a>' ), '<p>x</p>\n ' );
39
+ });
30
40
});
31
41
32
42
group ('Valid custom base URL' , () {
You can’t perform that action at this time.
0 commit comments