md2adaptivecard
v1.0.1
Published
Convert Markdown to Adaptive Cards
Maintainers
Readme
md2adaptivecard
Convert Markdown to Adaptive Cards for Microsoft Teams and other Adaptive Card hosts.
Try it out: https://heyitsaamir.github.io/markdown2adaptivecard/
Installation
npm install md2adaptivecardUsage
import { Lexer } from 'marked';
import { MarkdownToACParser } from 'md2adaptivecard';
const markdown = `
# Hello World
This is a **bold** statement with some *italic* text.
- Item 1
- Item 2
\`\`\`js
console.log("hello");
\`\`\`
`;
const tokens = new Lexer().lex(markdown);
const parser = new MarkdownToACParser();
const adaptiveCardJson = parser.parse(tokens);
console.log(adaptiveCardJson);API
MarkdownToACParser
The main parser class. Accepts marked tokens and produces an Adaptive Card JSON string.
parse(tokens: Token[]): string
Parses an array of marked tokens and returns the Adaptive Card as a JSON string.
parseInline(tokens: Token[]): TextRun[]
Parses inline tokens (bold, italic, links, etc.) and returns an array of TextRun objects.
ACRenderer
The renderer class that builds the Adaptive Card. Exposed for advanced use cases where you need direct control over card construction.
Dependencies
marked— Markdown lexer/tokenizer@microsoft/teams.cards— Adaptive Card type builders
Disclaimer
This project is not affiliated with, endorsed by, or sponsored by Microsoft.
License
MIT
