@md-plugins/quasar-app-extension-q-press 0.1.0-alpha.27 → 0.1.0-alpha.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@md-plugins/quasar-app-extension-q-press",
3
- "version": "0.1.0-alpha.27",
3
+ "version": "0.1.0-alpha.29",
4
4
  "description": "QPress - The Ultimate Markdown Solution for Quasar Framework",
5
5
  "author": "hawkeye64 <galbraith64@gmail.com>",
6
6
  "keywords": [
@@ -29,19 +29,19 @@
29
29
  "dependencies": {
30
30
  "@types/markdown-it": "^14.1.2",
31
31
  "markdown-it": "^14.1.0",
32
- "@md-plugins/md-plugin-frontmatter": "0.1.0-alpha.27",
33
- "@md-plugins/md-plugin-blockquote": "0.1.0-alpha.27",
34
- "@md-plugins/md-plugin-containers": "0.1.0-alpha.27",
35
- "@md-plugins/md-plugin-imports": "0.1.0-alpha.27",
36
- "@md-plugins/md-plugin-image": "0.1.0-alpha.27",
37
- "@md-plugins/md-plugin-table": "0.1.0-alpha.27",
38
- "@md-plugins/md-plugin-inlinecode": "0.1.0-alpha.27",
39
- "@md-plugins/md-plugin-headers": "0.1.0-alpha.27",
40
- "@md-plugins/md-plugin-link": "0.1.0-alpha.27",
41
- "@md-plugins/md-plugin-codeblocks": "0.1.0-alpha.27",
42
- "@md-plugins/shared": "0.1.0-alpha.27",
43
- "@md-plugins/md-plugin-title": "0.1.0-alpha.27",
44
- "@md-plugins/vite-md-plugin": "0.1.0-alpha.27"
32
+ "@md-plugins/md-plugin-blockquote": "0.1.0-alpha.29",
33
+ "@md-plugins/md-plugin-codeblocks": "0.1.0-alpha.29",
34
+ "@md-plugins/md-plugin-containers": "0.1.0-alpha.29",
35
+ "@md-plugins/md-plugin-frontmatter": "0.1.0-alpha.29",
36
+ "@md-plugins/md-plugin-headers": "0.1.0-alpha.29",
37
+ "@md-plugins/md-plugin-image": "0.1.0-alpha.29",
38
+ "@md-plugins/md-plugin-imports": "0.1.0-alpha.29",
39
+ "@md-plugins/md-plugin-inlinecode": "0.1.0-alpha.29",
40
+ "@md-plugins/md-plugin-link": "0.1.0-alpha.29",
41
+ "@md-plugins/md-plugin-table": "0.1.0-alpha.29",
42
+ "@md-plugins/shared": "0.1.0-alpha.29",
43
+ "@md-plugins/md-plugin-title": "0.1.0-alpha.29",
44
+ "@md-plugins/vite-md-plugin": "0.1.0-alpha.29"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/markdown-it": "^14.1.2",
@@ -7,7 +7,7 @@ desc: Headers plugin advanced topics for Markdown.
7
7
 
8
8
  The `headers` plugin allows you to add custom classes to headers and generate a table of contents (TOC) in your Markdown content. This section will cover how the plugin works, the available options for customization, and examples of how to use it effectively.
9
9
 
10
- ### Type Infformation
10
+ ### Type Information
11
11
 
12
12
  ```ts
13
13
  import { PluginWithOptions } from 'markdown-it'
@@ -44,6 +44,22 @@ interface HeadersPluginOptions {
44
44
  * @default false
45
45
  */
46
46
  shouldAllowNested?: boolean
47
+ /**
48
+ * Should allow API headers
49
+ *
50
+ * If set to `true`, headers for `<MarkdownAPI>` title would also be extracted.
51
+ *
52
+ * @default true
53
+ */
54
+ shouldAllowApi?: boolean
55
+ /**
56
+ * Should allow Example headers
57
+ *
58
+ * If set to `true`, headers for `<MarkdownExample>` title would also be extracted.
59
+ *
60
+ * @default true
61
+ */
62
+ shouldAllowExample?: boolean
47
63
  }
48
64
 
49
65
  interface TocItem {
@@ -67,168 +83,6 @@ declare const headersPlugin: PluginWithOptions<HeadersPluginOptions>
67
83
  export { type HeadersPluginOptions, type TocItem, headersPlugin }
68
84
  ```
69
85
 
70
- ### How It Works
71
-
72
- The `headers` plugin processes headers in your Markdown content, adding custom classes and generating a TOC. The TOC is stored in the `env` object passed to the Markdown renderer.
73
-
74
- ### Default Behavior
75
-
76
- By default, the `headers` plugin adds custom classes to headers and generates a TOC for headers at levels 2 and 3. Here is an example of a Markdown file with headers:
77
-
78
- ```markdown
79
- # My Awesome Post
80
-
81
- ## Introduction
82
-
83
- ## Details
84
-
85
- ### Subsection
86
-
87
- ## Conclusion
88
- ```
89
-
90
- ### Plugin Options
91
-
92
- The `headers` plugin provides several options for customization. Here are the available options and their descriptions:
93
-
94
- #### `level`
95
-
96
- - **Type**: `number[]`
97
- - **Default**: `[2, 3]`
98
- - **Description**: The levels of headers to include in the TOC.
99
-
100
- #### `slugify`
101
-
102
- - **Type**: `function`
103
- - **Default**: `defaultSlugify`
104
- - **Description**: A custom function to generate slugs for the headers.
105
-
106
- #### `format`
107
-
108
- - **Type**: `function`
109
- - **Description**: A custom function to format the header titles.
110
-
111
- ### Example Configuration
112
-
113
- Here is an example of how you can configure the `headers` plugin with custom options:
114
-
115
- ```typescript
116
- import MarkdownIt from 'markdown-it'
117
- import { headersPlugin } from '@md-plugins/md-plugin-headers'
118
- import { slugify as customSlugify } from './custom-slugify'
119
-
120
- const md = new MarkdownIt()
121
-
122
- md.use(headersPlugin, {
123
- level: [2, 3, 4],
124
- slugify: customSlugify,
125
- format: (str) => str.toUpperCase(),
126
- })
127
- ```
128
-
129
- ### Using the TOC
130
-
131
- Once the TOC is generated, it is stored in the `env` object. How you handle this data and send it to the front-end is up to you. Here is an example of how to use the TOC in a Vue component:
132
-
133
- ```vue
134
- <template>
135
- <div>
136
- <h1>Table of Contents</h1>
137
- <ul>
138
- <li v-for="item in toc" :key="item.id">
139
- <a :href="'#' + item.id">{{ item.title }}</a>
140
- <ul v-if="item.sub">
141
- <li v-for="subItem in item.sub" :key="subItem.id">
142
- <a :href="'#' + subItem.id">{{ subItem.title }}</a>
143
- </li>
144
- </ul>
145
- </li>
146
- </ul>
147
- </div>
148
- </template>
149
-
150
- <script setup>
151
- import { ref } from 'vue'
152
-
153
- const toc = ref([
154
- { id: 'introduction', title: 'Introduction' },
155
- { id: 'details', title: 'Details', sub: [{ id: 'subsection', title: 'Subsection' }] },
156
- { id: 'conclusion', title: 'Conclusion' },
157
- ])
158
- </script>
159
- ```
160
-
161
- ### Default CSS
162
-
163
- By default, the `headers` plugin applies specific CSS classes to different levels of headers. You can add these classes in your CSS to customize the appearance of headers.
164
-
165
- ```scss
166
- .markdown-h1 {
167
- font-size: 2.4em !important;
168
- font-weight: 700;
169
- margin: 0 0 1em !important;
170
- display: flex;
171
- align-items: center;
172
- }
173
-
174
- .markdown-h2 {
175
- font-size: 1.8em !important;
176
- font-weight: 600;
177
- padding-bottom: 8px !important;
178
- border-bottom: 1px solid $separator-color;
179
- }
180
-
181
- .markdown-h3 {
182
- font-size: 1.6em !important;
183
- font-weight: 500;
184
- }
185
-
186
- .markdown-h4 {
187
- font-size: 1.4em !important;
188
- font-weight: 500;
189
- &:before {
190
- content: '» ';
191
- vertical-align: text-top;
192
- }
193
- }
194
-
195
- .markdown-h5 {
196
- font-size: 1em !important;
197
- font-weight: 500;
198
- &:before {
199
- content: '»» ';
200
- vertical-align: text-top;
201
- }
202
- }
203
-
204
- .markdown-h6 {
205
- font-size: 1em !important;
206
- font-weight: 400;
207
- &:before {
208
- content: '»»» ';
209
- vertical-align: text-top;
210
- }
211
- }
212
-
213
- @media (max-width: 850px) {
214
- .markdown-h1 {
215
- font-size: 1.7em !important;
216
- }
217
- .markdown-h2 {
218
- font-size: 1.4em !important;
219
- }
220
- .markdown-h3 {
221
- font-size: 1.3em !important;
222
- }
223
- .markdown-h4 {
224
- font-size: 1.2em !important;
225
- }
226
- .markdown-h5 {
227
- font-size: 1.1em !important;
228
- }
229
- }
230
- ```
231
-
232
86
  ### Conclusion
233
87
 
234
88
  The `headers` plugin is a powerful tool for adding custom classes to headers and generating a TOC in your Markdown content. By customizing the levels, slugify function, and format function, you can tailor the plugin to fit your specific needs. Remember, it is up to you to handle the generated TOC data and send it to the front-end in a way that suits your application. Experiment with different configurations and find the one that works best for you.
@@ -82,6 +82,8 @@ md.use(headersPlugin, {
82
82
  slugify: (str) => str.toLowerCase().replace(/\s+/g, '-'), // Optional: Customize slugification
83
83
  format: (str) => str.toUpperCase(), // Optional: Customize header formatting
84
84
  shouldAllowNested: true, // Optional: Allow headers inside nested blocks
85
+ shouldAllowApi = true, // Optional: Allow headers from api title
86
+ shouldAllowExample = true, // Optional: Allow headers from example title
85
87
  })
86
88
 
87
89
  // Now you can use the Headers plugin in your Markdown content
@@ -98,6 +100,8 @@ The Headers plugin accepts the following options:
98
100
  - **level**: Heading levels to be extracted. Should be a subset of markdown-it-anchor's level option to ensure the slug exists. Default is `[2, 3]`.
99
101
 
100
102
  - **shouldAllowNested**: Should allow headers inside nested blocks or not. Default is `false`.
103
+ - **shouldAllowApi**: Should allow headers from api title or not. Default is `true`.
104
+ - **shouldAllowExample**: Should allow headers from example title or not. Default is `true`.
101
105
 
102
106
  ## Advanced Configuration
103
107
 
@@ -116,6 +120,8 @@ md.use(headersPlugin, {
116
120
  slugify: (str) => str.toLowerCase().replace(/\s+/g, '-'), // Customize slugification
117
121
  format: (str) => str.toUpperCase(), // Customize header formatting
118
122
  shouldAllowNested: true, // Allow headers inside nested blocks
123
+ shouldAllowApi = true, // Optional: Allow headers from api blocks
124
+ shouldAllowExample = true, // Optional: Allow headers from example blocks
119
125
  })
120
126
  .use(markdownItAnchor)
121
127
  .use(markdownItToc)
@@ -44,7 +44,6 @@ declare const htmlUnescape: (str: string) => string
44
44
  interface MarkdownItEnv {
45
45
  plugins?: Record<string, unknown>
46
46
  }
47
-
48
47
  interface MarkdownItHeader {
49
48
  /**
50
49
  * The slug of the header
@@ -73,6 +72,16 @@ interface MarkdownItHeader {
73
72
  */
74
73
  children: MarkdownItHeader[]
75
74
  }
75
+ type ResolvePluginOptionsFn = <T extends object, K extends keyof any>(
76
+ options:
77
+ | T
78
+ | {
79
+ [P in K]?: T
80
+ }
81
+ | undefined,
82
+ key: K,
83
+ defaults: T,
84
+ ) => T
76
85
 
77
86
  interface ResolveTitleOptions {
78
87
  /**
@@ -90,7 +99,6 @@ interface ResolveTitleOptions {
90
99
  */
91
100
  shouldEscapeText: boolean
92
101
  }
93
-
94
102
  /**
95
103
  * Resolve header title from markdown-it token
96
104
  *
@@ -103,7 +111,7 @@ declare const resolveTitleFromToken: (
103
111
 
104
112
  interface ResolveHeadersOptions extends ResolveTitleOptions {
105
113
  /**
106
- * Heading level that is going to be resolved; ie: `1` to `6`
114
+ * Heading level that going to be resolved
107
115
  */
108
116
  level: number[]
109
117
  /**
@@ -123,7 +131,6 @@ interface ResolveHeadersOptions extends ResolveTitleOptions {
123
131
  */
124
132
  format?: (str: string) => string | undefined
125
133
  }
126
-
127
134
  /**
128
135
  * Resolve headers from markdown-it tokens
129
136
  */
@@ -144,14 +151,27 @@ declare const resolveHeadersFromTokens: (
144
151
  */
145
152
  declare const slugify: (str: string) => string
146
153
 
154
+ declare function resolvePluginOptions<T extends object, K extends keyof any>(
155
+ options:
156
+ | T
157
+ | {
158
+ [key in K]?: T
159
+ }
160
+ | undefined,
161
+ key: K,
162
+ defaults: T,
163
+ ): T
164
+
147
165
  export {
148
166
  type MarkdownItEnv,
149
167
  type MarkdownItHeader,
150
168
  type ResolveHeadersOptions,
169
+ type ResolvePluginOptionsFn,
151
170
  type ResolveTitleOptions,
152
171
  htmlEscape,
153
172
  htmlUnescape,
154
173
  resolveHeadersFromTokens,
174
+ resolvePluginOptions,
155
175
  resolveTitleFromToken,
156
176
  slugify,
157
177
  }
@@ -11,6 +11,30 @@ The `viteMdPlugin` is a powerful tool for integrating Markdown processing into y
11
11
 
12
12
  ```ts
13
13
  import { Plugin } from 'vite'
14
+ import { Options } from 'markdown-it'
15
+ import { BlockquotePluginOptions } from '@md-plugins/md-plugin-blockquote'
16
+ import { CodeblockPluginOptions } from '@md-plugins/md-plugin-codeblocks'
17
+ import { FrontmatterPluginOptions } from '@md-plugins/md-plugin-frontmatter'
18
+ import { HeadersPluginOptions } from '@md-plugins/md-plugin-headers'
19
+ import { ImagePluginOptions } from '@md-plugins/md-plugin-image'
20
+ import { InlineCodePluginOptions } from '@md-plugins/md-plugin-inlinecode'
21
+ import { LinkPluginOptions } from '@md-plugins/md-plugin-link'
22
+ import { TablePluginOptions } from '@md-plugins/md-plugin-table'
23
+
24
+ interface MarkdownOptions extends Options {
25
+ html?: boolean
26
+ linkify?: boolean
27
+ typographer?: boolean
28
+ breaks?: boolean
29
+ blockquote?: BlockquotePluginOptions
30
+ codeblocks?: CodeblockPluginOptions
31
+ frontmatter?: FrontmatterPluginOptions
32
+ headers?: HeadersPluginOptions | boolean
33
+ image?: ImagePluginOptions
34
+ inlinecode?: InlineCodePluginOptions
35
+ link?: LinkPluginOptions
36
+ table?: TablePluginOptions
37
+ }
14
38
 
15
39
  interface MenuItem {
16
40
  name: string
@@ -24,12 +48,14 @@ interface MenuItem {
24
48
  external?: boolean
25
49
  expanded?: boolean
26
50
  }
51
+
27
52
  interface MenuNode {
28
53
  name: string
29
54
  path?: string
30
55
  external?: boolean
31
56
  children?: MenuNode[]
32
57
  }
58
+
33
59
  interface FlatMenuEntry {
34
60
  name: string
35
61
  category: string | null
@@ -37,18 +63,23 @@ interface FlatMenuEntry {
37
63
  prev?: FlatMenuEntry
38
64
  next?: FlatMenuEntry
39
65
  }
66
+
40
67
  type FlatMenu = Record<string, FlatMenuEntry>
68
+
41
69
  interface NavItem extends FlatMenuEntry {
42
70
  classes: string
43
71
  }
72
+
44
73
  interface RelatedItem {
45
74
  name: string
46
75
  category: string
47
76
  path: string
48
77
  }
78
+
49
79
  interface UserConfig {
50
80
  path: string
51
81
  menu: MenuItem[]
82
+ config?: MarkdownOptions
52
83
  }
53
84
 
54
85
  /**
@@ -58,6 +89,7 @@ interface UserConfig {
58
89
  * @param userConfig - The configuration object for the Vite Markdown plugin.
59
90
  * @param userConfig.path - The base path prefix to be used for routing or file resolution.
60
91
  * @param userConfig.menu - An array of MenuItem objects representing the navigation menu structure.
92
+ * @param userConfig.config - Additional configuration options for the Markdown processing.
61
93
  * @returns A Vite Plugin object pre-configured with the provided settings for Markdown processing.
62
94
  */
63
95
  declare function viteMdPlugin(userConfig: UserConfig): Plugin
@@ -65,6 +97,7 @@ declare function viteMdPlugin(userConfig: UserConfig): Plugin
65
97
  export {
66
98
  type FlatMenu,
67
99
  type FlatMenuEntry,
100
+ type MarkdownOptions,
68
101
  type MenuItem,
69
102
  type MenuNode,
70
103
  type NavItem,
@@ -177,6 +210,38 @@ export interface MenuItem {
177
210
  }
178
211
  ```
179
212
 
213
+ #### `config`
214
+
215
+ - **Type**: `MarkdownOptions`
216
+ - **Description**: Additional configuration options for the Markdown processing.
217
+
218
+ ````ts
219
+ import { Options } from 'markdown-it';
220
+ import { BlockquotePluginOptions } from '@md-plugins/md-plugin-blockquote';
221
+ import { CodeblockPluginOptions } from '@md-plugins/md-plugin-codeblocks';
222
+ import { FrontmatterPluginOptions } from '@md-plugins/md-plugin-frontmatter';
223
+ import { HeadersPluginOptions } from '@md-plugins/md-plugin-headers';
224
+ import { ImagePluginOptions } from '@md-plugins/md-plugin-image';
225
+ import { InlineCodePluginOptions } from '@md-plugins/md-plugin-inlinecode';
226
+ import { LinkPluginOptions } from '@md-plugins/md-plugin-link';
227
+ import { TablePluginOptions } from '@md-plugins/md-plugin-table';
228
+
229
+ interface MarkdownOptions extends Options {
230
+ html?: boolean;
231
+ linkify?: boolean;
232
+ typographer?: boolean;
233
+ breaks?: boolean;
234
+ blockquote?: BlockquotePluginOptions;
235
+ codeblocks?: CodeblockPluginOptions;
236
+ frontmatter?: FrontmatterPluginOptions;
237
+ headers?: HeadersPluginOptions | boolean;
238
+ image?: ImagePluginOptions;
239
+ inlinecode?: InlineCodePluginOptions;
240
+ link?: LinkPluginOptions;
241
+ table?: TablePluginOptions;
242
+ }
243
+ ```
244
+
180
245
  ### Example Configuration
181
246
 
182
247
  Here is an example of how you can configure the `viteMdPlugin` with custom options:
@@ -196,7 +261,7 @@ const basePath = '/docs'
196
261
  export default defineConfig({
197
262
  plugins: [vue(), viteMdPlugin(basePath, menu)],
198
263
  })
199
- ```
264
+ ````
200
265
 
201
266
  ### Using the Plugin
202
267
 
@@ -218,7 +283,7 @@ When you build your project, the `viteMdPlugin` will process this Markdown file
218
283
 
219
284
  ## Advanced
220
285
 
221
- If you need to change the behavior of `viteMdPlugin`, you can create your own Vite plugin and use that instead. Look at the source to see how it can be done.
286
+ If you need to change the behavior of `viteMdPlugin`, you can make behavioral changes via the `MarkdownOptions`, or you can create your own Vite plugin and use that instead. Look at the source to see how it can be done.
222
287
 
223
288
  ## Conclusion
224
289