Skip to content

Commit f97402f

Browse files
committed
Add bugref markdown plugin
1 parent 1bc90e1 commit f97402f

File tree

5 files changed

+35
-25
lines changed

5 files changed

+35
-25
lines changed

next.config.mjs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,33 @@
11
import createMDX from '@next/mdx'
22
import rehypeSlug from 'rehype-slug'
33
import remarkGfm from 'remark-gfm'
4+
import { visit } from 'unist-util-visit'
5+
6+
function remarkBugRef() {
7+
return function (tree) {
8+
visit(tree, 'text', function (node, index, parent) {
9+
if (node.value.endsWith(':bugref:')) {
10+
node.value = node.value.slice(0, node.value.length - 8)
11+
const next = parent.children[index + 1]
12+
const issue = next.value
13+
parent.children[index + 1] = {
14+
type: 'link',
15+
url: `https://github.com/minizinc/libminizinc/issues/${issue}`,
16+
children: [{ type: 'text', value: `issue ${issue}` }],
17+
}
18+
} else if (node.value.endsWith(':idebugref:')) {
19+
node.value = node.value.slice(0, node.value.length - 118)
20+
const next = parent.children[index + 1]
21+
const issue = next.value
22+
parent.children[index + 1] = {
23+
type: 'link',
24+
url: `https://github.com/minizinc/MiniZincIDE/issues/${issue}`,
25+
children: [{ type: 'text', value: `issue ${issue}` }],
26+
}
27+
}
28+
})
29+
}
30+
}
431

532
/** @type {import('next').NextConfig} */
633
const nextConfig = {
@@ -23,7 +50,7 @@ const nextConfig = {
2350

2451
const withMDX = createMDX({
2552
options: {
26-
remarkPlugins: [remarkGfm],
53+
remarkPlugins: [remarkGfm, remarkBugRef],
2754
rehypePlugins: [rehypeSlug],
2855
},
2956
})

package-lock.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"eslint": "9.20",
4242
"eslint-config-next": "15.1",
4343
"prettier": "^3.5.0",
44-
"prettier-plugin-tailwindcss": "^0.6.11"
44+
"prettier-plugin-tailwindcss": "^0.6.11",
45+
"unist-util-visit": "^5.0.0"
4546
}
4647
}

src/components/BugRef.jsx

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/data/release.mdx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import { BugRef, IDEBugRef } from '@/components/BugRef'
2-
3-
- Fix the packaging of the OR Tools solver on linux distributions (<BugRef issue={889} />).
1+
- Fix the packaging of the OR Tools solver on linux distributions (:bugref:`889`).
42
- Prevent output of and emit warning for invalid statistics in JSON streaming mode.
5-
- Fix crash in string interpolation (<BugRef issue={891} />).
6-
- Fix `row` and `col` functions to use enumerated types instead of `int` (<BugRef issue={888} />).
3+
- Fix crash in string interpolation (:bugref:`891`).
4+
- Fix `row` and `col` functions to use enumerated types instead of `int` (:bugref:`888`).
75

86
export default function Release({ children }) {
97
return (

0 commit comments

Comments
 (0)