@md-plugins/md-plugin-blockquote 0.1.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024-present, Jeff Galbraith
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # @md-plugins/md-plugin-blockquote
2
+
3
+ A **Markdown-It** plugin that enhances blockquote rendering by adding customizable CSS classes. This allows for easier styling and alignment with design systems, enabling more visually appealing and consistent blockquote presentation.
4
+
5
+ ## Features
6
+
7
+ - Adds customizable CSS classes to `<blockquote>` elements.
8
+ - Supports a default class that can be overridden via plugin options.
9
+
10
+ ## Installation
11
+
12
+ Install the plugin via your preferred package manager:
13
+
14
+ ```bash
15
+ # With npm:
16
+ npm install @md-plugins/md-plugin-blockquote
17
+ # Or with Yarn:
18
+ yarn add @md-plugins/md-plugin-blockquote
19
+ # Or with pnpm:
20
+ pnpm add @md-plugins/md-plugin-blockquote
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ### Basic Setup
26
+
27
+ ```js
28
+ import MarkdownIt from 'markdown-it';
29
+ import { blockquotePlugin } from 'md-plugin-blockquote';
30
+
31
+ const md = new MarkdownIt();
32
+ md.use(blockquotePlugin, {
33
+ blockquoteClass: 'custom-blockquote',
34
+ });
35
+
36
+ const markdownContent = `
37
+ > This is a blockquote.
38
+ `;
39
+
40
+ const renderedOutput = md.render(markdownContent);
41
+
42
+ console.log('Rendered Output:', renderedOutput);
43
+ ```
44
+
45
+ ### Example Output
46
+
47
+ The rendered output will include the specified CSS class:
48
+
49
+ ```html
50
+ <blockquote class="custom-blockquote">
51
+ <p>This is a blockquote.</p>
52
+ </blockquote>
53
+ ```
54
+
55
+ ## Options
56
+
57
+ The `md-plugin-blockquote` plugin supports the following options:
58
+
59
+ | Option | Type | Default | Description |
60
+ | --------------- | ------ | --------------------- | ---------------------------------- |
61
+ | blockquoteClass | string | 'markdown-blockquote' | CSS class to apply to blockquotes. |
62
+
63
+ ## Testing
64
+
65
+ To run the tests, use the following command:
66
+
67
+ ```bash
68
+ pnpm test
69
+ ```
70
+
71
+ ## License
72
+
73
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE.md) file for details.
@@ -0,0 +1,14 @@
1
+ import { PluginWithOptions } from 'markdown-it';
2
+
3
+ interface BlockquotePluginOptions {
4
+ /**
5
+ * The class for the blockquote
6
+ *
7
+ * @default 'markdown-blockquote'
8
+ */
9
+ blockquoteClass?: string;
10
+ }
11
+
12
+ declare const blockquotePlugin: PluginWithOptions<BlockquotePluginOptions>;
13
+
14
+ export { type BlockquotePluginOptions, blockquotePlugin };
@@ -0,0 +1,14 @@
1
+ import { PluginWithOptions } from 'markdown-it';
2
+
3
+ interface BlockquotePluginOptions {
4
+ /**
5
+ * The class for the blockquote
6
+ *
7
+ * @default 'markdown-blockquote'
8
+ */
9
+ blockquoteClass?: string;
10
+ }
11
+
12
+ declare const blockquotePlugin: PluginWithOptions<BlockquotePluginOptions>;
13
+
14
+ export { type BlockquotePluginOptions, blockquotePlugin };
package/dist/index.mjs ADDED
@@ -0,0 +1,15 @@
1
+ const blockquotePlugin = (md, { blockquoteClass = "markdown-blockquote" } = {}) => {
2
+ const originalRender = md.renderer.render.bind(md.renderer);
3
+ md.renderer.render = (tokens, options, env) => {
4
+ tokens.forEach((token) => {
5
+ if (token.tag === "blockquote" && token.type === "blockquote_open") {
6
+ const existingClass = token.attrGet("class") || "";
7
+ const newClass = [existingClass, blockquoteClass].filter(Boolean).join(" ");
8
+ token.attrSet("class", newClass);
9
+ }
10
+ });
11
+ return originalRender(tokens, options, env);
12
+ };
13
+ };
14
+
15
+ export { blockquotePlugin };
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@md-plugins/md-plugin-blockquote",
3
+ "version": "0.1.0-alpha.1",
4
+ "description": "A markdown-it plugin for Blockquotes with custom styles.",
5
+ "keywords": [
6
+ "markdown-it",
7
+ "quasarframework",
8
+ "vue",
9
+ "types"
10
+ ],
11
+ "homepage": "https://github.com/md-plugins",
12
+ "bugs": {
13
+ "url": "https://github.com/md-plugins/md-plugins/issues"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/md-plugins/md-plugins.git"
18
+ },
19
+ "license": "MIT",
20
+ "author": "hawkeye64 <galbraith64@gmail.com>",
21
+ "type": "module",
22
+ "exports": {
23
+ ".": {
24
+ "import": {
25
+ "types": "./dist/index.d.mts",
26
+ "default": "./dist/index.mjs"
27
+ }
28
+ }
29
+ },
30
+ "module": "./dist/index.mjs",
31
+ "types": "./dist/index.d.ts",
32
+ "files": [
33
+ "./dist"
34
+ ],
35
+ "dependencies": {
36
+ "@types/markdown-it": "^14.1.2",
37
+ "markdown-it": "^14.1.0",
38
+ "@md-plugins/shared": "0.1.0-alpha.1"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
43
+ "scripts": {
44
+ "build": "unbuild",
45
+ "clean": "rm -rf dist",
46
+ "test": "vitest"
47
+ }
48
+ }