Skip to content

Commit a60a17f

Browse files
Add scripts to convert org to md
1 parent 6282595 commit a60a17f

File tree

5 files changed

+32
-4
lines changed

5 files changed

+32
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ docs/_build
22
node_modules
33
cache
44
.vitepress/dist
5+
docs_md

.vitepress/config.mts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ export default async () => {
2525
{ icon: 'github', link: 'https://github.com/nvim-orgmode/orgmode' }
2626
]
2727
},
28-
ignoreDeadLinks: true,
29-
transformHtml(code, id, ctx) {
30-
console.log('id', id)
31-
},
3228
})
3329

3430
}

docs_md/.gitkeep

Whitespace-only changes.

scripts/generate_md.mjs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import fs from 'fs'
2+
import path from 'path'
3+
import { execSync } from 'child_process'
4+
import { dirname } from 'node:path';
5+
import { fileURLToPath } from 'node:url';
6+
7+
const __dirname = dirname(fileURLToPath(import.meta.url));
8+
9+
const generateMd = async () => {
10+
const files = fs.readdirSync(path.resolve(__dirname, '../docs'))
11+
fs.mkdirSync(path.resolve(__dirname, '../docs_md'))
12+
for await (const file of files) {
13+
execSync(`pandoc --lua-filter=${__dirname}/pandoc_fix_links.lua -s ${__dirname}/../docs/${file} -o ${__dirname}/../docs_md/${path.parse(file).name}.md -t gfm`)
14+
}
15+
}
16+
17+
generateMd().then(() => {
18+
process.exit(0)
19+
}).catch((err) => {
20+
console.error(err)
21+
process.exit(1)
22+
})

scripts/pandoc_fix_links.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function Link(el)
2+
local target = el.target
3+
if target:sub(1, 2) == './' then
4+
target = target:gsub('^(%./%w+)(%.org)(.*)$', '%1.md%3')
5+
target = target:gsub('::', '')
6+
end
7+
el.target = target
8+
return el
9+
end

0 commit comments

Comments
 (0)