Skip to content

Instantly share code, notes, and snippets.

@esmooov
Created December 15, 2015 21:10
Show Gist options
  • Save esmooov/d33a066bae21741d873e to your computer and use it in GitHub Desktop.
Save esmooov/d33a066bae21741d873e to your computer and use it in GitHub Desktop.
window.storyFormat({
"name":"Entweedle",
"version":"1.0.2",
"author":'<a href="http://twitter.com/gnustoboz">Michael McCollum</a>',
"description":"Free utility format to export your story into twee format.",
"image":"icon.svg",
"url":"http://maximumverbosity.net/twine/Entweedle/",
"license":'<a href="http://opensource.org/licenses/MIT">MIT License</a>',
"proofing":false,
"source":"<html>\r\n\t<head>\r\n\t\t<title>{{STORY_NAME}}</title>\r\n\t\t<script type=\"text/javascript\">\r\n/**\r\n * Entweedle - Twine 2 Twee Export Story Format\r\n * \r\n * Copyright (c) 2015 Michael McCollum\r\n * http://www.maximumverbosity.net/twine/Illume/\r\n *\r\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and\r\n * associated documentation files (the \"Software\"), to deal in the Software without restriction,\r\n * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,\r\n * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,\r\n * subject to the following conditions:\r\n *\r\n * The above copyright notice and this permission notice shall be included in all copies or substantial\r\n * portions of the Software.\r\n *\r\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT\r\n * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\r\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\r\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\r\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r\n */\r\nwindow.onload=function(){if(typeof(window.Entweedle)==\"undefined\"){window.Entweedle={convert:function(){var output=window.document.getElementById(\"output\");output.innerHTML=this.export();},export:function(){var buffer=[];var storyData=window.document.getElementsByTagName(\"tw-storydata\");if(storyData){buffer.push(this.buildPassage(\"StoryTitle\",\"\",storyData[0].getAttribute(\"name\")));}\nvar userScript=window.document.getElementById(\"twine-user-script\");if(userScript){buffer.push(this.buildPassage(\"UserScript\",\"script\",userScript.innerHTML));}\nvar userStylesheet=window.document.getElementById(\"twine-user-stylesheet\");if(userStylesheet){buffer.push(this.buildPassage(\"UserStylesheet\",\"stylesheet\",userStylesheet.innerHTML));}\nvar passages=window.document.getElementsByTagName(\"tw-passagedata\");for(var i=0;i<passages.length;++i){buffer.push(this.buildPassageFromElement(passages[i]));}\nreturn buffer.join('');},buildPassageFromElement:function(passage){var name=passage.getAttribute(\"name\");if(!name){name=\"Untitled Passage\";}\nvar tags=passage.getAttribute(\"tags\");var content=passage.textContent;return this.buildPassage(name,tags,content);},buildPassage:function(title,tags,content){var result=[];result.push(\":: \",title);if(tags){result.push(\"[\",tags,\"]\");}\nresult.push(\"\\r\\n\",this.scrub(content),\"\\r\\n\\r\\n\");return result.join('');},scrub:function(content){if(content){content=content.replace(/^::/gm,\" ::\");content=content.replace(/\\</gm,\"&lt;\");content=content.replace(/\\>/gm,\"&gt;\");}\nreturn content;}}}\nwindow.Entweedle.convert();}\t\t\r\n\t\t</script>\r\n\t</head>\r\n\t<body>\r\n\t\t<pre id=\"output\">\r\n\t\t\r\n\t\t</pre>\r\n\t\t<div id=\"storyData\" style=\"display: none;\">\r\n\t\t\t{{STORY_DATA}}\r\n\t\t</div>\r\n\t</body>\r\n</html>"
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment