@mintlify/common 1.0.678 → 1.0.680

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.
@@ -1,4 +1,4 @@
1
- import { rehypeCodeBlocks, rehypeDynamicTailwindCss, rehypeKeyboardSymbols, rehypeMdxExtractEndpoint, rehypeMdxExtractExamples, rehypeParamFieldIds, rehypeRawComponents, rehypeTable, rehypeUnicodeIds, rehypeZoomImages, remarkExtractChangelogFilters, remarkExtractTableOfContents, remarkFrames, remarkComponentIds, remarkMdxInjectSnippets, remarkMdxRemoveUnusedVariables, remarkRemoveImports, remarkMdxExtractPanel, remarkVideo, remarkExtractMultiView, } from './plugins/index.js';
1
+ import { rehypeCodeBlocks, rehypeDynamicTailwindCss, rehypeKeyboardSymbols, rehypeListItemText, rehypeMdxExtractEndpoint, rehypeMdxExtractExamples, rehypeParamFieldIds, rehypeRawComponents, rehypeTable, rehypeUnicodeIds, rehypeZoomImages, remarkExtractChangelogFilters, remarkExtractTableOfContents, remarkFrames, remarkComponentIds, remarkMdxInjectSnippets, remarkMdxRemoveUnusedVariables, remarkRemoveImports, remarkMdxExtractPanel, remarkVideo, remarkExtractMultiView, } from './plugins/index.js';
2
2
  import { remarkMdxRemoveUnknownJsx } from './plugins/remark/remarkMdxRemoveUnknownJsx/index.js';
3
3
  import { remarkMermaid } from './plugins/remark/remarkMermaid.js';
4
4
  // avoid running extractors unnecessarily
@@ -34,6 +34,7 @@ export const getMDXOptions = ({ data, remarkPlugins = [], rehypePlugins = [], md
34
34
  ...rehypeExtractors(mdxExtracts, data),
35
35
  rehypeTable,
36
36
  rehypeRawComponents,
37
+ rehypeListItemText,
37
38
  rehypeZoomImages,
38
39
  rehypeUnicodeIds,
39
40
  [rehypeDynamicTailwindCss, data.tailwindSelectors],
@@ -1,4 +1,5 @@
1
1
  export * from './rehypeCodeBlocks/index.js';
2
+ export * from './rehypeListItemText.js';
2
3
  export * from './rehypeMdxExtractEndpoint/index.js';
3
4
  export * from './rehypeMdxExtractExamples.js';
4
5
  export * from './rehypeParamFieldIds.js';
@@ -1,4 +1,5 @@
1
1
  export * from './rehypeCodeBlocks/index.js';
2
+ export * from './rehypeListItemText.js';
2
3
  export * from './rehypeMdxExtractEndpoint/index.js';
3
4
  export * from './rehypeMdxExtractExamples.js';
4
5
  export * from './rehypeParamFieldIds.js';
@@ -0,0 +1,2 @@
1
+ import type { Pluggable } from 'unified';
2
+ export declare const rehypeListItemText: Pluggable;
@@ -0,0 +1,60 @@
1
+ import { visit } from 'unist-util-visit';
2
+ const ELEMENT_TYPES = ['element', 'mdxJsxFlowElement', 'mdxJsxTextElement'];
3
+ const MDX_EXPRESSION_TYPES = ['mdxFlowExpression', 'mdxTextExpression'];
4
+ const LIST_TAGS = ['ol', 'ul'];
5
+ const isElementNode = (node) => ELEMENT_TYPES.includes(node.type);
6
+ const isMdxExpression = (node) => MDX_EXPRESSION_TYPES.includes(node.type);
7
+ const getTagName = (node) => {
8
+ if ('tagName' in node)
9
+ return node.tagName;
10
+ if ('name' in node)
11
+ return node.name;
12
+ return null;
13
+ };
14
+ const isListElement = (node) => {
15
+ const tag = getTagName(node);
16
+ return tag !== null && LIST_TAGS.includes(tag);
17
+ };
18
+ const isTextWithContent = (node) => { var _a; return node.type === 'text' && Boolean((_a = node.value) === null || _a === void 0 ? void 0 : _a.trim()); };
19
+ const addNoBulletAttribute = (node) => {
20
+ if ('properties' in node) {
21
+ node.properties['data-no-bullet'] = '';
22
+ return;
23
+ }
24
+ node.attributes.push({
25
+ type: 'mdxJsxAttribute',
26
+ name: 'data-no-bullet',
27
+ value: '',
28
+ });
29
+ };
30
+ const hasOnlyNestedLists = (children) => {
31
+ let foundList = false;
32
+ for (const child of children) {
33
+ if (isTextWithContent(child))
34
+ return false;
35
+ if (isMdxExpression(child))
36
+ return false;
37
+ if (!isElementNode(child))
38
+ continue;
39
+ if (isListElement(child)) {
40
+ foundList = true;
41
+ continue;
42
+ }
43
+ return false;
44
+ }
45
+ return foundList;
46
+ };
47
+ export const rehypeListItemText = () => (tree) => {
48
+ visit(tree, (node) => {
49
+ if (!isElementNode(node))
50
+ return;
51
+ if (getTagName(node) !== 'li')
52
+ return;
53
+ const element = node;
54
+ if (element.children.length === 0)
55
+ return;
56
+ if (hasOnlyNestedLists(element.children)) {
57
+ addNoBulletAttribute(element);
58
+ }
59
+ });
60
+ };