solid-markdown
Advanced tools
Comparing version 1.2.2 to 2.0.0
@@ -1,5 +0,91 @@ | ||
import { Component } from "solid-js"; | ||
import { PluggableList } from "unified"; | ||
import { Options as TransformOptions } from "./ast-to-solid"; | ||
import { Options as FilterOptions } from "./rehype-filter"; | ||
import { JSX, Component } from 'solid-js'; | ||
import { PluggableList } from 'unified'; | ||
import { Position } from 'unist'; | ||
import { ElementContent, Element, Root } from 'hast'; | ||
interface SolidMarkdownProps { | ||
node: Element; | ||
children: Component[]; | ||
/** | ||
* Passed when `options.rawSourcePos` is given | ||
*/ | ||
sourcePosition?: Position; | ||
/** | ||
* Passed when `options.includeElementIndex` is given | ||
*/ | ||
index?: number; | ||
/** | ||
* Passed when `options.includeElementIndex` is given | ||
*/ | ||
siblingCount?: number; | ||
} | ||
type NormalComponents = { | ||
[TagName in keyof JSX.IntrinsicElements]: keyof JSX.IntrinsicElements | Component<JSX.IntrinsicElements[TagName] & SolidMarkdownProps>; | ||
}; | ||
type TransformLink = (href: string, children: ElementContent[], title?: string) => string; | ||
type TransformImage = (src: string, alt: string, title?: string) => string; | ||
type TransformLinkTargetType = "_self" | "_blank" | "_parent" | "_top" | (string & {}); | ||
type TransformLinkTarget = (href: string, children: ElementContent[], title?: string) => TransformLinkTargetType | undefined; | ||
type SolidMarkdownNames = keyof JSX.IntrinsicElements; | ||
type CodeComponent = Component<JSX.IntrinsicElements["code"] & SolidMarkdownProps & { | ||
inline?: boolean; | ||
}>; | ||
type HeadingComponent = Component<JSX.IntrinsicElements["h1"] & SolidMarkdownProps & { | ||
level: number; | ||
}>; | ||
type LiComponent = Component<JSX.IntrinsicElements["li"] & SolidMarkdownProps & { | ||
checked: boolean | null; | ||
index: number; | ||
ordered: boolean; | ||
}>; | ||
type OrderedListComponent = Component<JSX.IntrinsicElements["ol"] & SolidMarkdownProps & { | ||
depth: number; | ||
ordered: true; | ||
}>; | ||
type TableCellComponent = Component<JSX.IntrinsicElements["table"] & SolidMarkdownProps & { | ||
style?: Record<string, unknown>; | ||
isHeader: boolean; | ||
}>; | ||
type TableRowComponent = Component<JSX.IntrinsicElements["tr"] & SolidMarkdownProps & { | ||
isHeader: boolean; | ||
}>; | ||
type UnorderedListComponent = Component<JSX.IntrinsicElements["ul"] & SolidMarkdownProps & { | ||
depth: number; | ||
ordered: false; | ||
}>; | ||
type SpecialComponents = { | ||
code: CodeComponent | SolidMarkdownNames; | ||
h1: HeadingComponent | SolidMarkdownNames; | ||
h2: HeadingComponent | SolidMarkdownNames; | ||
h3: HeadingComponent | SolidMarkdownNames; | ||
h4: HeadingComponent | SolidMarkdownNames; | ||
h5: HeadingComponent | SolidMarkdownNames; | ||
h6: HeadingComponent | SolidMarkdownNames; | ||
li: LiComponent | SolidMarkdownNames; | ||
ol: OrderedListComponent | SolidMarkdownNames; | ||
td: TableCellComponent | SolidMarkdownNames; | ||
th: TableCellComponent | SolidMarkdownNames; | ||
tr: TableRowComponent | SolidMarkdownNames; | ||
ul: UnorderedListComponent | SolidMarkdownNames; | ||
}; | ||
type Components = Partial<Omit<NormalComponents, keyof SpecialComponents>> & Partial<SpecialComponents>; | ||
type Options$1 = { | ||
sourcePos: boolean; | ||
rawSourcePos: boolean; | ||
skipHtml: boolean; | ||
includeElementIndex: boolean; | ||
transformLinkUri: null | false | TransformLink; | ||
transformImageUri?: TransformImage; | ||
linkTarget: TransformLinkTargetType | TransformLinkTarget; | ||
components: Components; | ||
}; | ||
type AllowElement = (element: Element, index: number, parent: Element | Root) => boolean | undefined; | ||
type Options = { | ||
allowedElements?: string[]; | ||
disallowedElements?: string[]; | ||
allowElement?: AllowElement; | ||
unwrapDisallowed: boolean; | ||
}; | ||
type CoreOptions = { | ||
@@ -15,4 +101,5 @@ children: string; | ||
}; | ||
type SolidMarkdownOptions = CoreOptions & PluginOptions & LayoutOptions & FilterOptions & TransformOptions; | ||
type SolidMarkdownOptions = CoreOptions & PluginOptions & LayoutOptions & Options & Options$1; | ||
declare const SolidMarkdown: Component<Partial<SolidMarkdownOptions>>; | ||
export default SolidMarkdown; | ||
export { SolidMarkdown }; |
146
package.json
{ | ||
"name": "solid-markdown", | ||
"version": "1.2.2", | ||
"private": false, | ||
"description": "Render Markdown as Solid JS components", | ||
"version": "2.0.0", | ||
"description": "Markdown renderer for solid-js", | ||
"license": "MIT", | ||
"keywords": [ | ||
@@ -18,13 +18,3 @@ "remark", | ||
], | ||
"homepage": "https://github.com/andi23rosca/solid-markdown", | ||
"bugs": { | ||
"url": "https://github.com/andi23rosca/solid-markdown/issues", | ||
"email": "andi23rosca+solid-markdown@gmail.com" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/andi23rosca/solid-markdown.git" | ||
}, | ||
"license": "MIT", | ||
"author": "Andi Rosca <andi23rosca@gmail.com> (https://godoffrontend.com)", | ||
"author": "Andi Rosca <andi23rosca@gmail.com>", | ||
"contributors": [ | ||
@@ -38,53 +28,60 @@ { | ||
"url": "https://github.com/high1" | ||
}, | ||
{ | ||
"name": "Patrick Heneise", | ||
"url": "https://github.com/patrickheneise" | ||
} | ||
], | ||
"type": "module", | ||
"main": "dist/index.jsx", | ||
"source": "lib/index.tsx", | ||
"browser": "dist/index.browser.jsx", | ||
"types": "dist/index.d.ts", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/andi23rosca/solid-markdown.git" | ||
}, | ||
"homepage": "https://github.com/andi23rosca/solid-markdown#readme", | ||
"bugs": { | ||
"url": "https://github.com/andi23rosca/solid-markdown/issues" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"private": false, | ||
"sideEffects": false, | ||
"type": "module", | ||
"main": "./dist/index.js", | ||
"module": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"browser": {}, | ||
"exports": { | ||
"solid": { | ||
"development": "./dist/dev.jsx", | ||
"import": "./dist/index.jsx" | ||
}, | ||
"development": { | ||
"import": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/dev.js" | ||
} | ||
}, | ||
"import": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
} | ||
}, | ||
"typesVersions": {}, | ||
"scripts": { | ||
"build": "run-s build:*", | ||
"build:client": "esbuild lib/index.tsx --bundle --outfile=dist/index.browser.jsx --jsx=preserve --external:solid-js --format=esm && tsc", | ||
"build:server": "esbuild lib/index.tsx --bundle --platform=node --outfile=dist/index.jsx --jsx=preserve --external:solid-js --format=esm && tsc", | ||
"lint": "eslint --fix . --ext .ts --ext .tsx", | ||
"prepare": "husky install" | ||
"dev": "vite serve dev", | ||
"build": "tsup", | ||
"test": "concurrently pnpm:test:*", | ||
"test:client": "vitest", | ||
"test:ssr": "pnpm run test:client --mode ssr", | ||
"prepublishOnly": "pnpm build", | ||
"format": "prettier --ignore-path .gitignore -w \"src/**/*.{js,ts,json,css,tsx,jsx}\" \"dev/**/*.{js,ts,json,css,tsx,jsx}\"", | ||
"lint": "concurrently pnpm:lint:*", | ||
"lint:code": "eslint --ignore-path .gitignore --max-warnings 0 src/**/*.{js,ts,tsx,jsx}", | ||
"lint:types": "tsc --noEmit", | ||
"update-deps": "pnpm up -Li" | ||
}, | ||
"commitlint": { | ||
"extends": [ | ||
"@commitlint/config-conventional" | ||
] | ||
}, | ||
"lint-staged": { | ||
"*.{js,ts,tsx,json,md,yaml}": [ | ||
"prettier --write" | ||
], | ||
"*.{js,ts,jsx,tsx}": [ | ||
"eslint --cache --fix" | ||
] | ||
}, | ||
"release": { | ||
"branches": [ | ||
"main" | ||
] | ||
}, | ||
"dependencies": { | ||
"@types/hast": "^2.3.4", | ||
"@types/prop-types": "^15.7.5", | ||
"@types/unist": "^2.0.6", | ||
"comma-separated-tokens": "^2.0.3", | ||
"property-information": "^6.2.0", | ||
"property-information": "^6.3.0", | ||
"remark-gfm": "^3.0.1", | ||
"remark-parse": "^10.0.1", | ||
"remark-parse": "^10.0.2", | ||
"remark-rehype": "^10.1.0", | ||
"solid-js": "^1.7.3", | ||
"space-separated-tokens": "^2.0.2", | ||
"style-to-object": "^0.4.1", | ||
"style-to-object": "^0.3.0", | ||
"unified": "^10.1.2", | ||
@@ -94,21 +91,32 @@ "unist-util-visit": "^4.1.2", | ||
}, | ||
"peerDependencies": { | ||
"solid-js": "^1.6.0" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "^17.5.1", | ||
"@commitlint/config-conventional": "^17.4.4", | ||
"@types/hast": "^2.3.4", | ||
"@typescript-eslint/parser": "^5.57.1", | ||
"esbuild": "^0.17.16", | ||
"eslint": "^8.38.0", | ||
"eslint-config-prettier": "^8.8.0", | ||
"eslint-plugin-json": "^3.1.0", | ||
"eslint-plugin-solid": "^0.12.0", | ||
"husky": "^8.0.3", | ||
"lint-staged": "^13.2.1", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^2.8.7", | ||
"typescript": "^5.0.4" | ||
"@biomejs/biome": "^1.3.1", | ||
"@types/hast": "^2.3.7", | ||
"@types/unist": "^3.0.1", | ||
"@typescript-eslint/eslint-plugin": "^6.9.1", | ||
"@typescript-eslint/parser": "^6.9.1", | ||
"concurrently": "^8.2.2", | ||
"esbuild": "^0.18.20", | ||
"esbuild-plugin-solid": "^0.5.0", | ||
"eslint": "^8.52.0", | ||
"eslint-plugin-eslint-comments": "^3.2.0", | ||
"eslint-plugin-no-only-tests": "^3.1.0", | ||
"jsdom": "^22.1.0", | ||
"prettier": "3.0.0", | ||
"solid-js": "^1.8.5", | ||
"tsup": "^7.2.0", | ||
"tsup-preset-solid": "^2.1.0", | ||
"typescript": "^5.2.2", | ||
"vite": "^4.5.0", | ||
"vite-plugin-solid": "^2.7.2", | ||
"vitest": "^0.33.0" | ||
}, | ||
"peerDependencies": { | ||
"solid-js": "^1.2.0" | ||
"packageManager": "pnpm@8.6.0", | ||
"engines": { | ||
"node": ">=18", | ||
"pnpm": ">=8.6.0" | ||
} | ||
} |
@@ -1,7 +0,12 @@ | ||
# SolidJS version of `react-markdown` | ||
<p> | ||
<img width="100%" src="https://assets.solidjs.com/banner?type=solid-markdown&background=tiles&project=%20" alt="solid-markdown"> | ||
</p> | ||
# `solid-markdown` | ||
Render markdown as solid components. | ||
The implementation is 90% shamelessly copied from https://github.com/remarkjs/react-markdown. | ||
Changes include: | ||
- Replacing React specific component creation with SolidJS components | ||
@@ -13,11 +18,11 @@ - Porting the implementation from javascript with JSDoc types to typescript | ||
## Installation | ||
``` | ||
```bash | ||
npm install solid-markdown | ||
``` | ||
## Usage | ||
```jsx | ||
import SolidMarkdown from "solid-markdown"; | ||
import { SolidMarkdown } from "solid-markdown"; | ||
@@ -30,10 +35,9 @@ const markdown = ` | ||
- list | ||
`; | ||
` | ||
const App = () => { | ||
return <SolidMarkdown children={markdown} />; | ||
}; | ||
return <SolidMarkdown children={markdown} /> | ||
} | ||
``` | ||
## TODO | ||
- [ ] Port unit tests from from original library |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11
42
48387
20
8
1333
1
+ Addedstyle-to-object@0.3.0(transitive)
- Removed@types/hast@^2.3.4
- Removed@types/prop-types@^15.7.5
- Removed@types/unist@^2.0.6
- Removedsolid-js@^1.7.3
- Removed@types/prop-types@15.7.13(transitive)
- Removedstyle-to-object@0.4.4(transitive)
Updatedproperty-information@^6.3.0
Updatedremark-parse@^10.0.2
Updatedstyle-to-object@^0.3.0