-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21ba678
commit 8dab248
Showing
3 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<body> | ||
<input type="file" id="fileInput" accept=".md"> | ||
<div id="fileContent" contentEditable="true"></div> | ||
<button id="saveButton">Save as Markdown</button> | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/turndown/dist/turndown.js"></script> | ||
<script> | ||
marked.setOptions( { | ||
gfm: true | ||
} ); | ||
|
||
document.getElementById( 'fileInput' ).addEventListener( 'change', function ( e ) { | ||
const file = e.target.files[ 0 ]; | ||
if ( !file ) { | ||
return; | ||
} | ||
const reader = new FileReader(); | ||
|
||
reader.onload = function ( e ) { | ||
const markdown = e.target.result; | ||
const html = marked.parse( markdown ); | ||
document.getElementById( 'fileContent' ).innerHTML = html; | ||
}; | ||
reader.readAsText( file ); | ||
} ); | ||
|
||
document.getElementById( 'saveButton' ).addEventListener( 'click', function () { | ||
const turndownService = new TurndownService(); | ||
turndownService.addRule( 'headings', { | ||
filter: [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ], | ||
replacement: function ( content, node ) { | ||
var hLevel = node.nodeName.charAt( 1 ); | ||
var hashes = ''; | ||
for ( var i = 0; i < hLevel; i++ ) { | ||
hashes += '#'; | ||
} | ||
return '\n\n' + hashes + ' ' + content + '\n\n'; | ||
} | ||
} ); | ||
const html = document.getElementById( 'fileContent' ).innerHTML; | ||
const markdown = turndownService.turndown( html ); | ||
const blob = new Blob( [ markdown ], { type: 'text/plain' } ); | ||
const url = URL.createObjectURL( blob ); | ||
const a = document.createElement( 'a' ); | ||
a.href = url; | ||
a.download = 'file.md'; | ||
a.click(); | ||
} ); | ||
</script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Markdown | ||
|
||
123 456 789 | ||
|
||
ABC def ghi hhhhh iiiiiiiiii | ||
|
||
## Things we design | ||
|
||
* [https://jaanga.github.io/moving-manuals/](https://jaanga.github.io/moving-manuals/) | ||
* More | ||
* mmm | ||
* nnn nnnnnnnnnnnnn | ||
* [http://wikihouse.github.io/viewer-experiments/](http://wikihouse.github.io/viewer-experiments/) | ||
* [https://opendesk.github.io/design-playground/](https://opendesk.github.io/design-playground/) | ||
* [https://jaanga.github.io/demo/alexi-k/](https://jaanga.github.io/demo/alexi-k/) | ||
* [https://jaanga.github.io/demo/unlimbited/unlimbited-forearm-r2.html](https://jaanga.github.io/demo/unlimbited/unlimbited-forearm-r2.html) | ||
* [https://jaanga.github.io/gestification/projects/flying-leap-3d/barfolina-pavillion/r3/barfolina-pavillion.html](https://jaanga.github.io/gestification/projects/flying-leap-3d/barfolina-pavillion/r3/barfolina-pavillion.html) | ||
|
||
lorem ipsum, quia dolor sit, amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt, ut labore et dolore magnam aliquam quaerat voluptatem. ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? quis autem vel eum iure reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla pariatur? | ||
|
||
lorem ipsum, quia dolor sit, amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt, ut labore et dolore magnam aliquam quaerat voluptatem. ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? quis autem vel eum iure reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla pariatur? |