Skip to content

Commit

Permalink
✨ feat: Update dependencies and modify code in TypeScript files
Browse files Browse the repository at this point in the history
- Update dependencies in package.json
- Add new dependencies to package.json
- Modify code in remarklint/index.ts, remarklint/remarkGfmHighlight.ts, and remarklint/remarkTextrPlugins.ts files

The changes were made to update dependencies and add new dependencies in the package.json file. Additionally, code modifications were done in the remarklint/index.ts, remarklint/remarkGfmHighlight.ts, and remarklint/remarkTextrPlugins.ts files.
  • Loading branch information
canisminor1990 committed Nov 16, 2023
1 parent 5252afb commit 0786757
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 5 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@
"eslint-plugin-simple-import-sort": "^10",
"eslint-plugin-sort-keys-fix": "^1",
"eslint-plugin-typescript-sort-keys": "^3",
"eslint-plugin-unicorn": "^48",
"eslint-plugin-unicorn": "^49",
"eslint-plugin-unused-imports": "^3",
"gatsby-remark-find-replace": "^0.3.0",
"postcss-less": "^6",
"postcss-styled-syntax": "^0.5",
"prettier-plugin-organize-imports": "^3",
Expand Down Expand Up @@ -114,7 +115,8 @@
"stylelint-config-clean-order": "^5",
"stylelint-config-recommended": "^13",
"stylelint-less": "^2",
"stylelint-order": "^6"
"stylelint-order": "^6",
"unist-util-visit": "^5.0.0"
},
"devDependencies": {
"@commitlint/cli": "^18",
Expand Down
8 changes: 5 additions & 3 deletions src/remarklint/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const replaceNBSP = (str: string) => {
return str.replaceAll(' ', ' ');
};
import { remarkGfmHighlight } from './remarkGfmHighlight';
import { replaceNBSP } from './remarkTextrPlugins';

export default {
$schema: 'https://json.schemastore.org/remarkrc',
Expand All @@ -9,6 +8,7 @@ export default {
'remark-frontmatter',
'remark-pangu',
['remark-textr', { plugins: [replaceNBSP] }],
remarkGfmHighlight,

// ----- Plugin -----------------------------------------------------------
'remark-sort-definitions',
Expand Down Expand Up @@ -50,9 +50,11 @@ export default {
],
settings: {
bullet: '-',
emphasis: '*',
fences: true,
listItemIndent: 1,
rule: '-',
strong: '*',
tightDefinitions: true,
},
};
32 changes: 32 additions & 0 deletions src/remarklint/remarkGfmHighlight.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const gfmHighlight = [
{ from: 'Note', to: '[!NOTE]' },
{ from: 'Tip', to: '[!TIP]' },
{ from: 'Important', to: '[!IMPORTANT]' },
{ from: 'Warning', to: '[!WARNING]' },
{ from: 'Caution', to: '[!CAUTION]' },
];

export function remarkGfmHighlight() {
return async (tree: any) => {
const { visit } = await import('unist-util-visit');
visit(tree, 'blockquote', (node: any) => {
visit(node, 'strong', (subnode: any) => {
let value = '';

visit(subnode, 'text', (textnode: any) => {
if (['Note', 'Tip', 'Important', 'Warning', 'Caution'].includes(textnode.value)) {
for (const item of gfmHighlight) {
if (item.from === textnode.value) {
value = item.to;
}
}
}
if (value) {
subnode.type = 'text';
subnode.value = value;
}
});
});
});
};
}
3 changes: 3 additions & 0 deletions src/remarklint/remarkTextrPlugins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const replaceNBSP = (str: string) => {
return str.replaceAll(' ', ' ');
};

0 comments on commit 0786757

Please sign in to comment.