This project allows managing Markdown files through JavaScript/TypeScript
Install using npm
npm i markdown-as-codeInstall using pnpm
pnpm i markdown-as-codeInstall using yarn
yarn add markdown-as-codeRun tests
npm t
# or
npm run test- Run the tests
pnpm timport { Acknowledgements } from 'markdown-as-code';
const content = new Acknowledgements()
.add({
text: 'Acknowledgement',
url: 'https://github.com',
})
.synthesize();import { acknowledgementsSection } from 'markdown-as-code';
const content = acknowledgementsSection()
.add({
text: 'Acknowledgement',
url: 'https://github.com',
})
.synthesize();import { ApiReference } from 'markdown-as-code';
const content = new ApiReference()
.add({
title: 'Get all items',
httpMethod: 'GET',
path: '/api/items',
parameter: {
name: 'api_key',
type: 'string',
description: '**Required**. Your API key',
},
})
.synthesize();import { apiReferenceSection } from 'markdown-as-code';
const content = apiReferenceSection()
.add({
title: 'Get all items',
httpMethod: 'GET',
path: '/api/items',
parameter: {
name: 'api_key',
type: 'string',
description: '**Required**. Your API key',
},
})
.synthesize();import { Appendix } from 'markdown-as-code';
const content = new Appendix().appendContent('Test content').synthesize();import { appendixSection } from 'markdown-as-code';
const content = appendixSection().appendContent('Test content').synthesize();import { Authors } from 'markdown-as-code';
const content = new Authors()
.add({ githubUsername: 'JaneDoe' })
.add({ githubUsername: 'JohnSmith' })
.synthesize();import { authorsSection } from 'markdown-as-code';
const content = authorsSection()
.add({ githubUsername: 'JaneDoe' })
.add({ githubUsername: 'JohnSmith' })
.synthesize();import { ContentSection } from 'markdown-as-code';
const content = new ContentSection('Test Section').synthesize();import { contentSection } from 'markdown-as-code';
const content = contentSection('Test Section').synthesize();import { Contributing } from 'markdown-as-code';
const content = new Contributing().synthesize();import { contributingSection } from 'markdown-as-code';
const content = contributingSection().synthesize();import { EnvironmentVariables } from 'markdown-as-code';
const content = new EnvironmentVariables()
.add({
name: 'API_KEY',
defaultValue: 'YOUR-API-KEY-HERE',
})
.synthesize();import { environmentVariablesSection } from 'markdown-as-code';
const content = environmentVariablesSection()
.add({
name: 'API_KEY',
defaultValue: 'YOUR-API-KEY-HERE',
})
.synthesize();import { Examples } from 'markdown-as-code';
const content = new Examples()
.add({
title: 'Create an example section',
description:
'The title is defaulted to Examples but can be overridden in the constructor',
codeblock: {
language: 'typescript',
code: 'const section = new Examples();',
},
})
.synthesize();import { examplesSection } from 'markdown-as-code';
const content = examplesSection()
.add({
title: 'Create an example section',
description:
'The title is defaulted to Examples but can be overridden in the constructor',
codeblock: {
language: 'typescript',
code: 'const section = new Examples();',
},
})
.synthesize();import { FAQ } from 'markdown-as-code';
const content = new FAQ()
.add({
question: 'Question 1',
answer: 'Answer 1',
})
.synthesize();import { faqSection } from 'markdown-as-code';
const content = faqSection()
.add({
question: 'Question 1',
answer: 'Answer 1',
})
.synthesize();import { Installation } from 'markdown-as-code';
const content = new Installation()
.add({
command: 'npm i markdown-as-code',
description: 'Install using npm',
})
.synthesize();import { installationSection } from 'markdown-as-code';
const content = installationSection()
.add({
command: 'npm i markdown-as-code',
description: 'Install using npm',
})
.synthesize();import { Roadmap } from 'markdown-as-code';
const content = new Roadmap().add({ text: 'Item 1' }).synthesize();import { roadmapSection } from 'markdown-as-code';
const content = roadmapSection().add({ text: 'Item 1' }).synthesize();import { RunLocally } from 'markdown-as-code';
const content = new RunLocally()
.add({
command: 'npm t',
description: 'Run the tests',
})
.synthesize();import { runLocallySection } from 'markdown-as-code';
const content = runLocallySection()
.add({
command: 'npm t',
description: 'Run the tests',
})
.synthesize();import { Support } from 'markdown-as-code';
const support = new Support().appendContent('Test content').synthesize();import { supportSection } from 'markdown-as-code';
const support = supportSection().appendContent('Test content').synthesize();import { TableOfContentsSection, ContentSection } from 'markdown-as-code';
const content = new TableOfContentsSection({
sections: [new ContentSection('Test Section')],
}).synthesize();import { tableOfContentsSection, contentSection } from 'markdown-as-code';
const content = tableOfContentsSection({
sections: [contentSection('Test Section')],
}).synthesize();import { createMarkdownDocument, ContentSection } from 'markdown-as-code';
const content = createMarkdownDocument({
title: 'Test',
fileName: 'test.md',
})
.addSection(new ContentSection('Custom Section', 'Some markdown content'))
.synthContent();import { createReadmeDocument, ContentSection } from 'markdown-as-code';
const content = createReadmeDocument({
title: 'Test',
fileName: 'test.md',
})
.addSection(new ContentSection('Custom Section', 'Some markdown content'))
.synthContent();import { codeBlock } from 'markdown-as-code';
codeBlock({ language: 'typescript', code: 'const testNumber = 1' });import { heading } from 'markdown-as-code';
heading(1, 'Heading Level 1');
heading(2, 'Heading Level 2');
heading(3, 'Heading Level 3');
heading(4, 'Heading Level 4');
heading(5, 'Heading Level 5');
heading(6, 'Heading Level 6');import { image } from 'markdown-as-code';
image('https://via.placeholder.com/150', 'Placeholder Image');import { link } from 'markdown-as-code';
link('Link Text', '');import { orderedList, unorderedList, taskList } from 'markdown-as-code';
orderedList(['Item 1', 'Item 2', 'Item 3']);
unorderedList(['Item 1', 'Item 2', 'Item 3']);
taskList([
{ description: 'Task 1', complete: true },
{ description: 'Task 2', complete: false },
{ description: 'Task 3', complete: true },
]);import { mentionPerson } from 'markdown-as-code';
mentionPerson('AllyMurray');import { quote } from 'markdown-as-code';
quote('This is a quote');import { style } from 'markdown-as-code';
style('Bold', 'Example Bold Text');
style('Italic', 'Example Italic Text');
style('Strikethrough', 'Example Strikethrough Text');
style('Superscript', 'Example Superscript Text');
style('Subscript', 'Example Subscript Text');
style('BoldItalic', 'Example BoldItalic Text');