Repository: dart-lang/pub-dev (dart)

Issue:
Links to <a> tags stopped working on pub.dev
https://pub.dev/packages/context_plus#supported-observable-types
https://github.com/s0nerik/context_plus/tree/main/packages/context_plus#supported-observable-types

Previously, both of these links were navigating to the corresponding section of the README.md file. Recently, it stopped working on pub.dev, but still works on GitHub.

This appears to be a pub.dev bug to me.

The link itself is implemented in the README.md like this:
```markdown
<a name="supported-observable-types"></a>
### Supported observable types for `Observable.watch()` and `Ref<Observable>.watch()`:
```

Pull request description:
Fixes #8794.

Patch:
diff --git a/app/lib/shared/markdown.dart b/app/lib/shared/markdown.dart
index 64dea9fd87..241cc60c8a 100644
--- a/app/lib/shared/markdown.dart
+++ b/app/lib/shared/markdown.dart
@@ -220,7 +220,13 @@ class _RelativeUrlRewriter extends html_parsing.TreeVisitor {
     super.visitElement(element);
 
     // check current element
-    if (element.localName == 'a') {
+    if (element.localName == 'a' &&
+        element.attributes.length == 1 &&
+        element.attributes.containsKey('name') &&
+        element.attributes['name']!.isNotEmpty &&
+        element.nodes.isEmpty) {
+      // allow name anchor without any other attribute or content
+    } else if (element.localName == 'a') {
       _updateUrlAttributes(element, 'href');
     } else if (element.localName == 'img') {
       _updateUrlAttributes(element, 'src', raw: true);


Test patch:
diff --git a/app/test/shared/markdown_test.dart b/app/test/shared/markdown_test.dart
index 7c647fde8b..908d72a450 100644
--- a/app/test/shared/markdown_test.dart
+++ b/app/test/shared/markdown_test.dart
@@ -27,6 +27,16 @@ void main() {
         '</ul>\n',
       );
     });
+
+    test('named anchor', () {
+      expect(
+          markdownToHtml('<a name="abc"></a>'), '<p><a name="abc"></a></p>\n');
+    });
+
+    test('named anchor with other content', () {
+      expect(markdownToHtml('<a name="abc" other="1"></a>'), '<p></p>\n');
+      expect(markdownToHtml('<a name="abc">x</a>'), '<p>x</p>\n');
+    });
   });
 
   group('Valid custom base URL', () {