diff --git a/__tests__/renderer-spec.tsx b/__tests__/renderer-spec.tsx
index 9a0a1d7..46cab12 100644
--- a/__tests__/renderer-spec.tsx
+++ b/__tests__/renderer-spec.tsx
@@ -129,3 +129,29 @@ test('should render image without attributes', () => {
''
);
});
+
+test('should render link with text and title', () => {
+ expect(
+ (render(
+
+ some text
+
+ ) as string).trim()
+ ).toBe('[some text](./test "some title")');
+});
+
+test('should render link with only text', () => {
+ expect((render(some text) as string).trim()).toBe(
+ '[some text](./test)'
+ );
+});
+
+test('should render link with only title', () => {
+ expect(
+ (render() as string).trim()
+ ).toBe('[](./test "some title")');
+});
+
+test('should render link without title and text', () => {
+ expect((render() as string).trim()).toBe('[](./test)');
+});
diff --git a/src/tagHandler.ts b/src/tagHandler.ts
index c2abb9c..8e92d74 100644
--- a/src/tagHandler.ts
+++ b/src/tagHandler.ts
@@ -2,11 +2,12 @@ import {
emphasis,
heading,
image,
+ link,
list,
listItem,
strong,
} from 'mdast-builder';
-import { ImgHTMLAttributes } from 'react';
+import { AnchorHTMLAttributes, ImgHTMLAttributes } from 'react';
// tslint:disable-next-line: no-implicit-dependencies
import { Node as MDASTNode, Parent as MDASTParent } from 'unist';
@@ -76,6 +77,18 @@ export default function handleTag(
}
// END - Handle img tag - with src and alt
+ // START - Handle anchor tag (link)
+ case 'a': {
+ const props = node.props as AnchorHTMLAttributes;
+ let href = '';
+ if (props.href !== undefined) {
+ href = props.href;
+ }
+ newParentASTNode = childASTNode = link(href, props.title);
+ break;
+ }
+ // END - Handle anchor tag (link)
+
default:
newParentASTNode = parentASTNode;
break;