Compare commits

...

10 Commits

Author SHA1 Message Date
jkunz cd3b6d24fe v3.1.0 2026-05-01 21:57:01 +00:00
jkunz 84b4f355f8 feat(package): modernize package metadata, typings, and test setup for ESM builds 2026-05-01 21:57:01 +00:00
jkunz 2eae324908 chore: remove .gitlab-ci.yml 2026-03-01 18:56:59 +00:00
philkunz 4738e1e0e5 update description 2024-05-29 14:14:38 +02:00
philkunz 1d518b4f55 update tsconfig 2024-04-14 17:57:02 +02:00
philkunz 99718af936 update npmextra.json: githost 2024-04-01 21:36:29 +02:00
philkunz 7a02eeb0dd update npmextra.json: githost 2024-04-01 19:58:55 +02:00
philkunz 65ade5137b update npmextra.json: githost 2024-03-30 21:47:54 +01:00
philkunz dfd39b406a 3.0.3 2024-01-19 21:10:15 +01:00
philkunz 2c9515fb86 fix(core): update 2024-01-19 21:10:14 +01:00
16 changed files with 7706 additions and 19079 deletions
-140
View File
@@ -1,140 +0,0 @@
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: '$CI_BUILD_STAGE'
stages:
- security
- test
- release
- metadata
before_script:
- npm install -g @shipzone/npmci
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci git mirror
only:
- tags
tags:
- lossless
- docker
- notpriv
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --production --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
allow_failure: true
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev
tags:
- docker
allow_failure: true
# ====================
# test stage
# ====================
testStable:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
release:
stage: release
script:
- npmci node install stable
- npmci npm publish
only:
- tags
tags:
- lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
only:
- tags
script:
- npmci command npm install -g typescript
- npmci npm prepare
- npmci npm install
tags:
- lossless
- docker
- priv
trigger:
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- lossless
- docker
- notpriv
pages:
stage: metadata
script:
- npmci node install lts
- npmci command npm install -g @git.zone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags:
- lossless
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
allow_failure: true
+42
View File
@@ -0,0 +1,42 @@
{
"@ship.zone/szci": {
"npmGlobalTools": [],
"npmRegistryUrl": "registry.npmjs.org"
},
"@git.zone/cli": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smartmarkdown",
"shortDescription": "Markdown parsing and conversion utilities",
"description": "Enhances Markdown file handling with parsing, conversion, and frontmatter support.",
"npmPackagename": "@push.rocks/smartmarkdown",
"license": "MIT",
"keywords": [
"markdown",
"html conversion",
"markdown parsing",
"frontmatter",
"remark",
"unified",
"turndown",
"YAML",
"plugin system",
"text processing",
"documentation",
"content management"
]
},
"release": {
"registries": [
"https://verdaccio.lossless.digital",
"https://registry.npmjs.org"
],
"accessLevel": "public"
}
},
"@git.zone/tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.\n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.\n\nUse of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District Court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
}
}
+50
View File
@@ -0,0 +1,50 @@
# Changelog
## 2026-05-01 - 3.1.0 - feat(package)
modernize package metadata, typings, and test setup for ESM builds
- add an explicit package exports entry and include additional published config files
- upgrade build and test tooling dependencies and add documentation generation script
- improve TypeScript safety for frontmatter parsing and turndown GFM plugin typings
- refresh README usage examples and strengthen HTML-to-Markdown test assertions
## 2026-03-01 - 3.0.3 - maintenance
Project maintenance and repository metadata updates across the 3.0.3 release line.
- Removed the legacy `.gitlab-ci.yml` configuration
- Updated project description
- Updated TypeScript configuration
- Refreshed `npmextra.json` git host metadata
## 2024-01-19 - 3.0.2 - core
Core update release.
- Applied a core fix/update
## 2023-07-10 - 3.0.1 - project
Project organization updates during the 3.0.1 release cycle.
- Switched to the new organization scheme
- Included a core fix/update in the 3.0.03.0.1 range
## 2022-05-28 - 3.0.0 - core
Breaking core modernization release.
- BREAKING CHANGE: switched the project to ESM
## 2022-05-19 - 2.0.11 - core
Routine maintenance updates across versions 2.0.5 through 2.0.14.
- Applied repeated core fix/update releases for versions 2.0.52.0.14
## 2019-06-17 - 2.0.0 - core
Major core redesign release.
- BREAKING CHANGE: switched to a class-based design
- Added support for HTML to Markdown conversion
## 2018-09-22 - 1.0.1 - core
Initial stable release series.
- Initial core implementation
- Followed by routine core fix/update releases in versions 1.0.21.0.5
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2014 Lossless GmbH (hello@lossless.com)
Copyright (c) 2026 Task Venture Capital GmbH <hello@task.vc>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+31 -6
View File
@@ -1,17 +1,42 @@
{
"npmci": {
"@ship.zone/szci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
"npmRegistryUrl": "registry.npmjs.org"
},
"gitzone": {
"@git.zone/cli": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smartmarkdown",
"description": "do more with markdown files",
"shortDescription": "Markdown parsing and conversion utilities",
"description": "Enhances Markdown file handling with parsing, conversion, and frontmatter support.",
"npmPackagename": "@push.rocks/smartmarkdown",
"license": "MIT"
"license": "MIT",
"keywords": [
"markdown",
"html conversion",
"markdown parsing",
"frontmatter",
"remark",
"unified",
"turndown",
"YAML",
"plugin system",
"text processing",
"documentation",
"content management"
]
},
"release": {
"registries": [
"https://verdaccio.lossless.digital",
"https://registry.npmjs.org"
],
"accessLevel": "public"
}
},
"@git.zone/tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.\n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.\n\nUse of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District Court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
}
}
-13034
View File
File diff suppressed because it is too large Load Diff
+40 -15
View File
@@ -1,35 +1,39 @@
{
"name": "@push.rocks/smartmarkdown",
"version": "3.0.2",
"version": "3.1.0",
"private": false,
"description": "do more with markdown files",
"description": "Enhances Markdown file handling with parsing, conversion, and frontmatter support.",
"exports": {
".": "./dist_ts/index.js"
},
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"author": "Lossless GmbH",
"author": "Task Venture Capital GmbH <hello@task.vc>",
"license": "MIT",
"scripts": {
"test": "tstest test/",
"build": "tsbuild --web --allowimplicitany --skiplibcheck"
"build": "tsbuild --web",
"buildDocs": "tsdoc"
},
"devDependencies": {
"@git.zone/tsbuild": "^2.1.61",
"@git.zone/tsrun": "^1.2.37",
"@git.zone/tstest": "^1.0.86",
"@push.rocks/tapbundle": "^5.0.3",
"@types/node": "^20.11.5"
"@git.zone/tsbuild": "^4.4.0",
"@git.zone/tsdoc": "^2.0.3",
"@git.zone/tstest": "^3.6.3",
"@types/mdast": "^4.0.4",
"@types/node": "^25.6.0"
},
"dependencies": {
"@push.rocks/smartyaml": "^2.0.5",
"@types/turndown": "^5.0.1",
"@push.rocks/smartyaml": "^3.0.5",
"@types/turndown": "^5.0.6",
"remark-frontmatter": "^5.0.0",
"remark-gfm": "^4.0.0",
"remark-gfm": "^4.0.1",
"remark-html": "^16.0.1",
"remark-parse": "^11.0.0",
"remark-stringify": "^11.0.0",
"turndown": "^7.1.1",
"turndown": "^7.2.4",
"turndown-plugin-gfm": "^1.0.2",
"unified": "^11.0.4"
"unified": "^11.0.5"
},
"files": [
"ts/**/*",
@@ -40,10 +44,31 @@
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
".smartconfig.json",
"license",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
]
],
"keywords": [
"markdown",
"html conversion",
"markdown parsing",
"frontmatter",
"remark",
"unified",
"turndown",
"YAML",
"plugin system",
"text processing",
"documentation",
"content management"
],
"homepage": "https://code.foss.global/push.rocks/smartmarkdown",
"repository": {
"type": "git",
"url": "https://code.foss.global/push.rocks/smartmarkdown.git"
}
}
+7307 -5831
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -0,0 +1 @@
+178 -28
View File
@@ -1,39 +1,189 @@
# @push.rocks/smartmarkdown
do more with markdown files
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartmarkdown)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartmarkdown)
* [github.com (source mirror)](https://github.com/pushrocks/smartmarkdown)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartmarkdown/)
Markdown utilities for modern TypeScript projects: parse Markdown into HTML, read YAML frontmatter, and convert HTML back into clean GitHub-flavored Markdown.
## Status for master
`@push.rocks/smartmarkdown` wraps the Unified/Remark ecosystem for Markdown parsing and the Turndown ecosystem for HTML-to-Markdown conversion behind a small, typed API that works in Node.js and browser-oriented ESM builds.
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartmarkdown/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartmarkdown/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartmarkdown)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartmarkdown)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@push.rocks/smartmarkdown)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartmarkdown)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartmarkdown)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
## Issue Reporting and Security
## Usage
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
Use TypeScript for best in class intellisense.
## Install
## Contribution
```bash
pnpm add @push.rocks/smartmarkdown
```
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
## What It Does
For further information read the linked docs at the top of this readme.
`@push.rocks/smartmarkdown` is intentionally focused:
> MIT licensed | **&copy;** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
- Convert Markdown strings to HTML.
- Parse YAML frontmatter into a JavaScript object.
- Preserve access to the original Markdown source.
- Convert HTML strings back to Markdown using ATX headings and fenced code blocks.
- Support GitHub-flavored Markdown through `remark-gfm` and `turndown-plugin-gfm`.
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)
## Quick Start
```typescript
import { SmartMarkdown } from '@push.rocks/smartmarkdown';
const html = await SmartMarkdown.easyMarkdownToHtml(`# Hello Markdown
- fast
- typed
- practical
`);
console.log(html);
// <h1>Hello Markdown</h1>
// <ul>
// <li>fast</li>
// <li>typed</li>
// <li>practical</li>
// </ul>
```
## API
### `SmartMarkdown.easyMarkdownToHtml(markdown)`
Static convenience method for the most common path: Markdown in, HTML out.
```typescript
import { SmartMarkdown } from '@push.rocks/smartmarkdown';
const html = await SmartMarkdown.easyMarkdownToHtml('# Hi!');
console.log(html);
// <h1>Hi!</h1>
```
### `new SmartMarkdown().getMdParsedResultFromMarkdown(markdown)`
Parses a Markdown string into an `MdParsedResult` instance.
```typescript
import { SmartMarkdown } from '@push.rocks/smartmarkdown';
const smartMarkdown = new SmartMarkdown();
const result = await smartMarkdown.getMdParsedResultFromMarkdown(`---
title: Smart Docs
published: true
tags:
- markdown
- docs
---
# Smart Docs
Markdown with metadata.
`);
console.log(result.originalString); // the original Markdown input
console.log(result.html); // rendered HTML
console.log(result.frontmatterData); // { title: 'Smart Docs', published: true, tags: ['markdown', 'docs'] }
```
The returned object exposes:
- `originalString`: the Markdown input string.
- `html`: the rendered HTML output.
- `frontmatterData`: parsed YAML frontmatter as `Record<string, unknown>`.
- `title`: currently initialized as an empty string for consumers that want to attach title metadata.
### `new SmartMarkdown().htmlToMarkdown(html)`
Converts HTML back to Markdown using Turndown with GitHub-flavored Markdown support.
```typescript
import { SmartMarkdown } from '@push.rocks/smartmarkdown';
const smartMarkdown = new SmartMarkdown();
const markdown = smartMarkdown.htmlToMarkdown(`
<h1 id="hello">Hello</h1>
<p>This came from HTML.</p>
<ul>
<li>tables, strikethrough, and task lists are handled through GFM support</li>
</ul>
`);
console.log(markdown);
// # Hello
//
// This came from HTML.
```
## Frontmatter
Frontmatter is detected with `remark-frontmatter` and parsed through `@push.rocks/smartyaml`.
```typescript
import { SmartMarkdown } from '@push.rocks/smartmarkdown';
const smartMarkdown = new SmartMarkdown();
const result = await smartMarkdown.getMdParsedResultFromMarkdown(`---
layout: guide
draft: false
order: 10
---
# Guide
`);
console.log(result.frontmatterData.layout); // 'guide'
console.log(result.frontmatterData.draft); // false
console.log(result.frontmatterData.order); // 10
```
If no frontmatter block is present, `frontmatterData` is an empty object.
## Markdown Features
Markdown parsing uses:
- `remark-parse` for Markdown parsing.
- `remark-gfm` for GitHub-flavored Markdown.
- `remark-frontmatter` for YAML/TOML frontmatter detection.
- `remark-html` for HTML output.
HTML-to-Markdown conversion uses:
- `turndown` with `headingStyle: 'atx'`.
- `turndown` with `codeBlockStyle: 'fenced'`.
- `turndown-plugin-gfm` for GitHub-flavored Markdown output.
## TypeScript and ESM
This package ships as an ES module and includes TypeScript declarations.
```typescript
import { SmartMarkdown } from '@push.rocks/smartmarkdown';
```
The package export points to the built ESM entrypoint and is ready for TypeScript, Node.js ESM, and bundler-based frontend projects.
## License and Legal Information
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
### Company Information
Task Venture Capital GmbH
Registered at District Court Bremen HRB 35230 HB, Germany
For any legal inquiries or further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
+4 -4
View File
@@ -1,4 +1,4 @@
import { expect, tap } from '@push.rocks/tapbundle';
import { expect, tap } from '@git.zone/tstest/tapbundle';
import * as smartmarkdown from '../ts/index.js';
let smartMarkdownInstance: smartmarkdown.SmartMarkdown;
@@ -25,13 +25,13 @@ hello: yes
const mdParsedResult = await smartMarkdownInstance.getMdParsedResultFromMarkdown(markdownString);
expect(mdParsedResult.frontmatterData.hello).toEqual('yes');
});
tap.test('should convert a html string to markdown', async () => {
const htmlString = '<h1 id="hi">Hi!</h1>\n<h2>This is it!</h2>';
const markdownString = smartMarkdownInstance.htmlToMarkdown(htmlString);
console.log(markdownString);
expect(markdownString).toContain('# Hi!');
expect(markdownString).toContain('## This is it!');
});
tap.start();
export default tap.start();
+3 -3
View File
@@ -1,8 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
* autocreated commitinfo by @push.rocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartmarkdown',
version: '3.0.2',
description: 'do more with markdown files'
version: '3.1.0',
description: 'Enhances Markdown file handling with parsing, conversion, and frontmatter support.'
}
+21 -10
View File
@@ -1,5 +1,16 @@
import * as plugins from './smartmarkdown.plugins.js';
export type TFrontmatterData = Record<string, unknown>;
type TYamlNode = plugins.RootContent & {
type: 'yaml';
value: string;
};
const isYamlNode = (nodeArg: plugins.RootContent): nodeArg is TYamlNode => {
return nodeArg.type === 'yaml' && 'value' in nodeArg && typeof nodeArg.value === 'string';
};
export class MdParsedResult {
public static async createFromMarkdownString(mdStringArg: string): Promise<MdParsedResult> {
const mdParsedResult = new MdParsedResult();
@@ -7,24 +18,24 @@ export class MdParsedResult {
return mdParsedResult;
}
public originalString: string;
public title: string;
public html: string;
public frontmatterData: {[key: string]: any};
public originalString = '';
public title = '';
public html = '';
public frontmatterData: TFrontmatterData = {};
public async updateFromMarkdownString(mdStringArg: string) {
let yamlString: string;
public async updateFromMarkdownString(mdStringArg: string): Promise<void> {
this.originalString = mdStringArg;
let yamlString: string | undefined;
const result = await plugins.unified()
.use(plugins.remarkParse)
.use(plugins.remarkGfm)
.use(plugins.remarkFrontmatter, ['yaml', 'toml'])
.use(plugins.remarkStringify)
.use(plugins.remarkHtml)
.use(() => (tree) => {
console.dir(tree);
const yamlChild = tree.children.find(objectArg => objectArg.type === 'yaml');
.use((): plugins.Transformer<plugins.Root> => (tree) => {
const yamlChild = tree.children.find(isYamlNode);
if (yamlChild) {
yamlString = (yamlChild as any).value;
yamlString = yamlChild.value;
}
})
.process(mdStringArg);
+16 -3
View File
@@ -1,12 +1,16 @@
/// <reference path="./smartmarkdown.types.d.ts" />
// pushrocks scope
import * as smartyaml from '@push.rocks/smartyaml';
export {
smartyaml
}
};
// third party remark
import { unified } from 'unified';
import type { Plugin, Transformer } from 'unified';
import type { Root, RootContent } from 'mdast';
import remarkGfm from 'remark-gfm';
import remarkParse from 'remark-parse';
import remarkFrontmatter from 'remark-frontmatter';
@@ -14,10 +18,19 @@ import remarkHtml from 'remark-html';
import remarkStringify from 'remark-stringify';
export { unified, remarkGfm, remarkParse, remarkFrontmatter, remarkHtml, remarkStringify };
export type { Plugin, Transformer, Root, RootContent };
// other third party stuff
import turndown from 'turndown';
// @ts-ignore
import * as turndownPluginGfm from 'turndown-plugin-gfm';
import * as rawTurndownPluginGfm from 'turndown-plugin-gfm';
type TTurndownPlugin = (serviceArg: InstanceType<typeof turndown>) => void;
const turndownPluginGfm = rawTurndownPluginGfm as {
gfm: TTurndownPlugin;
strikethrough: TTurndownPlugin;
tables: TTurndownPlugin;
taskListItems: TTurndownPlugin;
};
export { turndown, turndownPluginGfm };
+6
View File
@@ -0,0 +1,6 @@
declare module 'turndown-plugin-gfm' {
export const gfm: unknown;
export const strikethrough: unknown;
export const tables: unknown;
export const taskListItems: unknown;
}
+3 -1
View File
@@ -5,8 +5,10 @@
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"noImplicitAny": true,
"esModuleInterop": true,
"verbatimModuleSyntax": true
"verbatimModuleSyntax": true,
"types": ["node"]
},
"exclude": [
"dist_*/**/*.d.ts"