Skip to content

Commit 9607d82

Browse files
committed
✨ initial commit
0 parents  commit 9607d82

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Scrapbox to Markdown
2+
3+
A script to convert a Scrapbox page to markdown text. For bookmarklet.
4+
5+
## How to use
6+
7+
Use `main.min.js` for bookmarklet.
8+
9+
## How to develop
10+
11+
### Prepare
12+
13+
```console
14+
npm install -g uglify-js
15+
```
16+
17+
### Generate `main.min.js`
18+
19+
```console
20+
uglifyjs main.js --mangle --output main.min.js
21+
```

main.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
(function () {
2+
3+
// ============
4+
// scrapbox (=sb) nodes
5+
// ============
6+
7+
class SbNodePage { }
8+
9+
// ============
10+
// scrapbox parsers
11+
// ============
12+
13+
function parse(doc) {
14+
return new SbNodePage();
15+
}
16+
17+
// ============
18+
// markdown (=md) nodes
19+
// ============
20+
21+
class MdNodeDocument {
22+
toString() {
23+
return 'foo';
24+
}
25+
}
26+
27+
// ============
28+
// scrapbox to markdown converters
29+
// ============
30+
31+
function convert(sbPage) {
32+
return new MdNodeDocument();
33+
}
34+
35+
// ============
36+
// main
37+
// ============
38+
39+
const sbPage = parse(document);
40+
const mdDoc = convert(sbPage);
41+
42+
// output
43+
const newDoc = window.open(
44+
'', // url
45+
).document;
46+
newDoc.title = 'conversion result';
47+
const textNode = newDoc.createTextNode(mdDoc.toString());
48+
newDoc.body.appendChild(textNode);
49+
})();

main.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)