Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
lzilioli committed Jun 6, 2024
1 parent 2bf99f0 commit 3fa2707
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 33 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Extensible macro processing framework for markdown, written in TypeScript.
# Table of Contents

- [md-macros](#md-macros)
- [Breaking changes in v7.0.0](#breaking-changes-in-v-7-0-0)
- [Overview](#overview)
- [Sample Use Case](#sample-use-case)
- [Usage](#usage)
Expand All @@ -27,6 +28,16 @@ Extensible macro processing framework for markdown, written in TypeScript.
- [args](#args)
- [Custom macros](#custom-macros)


## Breaking changes in v7.0.0

In order to call a macro, you must now precede the text with `macro:`. e.g.
`\\[[youtube url="url"]]` must now be written as `\\[[macro:youtube url="url"]]`.

This is so that we can add support for parsing of wiki-style linking in the future,
and so that the macro system does not collide with common markdown applications,
which use wiki-style linking.

# Overview

There have been lots of requests and proposals over the years for an official spec for a rich and extensible version of markdown. People want to be able to write clean and succinct text in their markdown files, and have it rendered into complex html components, without the need for inline html in their markdown files.
Expand Down
10 changes: 10 additions & 0 deletions README.tmpl.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ Extensible macro processing framework for markdown, written in TypeScript.

[[macro:mdToc]]


## Breaking changes in v7.0.0

In order to call a macro, you must now precede the text with `macro:`. e.g.
`\\[[youtube url="url"]]` must now be written as `\\[[macro:youtube url="url"]]`.

This is so that we can add support for parsing of wiki-style linking in the future,
and so that the macro system does not collide with common markdown applications,
which use wiki-style linking.

# Overview

There have been lots of requests and proposals over the years for an official spec for a rich and extensible version of markdown. People want to be able to write clean and succinct text in their markdown files, and have it rendered into complex html components, without the need for inline html in their markdown files.
Expand Down
46 changes: 13 additions & 33 deletions lib/parse-macros-from-md.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -813,39 +813,6 @@ but not #1: test but #what. is cool but should remove the period.`;
assert.deepEqual(macros, expected);
});

it('can differentiate between wiki-style links and macro calls', () => {
const md: string = `[[this is a wiki link]]
[[this is a wiki link|So is this]]
[[this is a wiki link#toasection|This one links to a section]]
`;
const macros: ParsedMacros = parseMacrosFromMd(md);
console.log(JSON.stringify(macros, null, 2));
const expected: ParsedMacros = {
...EMPTY_PARSE_RESULTS,
custom: [],
links: [{
altText: 'this is a wiki link',
fullMatch: '[[this is a wiki link]]',
href: 'this is a wiki link',
isReferenceStyle: false,
title: '',
}, {
altText: 'So is this',
fullMatch: '[[this is a wiki link|So is this]]',
href: 'this is a wiki link',
isReferenceStyle: false,
title: 'So is this',
}, {
altText: 'This one links to a section',
fullMatch: '[[this is a wiki link#toasection|This one links to a section]]',
href: 'this is a wiki link#toasection',
isReferenceStyle: false,
title: 'This one links to a section',
}],
};
assert.deepEqual(macros, expected);
});

it('skips over tags within blockquotes', () => {
const md: string = `# Hello
Expand Down Expand Up @@ -1035,4 +1002,17 @@ Ahh. Thats right.
};
assert.deepEqual(macros, expected);
});

it('does not parse out wiki-style links as macros', () => {
const md: string = `[[this is a wiki link]]
[[this is a wiki link|So is this]]
[[this is a wiki link#toasection|This one links to a section]]
`;
const macros: ParsedMacros = parseMacrosFromMd(md);
console.log(JSON.stringify(macros, null, 2));
const expected: ParsedMacros = {
...EMPTY_PARSE_RESULTS,
};
assert.deepEqual(macros, expected);
});
}

0 comments on commit 3fa2707

Please sign in to comment.