-
-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Labels
Description
Example, if I want to include this fragment
Lines 27 to 50 in 12c91a4
| /** | |
| * Process template. | |
| * | |
| * @returns {Promise} | |
| */ | |
| gitdown.get = () => { | |
| return parser | |
| .play(input) | |
| .then((state) => { | |
| let markdown; | |
| markdown = state.markdown; | |
| if (gitdown.getConfig().headingNesting.enabled) { | |
| markdown = Gitdown.nestHeadingIds(markdown); | |
| } | |
| return gitdown | |
| .resolveURLs(markdown) | |
| .then(() => { | |
| return markdown.replace(/<!--\sgitdown:\s(:?off|on)\s-->/g, ''); | |
| }); | |
| }); | |
| }; |
I would surround the code fragment with comments such as:
// gitdown-template-start: foo-fragment
/**
* Process template.
*
* @returns {Promise}
*/
gitdown.get = () => {
return parser
.play(input)
.then((state) => {
let markdown;
markdown = state.markdown;
if (gitdown.getConfig().headingNesting.enabled) {
markdown = Gitdown.nestHeadingIds(markdown);
}
return gitdown
.resolveURLs(markdown)
.then(() => {
return markdown.replace(/<!--\sgitdown:\s(:?off|on)\s-->/g, '');
});
});
};
// gitdown-template-end: foo-fragmentwhere "foo-fragment" is name of the fragment.
Then this snippet can be included into a README document using:
{"gitdown": "snippet", "file": "./src/gitdown.js", "name": "foo-fragment"}This would be used to inject type declarations, etc. to documentation without needing to repeat them.
drobertson123, ManuelVargas1251 and awhitford