Permalink
Browse files

Adding web based tool to convert markdown to wiki and other way round.

  • Loading branch information...
1 parent bfc1aae commit eb1506a8c4b179fd46096acfe5827ca2fba7e033 @Gozala committed Oct 14, 2010
View
@@ -0,0 +1,60 @@
+
+'use strict'
+
+var markdown2wiki = require('markdown-wiki').markdown2wiki
+, wiki2html = require('wiky').toHtml
+
+, xsltProcessor = null
+, parser = new DOMParser()
+, serializer = new XMLSerializer()
+, template =
+ [ '<?xml version="1.0"?>'
+ , '<html xmlns="http://www.w3.org/1999/xhtml">'
+ , '<body>'
+ , '{{body}}'
+ , '</body>'
+ , '</html>'
+ ].join('\n')
+
+function html2markdown(html) {
+ if (xsltProcessor) {
+ try {
+ html = template.replace('{{body}}', html)
+ var xml = parser.parseFromString(html,"text/xml")
+ var transformed = xsltProcessor.transformToDocument(xml)
+ markdown = transformed.documentElement.children[1].children[0].textContent.
+ replace(/<tt>([^<]*)<\/tt>/g, '`$1`')
+ //var markdown = serializer.serializeToString(transformed.documentElement.childNodes[2])
+ return markdown
+ } catch(e) {
+ return e.message
+ }
+ }
+ return "Loading ..."
+}
+
+function main() {
+ var stdin = document.getElementById("stdin")
+ var stdout = document.getElementById("stdout")
+ var request = new XMLHttpRequest()
+ request.open('GET', 'resources/markdown.xsl', true)
+ request.onreadystatechange = function() {
+ console.log(request)
+ if (request.readyState = 4 && (request.status == 0 || request.status == 200)) {
+ xsltProcessor = new XSLTProcessor()
+ xsltProcessor.importStylesheet(request.responseXML)
+ }
+ }
+ request.send(null)
+
+ document.documentElement.addEventListener("keyup", function(e) {
+ if (e.target == stdin) stdout.value = markdown2wiki(stdin.value)
+ if (e.target == stdout) stdin.value = html2markdown(wiki2html(stdout.value))
+ }, true);
+}
+
+if (require.main == module) {
+ if ('complete' === document.readyState) main()
+ else window.addEventListener("load", main, false)
+}
+
View
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html manifest="cache.manifest">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
+ <title>TaskHub</title>
+ <link type="text/css" rel="stylesheet" href="resources/css/style.css"/>
+ <script type="text/javascript" src="../teleport/lib/teleport.js"></script>
+ </head>
+ <body>
+ <script>
+ require.Sandbox({
+ global: window,
+ catalog:
+ { "wiky":
+ { path: "../wiky/"
+ , main: "./lib/wiky.js"
+ }
+ , "markdown-wiki":
+ { path: ""
+ , main: "./lib/markdown-wiki.js"
+ }
+ , "markdown":
+ { path: "../markdown/", main: "./lib/markdown.js" }
+ , "app":
+ { path: "demo/"
+ , directories: { lib: '' }
+ , main: "./main.js"
+ }
+ },
+ }).main("app");
+ </script>
+ <div id="main">
+ </div>
+ <strong>Markdown</strong>
+ <textarea id="stdin" style="width:98%" rows="17"></textarea>
+ <strong>Wiki<strong>
+ <textarea id="stdout" style="width:98%" rows="17"></textarea>
+ <div>
+ <div class="ribbon">
+ <a target="_blank" href="https://github.com/Gozala/taskhub">Fork me on GitHub</a>
+ </div>
+ </body>
+</html>
@@ -0,0 +1,151 @@
+body {
+ background: url(../images/bg.jpg);
+ color: rgb(253, 249, 250);
+ font-size: 2em;
+ font-family: 'Helvetiva Neue', Helvetica, Arial, sans-serif;
+}
+
+#add {
+ position: absolute;
+ top: 30px;
+ right: 0.6em;
+ font-size: 1em;
+ font-family: monaco;
+ display: inline-block;
+ color: rgba(89, 75, 66, 1);
+ text-decoration: none;
+ background: rgba(89, 75, 66, 0.5);
+ border: 0.1em rgba(89, 75, 66, 0.6) solid;
+ padding: 0 0.4em;
+ text-align: conter;
+ -webkit-border-radius: 1em;
+ -moz-border-radius: 1em;
+ border-radius: 1em;
+}
+
+#login-data {
+ font-size: 28px;
+ width: 85%;
+ outline: none;
+ border: none;
+ background: none;
+}
+#login {
+ position: absolute;
+ left 0px;
+ height: 2em;
+ background: url(../images/octocat.png) no-repeat 0 6px;
+ padding-left: 90px;
+ padding-bottom: 2px;
+}
+
+
+#tasks-view {
+ min-width: 50%;
+ position: absolute;
+ -webkit-transition: all 0.3s ease-out;
+ -moz-transition: all 0.3s ease-out;
+ left: -10px;
+ top: 2px;
+}
+ul {
+ width: 100%;
+ padding: 0;
+ margin: 0;
+ list-style-type: none;
+}
+li {
+ display: block;
+ text-shadow: rgba(0, 0, 0, 1) 0px 1px 1px;
+ -webkit-box-shadow: 2px 2px 4px #888;
+ -moz-box-shadow: 2px 2px 4px #888;
+ box-shadow: 2px 2px 4px #888;
+ -webkit-transition: all 0.3s ease-out;
+ -moz-transition: all 0.3s ease-out;
+ -webkit-border-radius: 5px;
+ -moz-border-radius: 5px;
+ border-radius: 5px;
+ outline: none;
+ background: rgba(89, 75, 66, 0.9);
+ background: rgba(52, 46, 46, 0.8);
+ padding: 10px 50px 10px 20px;
+ margin: 5px 20px 5px 5px;
+}
+li:nth-child(2n+1) {
+ background: rgba(89, 75, 66, 0.8);
+}
+li:hover {
+ background: rgba(52, 46, 46, 0.8);
+}
+
+li:first-child {
+ margin-right: 5px !important;
+ padding-right: 150px;
+ text-shadow: rgba(255, 255, 255, 0.5) 0px 1px 1px;
+ font-weight: bold;
+ background: rgb(184, 211, 11);
+ color: #000;
+ margin-bottom: 10px;
+}
+li[contenteditable=true] {
+ background: rgba(106,100,74, 0.9);
+ margin-right: 28px;
+}
+li:first-child[contenteditable=true] {
+ background: #D17100;
+}
+
+#settings {
+ position: absolute;
+ top: 18px;
+ right: 15px;
+ z-index: 1;
+ outline: none;
+ text-decoration: none;
+ -webkit-transition: all 0.3s ease-out;
+ -moz-transition: all 0.3s ease-out;
+ opacity: 0.5;
+}
+#settings:before {
+ content: url(../images/settings.png);
+}
+
+#settings:hover {
+ opacity: 0.7;
+}
+#settings:active {
+ opacity: 0.8;
+}
+.ribbon {
+ position: absolute;
+ z-index: 3;
+ overflow: hidden;
+ height: 100px;
+ right: 0;
+ top: 0;
+ pointer-events: none;
+}
+.ribbon > a {
+ pointer-events: auto;
+ outline: none;
+ position: relative;
+ top: 25px;
+ left: 45px;
+ background-color: #a00;
+ -moz-transform: rotate(45deg);
+ -webkit-transform: rotate(45deg);
+ /* shadow */
+ -moz-box-shadow: 0 0 1em #333;
+ -webkit-box-shadow: 0 0 1em #333;
+ display: block;
+ border: 1px solid #faa;
+ color: #fff;
+ font: bold 10px 'Helvetiva Neue', Helvetica, Arial, sans-serif;
+ margin: 0.05em 0 0.075em 0;
+ padding: 0.5em 3.5em;
+ text-align: center;
+ text-decoration: none;
+ /* shadow */
+ text-shadow: 0 0 0.5em #444;
+}
+
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong. Retry.

0 comments on commit eb1506a

Please sign in to comment.