typescriptmd
Version:
A type-safe, component-based markdown engine for TypeScript
181 lines (124 loc) • 3.53 kB
Markdown

A type-safe, component based markdown engine for embedding markdown content with TypeScript.
Create dynamic, template-driven markdown with full type support.
> ⚠️ **Early Alpha**: This library is in early alpha and is not stable for production applications.
1. **TypeScript Integration** - Full TypeScript support with type checking and IntelliSense
2. **Template Interpolation** - Dynamic content with `{{ expression }}` syntax
3. **Conditional Rendering** - Smart conditional blocks with ternary operators and logical AND
4. **Developer Tools** - Comprehensive CLI, VS Code extension, and testing utilities
```bash
npm install typescriptmd
bun add typescriptmd
```
```bash
mkdir tsmd
```
```ts
// /tsmd/Welcome.tsmd
function Welcome() {
const appName = 'My App';
const version = '1.0.0';
const isProduction = false;
return (
Current version: **{{ version }}**
{{ isProduction ? (
) : (
) }}
)
}
```
```bash
npm run typescriptmd
```
Then, you will see `.ts` files output in `/tsmd/_generated`
Use `{{ expression }}` to embed dynamic content:
```ts
function UserProfile() {
const user = { name: 'Alice', age: 30, skills: ['React', 'TypeScript'] };
return (
**Age:** {{ user.age }}
**Skills:** {{ user.skills.join(', ') }}
**Bio:** {{ user.age > 25 ? 'Experienced developer' : 'Junior developer' }}
)
}
```
Create dynamic content with conditional blocks:
```ts
function Dashboard() {
const { user, isLoggedIn } = useAuth();
const notifications = getNotifications();
return (
{{ isLoggedIn && (
Welcome back, {{ user.name }}!
) }}
{{ !isLoggedIn && (
Please [log in](./login) to continue.
) }}
{{ notifications.length > 0 && (
{{ notifications.map(n => `- ${n.message}`).join('\n') }}
) }}
{{ notifications.length === 0 && (
No new notifications.
) }}
)
}
```
Use components with the `<@ComponentName/>` syntax:
```ts
import { FeatureDetailView } from './components';
function Homepage() {
const features = ['Fast', 'Type-safe', 'Developer-friendly'];
return (
Get started in minutes with our powerful framework.
{{ features.map(feature => (
<@FeatureDetailView feature="${feature}" />
) }}
)
}
```
Install the TS Markdown VS Code extension for:
- **Syntax highlighting** for TSMD files
- **IntelliSense** for template expressions
- **Live preview** of TSMD content
We welcome contributions!
```bash
git clone https://github.com/andrewtdiz/tsmarkdown
cd tsmarkdown
npm install
npm run dev
```
```bash
npm test
npm test --coverage
```
MIT © [TS Markdown Team](https://github.com/andrewtdiz/tsmarkdown)
- [Documentation](https://tsmarkdown.dev)
- [VS Code Extension](https://marketplace.visualstudio.com/items?itemName=TSMarkdown.tsmarkdown-extension)
---
Made with ❤️ by the TS Markdown team