@md-plugins/md-plugin-inlinecode 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,75 @@
1
+ # @md-plugins/md-plugin-inlinecode
2
+
3
+ A **Markdown-It** plugin that enhances inline code rendering by adding customizable CSS classes. This allows for better styling and alignment with design systems, making inline code blocks visually distinct and consistent.
4
+
5
+ ## Features
6
+
7
+ - Adds a customizable CSS class to inline `<code>` elements.
8
+ - Supports a default class that can be overridden via plugin options.
9
+ - Enhances the appearance of inline code for better readability and emphasis.
10
+
11
+ ## Installation
12
+
13
+ Install the plugin via your preferred package manager:
14
+
15
+ ```bash
16
+ # With npm:
17
+ npm install @md-plugins/md-plugin-inlinecode
18
+ # Or with Yarn:
19
+ yarn add @md-plugins/md-plugin-inlinecode
20
+ # Or with pnpm:
21
+ pnpm add @md-plugins/md-plugin-inlinecode
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ### Basic Setup
27
+
28
+ ```js
29
+ import MarkdownIt from 'markdown-it';
30
+ import { inlinecodePlugin } from '@md-plugins/md-plugin-inlinecode';
31
+
32
+ const md = new MarkdownIt();
33
+ md.use(inlinecodePlugin, {
34
+ inlineCodeClass: 'custom-inline-code-class',
35
+ });
36
+
37
+ const markdownContent = `
38
+ Here is some \`inline code\` in a sentence.
39
+ `;
40
+
41
+ const renderedOutput = md.render(markdownContent);
42
+
43
+ console.log('Rendered Output:', renderedOutput);
44
+ ```
45
+
46
+ ### Example Output
47
+
48
+ The rendered output will include the specified CSS class:
49
+
50
+ ```html
51
+ <p>
52
+ Here is some <code class="custom-inline-code-class">inline code</code> in a
53
+ sentence.
54
+ </p>
55
+ ```
56
+
57
+ ## Options
58
+
59
+ The `md-plugin-inlinecode` plugin supports the following options:
60
+
61
+ | Option | Type | Default | Description |
62
+ | --------------- | ------ | ---------------- | ------------------------------------------- |
63
+ | inlineCodeClass | string | 'markdown-token' | CSS class to apply to inline `<code>` tags. |
64
+
65
+ ## Testing
66
+
67
+ Run the tests to ensure the plugin behaves as expected:
68
+
69
+ ```bash
70
+ pnpm test
71
+ ```
72
+
73
+ ## License
74
+
75
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE.md) file for details.
@@ -0,0 +1,17 @@
1
+ import { PluginWithOptions } from 'markdown-it';
2
+
3
+ interface InlineCodePluginOptions {
4
+ /**
5
+ * The CSS class to apply to inline code blocks
6
+ *
7
+ * @default 'markdown-token'
8
+ */
9
+ inlineCodeClass?: string;
10
+ }
11
+
12
+ /**
13
+ * Adds a class to inline code.
14
+ */
15
+ declare const inlinecodePlugin: PluginWithOptions<InlineCodePluginOptions>;
16
+
17
+ export { type InlineCodePluginOptions, inlinecodePlugin };
@@ -0,0 +1,17 @@
1
+ import { PluginWithOptions } from 'markdown-it';
2
+
3
+ interface InlineCodePluginOptions {
4
+ /**
5
+ * The CSS class to apply to inline code blocks
6
+ *
7
+ * @default 'markdown-token'
8
+ */
9
+ inlineCodeClass?: string;
10
+ }
11
+
12
+ /**
13
+ * Adds a class to inline code.
14
+ */
15
+ declare const inlinecodePlugin: PluginWithOptions<InlineCodePluginOptions>;
16
+
17
+ export { type InlineCodePluginOptions, inlinecodePlugin };
package/dist/index.mjs ADDED
@@ -0,0 +1,16 @@
1
+ import { escapeHtml } from 'markdown-it/lib/common/utils.mjs';
2
+
3
+ const inlinecodePlugin = (md, { inlineCodeClass = "markdown-token" } = {}) => {
4
+ md.renderer.rules.code_inline = (tokens, idx, _options, _env, self) => {
5
+ const token = tokens[idx];
6
+ if (!token) {
7
+ return "";
8
+ }
9
+ const existingClass = token.attrGet("class") || "";
10
+ const combinedClass = [existingClass, inlineCodeClass].filter(Boolean).join(" ");
11
+ token.attrSet("class", combinedClass);
12
+ return "<code" + self.renderAttrs(token) + ">" + escapeHtml(token.content) + "</code>";
13
+ };
14
+ };
15
+
16
+ export { inlinecodePlugin };
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@md-plugins/md-plugin-inlinecode",
3
+ "version": "0.1.0-alpha.1",
4
+ "description": "A markdown-it plugin for handling inline code.",
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
+ }