feat: support reference-style linking in documents (#1048)

feat: support reference-style linking in documents
This commit is contained in:
Blaine Bublitz 2018-10-26 21:33:44 -07:00 committed by Endilie Yacop Sucipto
parent 7488de266f
commit bbf355fdc7
7 changed files with 180 additions and 14 deletions

View file

@ -55,9 +55,15 @@ const doc3 = fs.readFileSync(
'utf8',
);
const refLinks = fs.readFileSync(
path.join(__dirname, '__fixtures__', 'reflinks.md'),
'utf8',
);
const rawContent1 = metadataUtils.extractMetadata(doc1).rawContent;
const rawContent2 = metadataUtils.extractMetadata(doc2).rawContent;
const rawContent3 = metadataUtils.extractMetadata(doc3).rawContent;
const rawContentRefLinks = metadataUtils.extractMetadata(refLinks).rawContent;
describe('mdToHtmlify', () => {
const mdToHtml = metadataUtils.mdToHtml(Metadata, '/');
@ -105,6 +111,17 @@ describe('mdToHtmlify', () => {
expect(content3).toMatchSnapshot();
expect(content3).not.toEqual(rawContent3);
});
test('transforms reference links', () => {
const contentRefLinks = docs.mdToHtmlify(
rawContentRefLinks,
mdToHtml,
Metadata['en-reflinks'],
);
expect(contentRefLinks).toContain('/docs/en/next/');
expect(contentRefLinks).toMatchSnapshot();
expect(contentRefLinks).not.toEqual(rawContentRefLinks);
});
});
describe('getFile', () => {