├── .gitignore
├── Confluence-html-to-github-markdown.js
├── LICENSE
├── README.md
└── package.json
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 |
8 | # Runtime data
9 | pids
10 | *.pid
11 | *.seed
12 | *.pid.lock
13 |
14 | # Directory for instrumented libs generated by jscoverage/JSCover
15 | lib-cov
16 |
17 | # Coverage directory used by tools like istanbul
18 | coverage
19 |
20 | # nyc test coverage
21 | .nyc_output
22 |
23 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
24 | .grunt
25 |
26 | # Bower dependency directory (https://bower.io/)
27 | bower_components
28 |
29 | # node-waf configuration
30 | .lock-wscript
31 |
32 | # Compiled binary addons (https://nodejs.org/api/addons.html)
33 | build/Release
34 |
35 | # Dependency directories
36 | node_modules/
37 | jspm_packages/
38 |
39 | # TypeScript v1 declaration files
40 | typings/
41 |
42 | # Optional npm cache directory
43 | .npm
44 |
45 | # Optional eslint cache
46 | .eslintcache
47 |
48 | # Optional REPL history
49 | .node_repl_history
50 |
51 | # Output of 'npm pack'
52 | *.tgz
53 |
54 | # Yarn Integrity file
55 | .yarn-integrity
56 |
57 | # dotenv environment variables file
58 | .env
59 |
60 | # parcel-bundler cache (https://parceljs.org/)
61 | .cache
62 |
63 | # next.js build output
64 | .next
65 |
66 | # nuxt.js build output
67 | .nuxt
68 |
69 | # vuepress build output
70 | .vuepress/dist
71 |
72 | # Serverless directories
73 | .serverless
--------------------------------------------------------------------------------
/Confluence-html-to-github-markdown.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | var fs = require('fs-extra')
3 | var exec = require('sync-exec')
4 | var path = require('path');
5 |
6 | var divePath = process.cwd();
7 | var attachmentsExportPath = "public/assets/images/"
8 | var markdownImageReference = "assets/images/"
9 | // print process.argv
10 | process.argv.forEach(function (val, index, array) {
11 | if (index === 2){
12 | divePath = process.cwd() + "/" + val;
13 | }else if (index === 3){
14 | attachmentsExportPath = val
15 | }else if(index === 4){
16 | markdownImageReference = val
17 | }
18 | });
19 | dive(divePath)
20 |
21 | function dive(dir) {
22 | var list = []
23 | var stat = ""
24 | // Read the directory
25 | list = fs.readdirSync(dir);
26 | list.forEach(function (file) {
27 | // Full path of that file
28 | var p = path.join(dir , file)
29 |
30 | // Get the file's stats
31 | stat = fs.statSync(p)
32 |
33 | // If the file is a directory
34 | if (stat && stat.isDirectory()) {
35 | dive(p);
36 | } else {
37 | console.log(file)
38 | if (file.endsWith('.html')) {
39 | var titleRegex = /
([^<]*)<\/title>/i
40 | var content = fs.readFileSync(p, 'utf8')
41 | var match = content.match(titleRegex)
42 | if (match != null && match.length > 1) {
43 | fs.ensureDir("Markdown")
44 | var sanitizedfilename = match[1].replace(/[^0-9a-zA-Z]/g,"_")
45 | var outputFile = path.join("Markdown", sanitizedfilename + ".md")
46 | var command = "pandoc -f html -t markdown -o " + outputFile + " " + p
47 | var out = exec(command, {cwd: process.cwd()})
48 | console.log(out)
49 | //images
50 | console.log("Reading : " + outputFile)
51 | var content = fs.readFileSync(outputFile, 'utf8')
52 | var matches = uniq(content.match(/(
`
17 |
18 | ### Defaults
19 | * `` : `Current Working Directory`
20 | * `` : `"/public/assets/images/"` Where to export images
21 | * `` : `"assets/images/"` Image reference in markdown files
22 |
23 |
24 | # Export to HTML
25 | Note that if the converter does not know how to handle a style, HTML to Markdown typically just leaves the HTML untouched (Markdown does allow for HTML tags).
26 |
27 | ### Step by Step Guide
28 |
29 | 1. Go to the space and choose Space tools > Content Tools on the sidebar.
30 | 2. Choose Export. This option will only be visible if you have the 'Export Space' permission.
31 | 3. Select HTML then choose Next.
32 | 4. Decide whether you need to customise the export:
33 | * Select Normal Export to produce an HTML file containing all the pages that you have permission to view.
34 | * Select Custom Export if you want to export a subset of pages, or to exclude comments from the export.
35 | 5. [Export Pages](https://confluence.atlassian.com/doc/export-content-to-word-pdf-html-and-xml-139475.html#ExportContenttoWord,PDF,HTMLandXML-ExportmultiplepagestoHTML,XML,orPDF)
36 | 6. Extract zip
37 | 7. Open shell in extracted zip
38 | 8. run `confluence-to-github-markdown` in shell
39 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "confluence-to-github-markdown",
3 | "version": "1.1.2",
4 | "description": "Convert Confluence Pages to github markdown",
5 | "bin": {
6 | "confluence-to-github-markdown": "./Confluence-html-to-github-markdown.js"
7 | },
8 | "main": "Confluence-html-to-github-markdown.js",
9 | "repository": "git@github.com:EWhite613/Confluence-to-Github-Markdown.git",
10 | "dependencies": {
11 | "path": "^0.12.7",
12 | "sync-exec": "^0.6.2",
13 | "fs-extra":"^7.0.0"
14 | },
15 | "devDependencies": {},
16 | "keywords": [
17 | "Confluence",
18 | "Markdown",
19 | "Confluence to Markdown",
20 | "Confluence to Github Markdown",
21 | "ember",
22 | "Github Markdown",
23 | "Images",
24 | "export images",
25 | "reference images"
26 | ],
27 | "scripts": {
28 | "test": "echo \"Error: no test specified\" && exit 1"
29 | },
30 | "author": "Eric White",
31 | "license": "MIT"
32 | }
33 |
--------------------------------------------------------------------------------