-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(remark): exposed "defaultRemarkPlugins" option
- Loading branch information
Showing
26 changed files
with
310 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'typedoc-plugin-remark': minor | ||
--- | ||
|
||
- Exposed "defaultRemarkPlugins" option to configure which remark plugins are loaded by default (#735). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
...edoc-plugin-remark/src/options/helpers.ts → ...edoc-plugin-remark/src/helpers/add-toc.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
packages/typedoc-plugin-remark/src/helpers/get-default-plugins.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { getDefaultPlugins } from './get-default-plugins'; | ||
|
||
describe('getDefaultPlugins', () => { | ||
it('should return an empty array when all flags are false', () => { | ||
const defaultPluginsFlag = { | ||
gfm: false, | ||
frontmatter: false, | ||
mdx: false, | ||
}; | ||
|
||
const result = getDefaultPlugins(defaultPluginsFlag); | ||
|
||
expect(result).toEqual([]); | ||
}); | ||
|
||
it('should include remark-frontmatter when frontmatter flag is true', () => { | ||
const defaultPluginsFlag = { | ||
gfm: false, | ||
frontmatter: true, | ||
mdx: false, | ||
}; | ||
|
||
const result = getDefaultPlugins(defaultPluginsFlag); | ||
|
||
expect(result).toEqual([['remark-frontmatter', ['yaml']]]); | ||
}); | ||
|
||
it('should include remark-gfm when gfm flag is true', () => { | ||
const defaultPluginsFlag = { | ||
gfm: true, | ||
frontmatter: false, | ||
mdx: false, | ||
}; | ||
|
||
const result = getDefaultPlugins(defaultPluginsFlag); | ||
|
||
expect(result).toEqual(['remark-gfm']); | ||
}); | ||
|
||
it('should include remark-mdx when mdx flag is true', () => { | ||
const defaultPluginsFlag = { | ||
gfm: false, | ||
frontmatter: false, | ||
mdx: true, | ||
}; | ||
|
||
const result = getDefaultPlugins(defaultPluginsFlag); | ||
|
||
expect(result).toEqual(['remark-mdx']); | ||
}); | ||
|
||
it('should include all plugins when all flags are true', () => { | ||
const defaultPluginsFlag = { | ||
gfm: true, | ||
frontmatter: true, | ||
mdx: true, | ||
}; | ||
|
||
const result = getDefaultPlugins(defaultPluginsFlag); | ||
|
||
expect(result).toEqual([ | ||
['remark-frontmatter', ['yaml']], | ||
'remark-gfm', | ||
'remark-mdx', | ||
]); | ||
}); | ||
}); |
23 changes: 23 additions & 0 deletions
23
packages/typedoc-plugin-remark/src/helpers/get-default-plugins.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { RemarkPlugin } from '../types/remark-plugin.js'; | ||
|
||
export function getDefaultPlugins(defaultPluginsFlag: { | ||
gfm: boolean; | ||
frontmatter: boolean; | ||
mdx: boolean; | ||
}) { | ||
const defaultPlugins: RemarkPlugin[] = []; | ||
|
||
if (defaultPluginsFlag.frontmatter) { | ||
defaultPlugins.push(['remark-frontmatter', ['yaml']]); | ||
} | ||
|
||
if (defaultPluginsFlag.gfm) { | ||
defaultPlugins.push('remark-gfm'); | ||
} | ||
|
||
if (defaultPluginsFlag.mdx) { | ||
defaultPlugins.push('remark-mdx'); | ||
} | ||
|
||
return defaultPlugins; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.