%!target: rst %!style: ../css/style.css %!preproc: 'BASEURLT2T' 'http://wiki.txt2tags.org/demos/' = txt2tags.js project = - txt2tags.js: a txt2tags parser in javascript. - markdown2txt2tags.js: an online quicker & dirty converter from markdown to txt2tags. //(both based on showdown)// - marked.js: a fork of marked.js, which can parse and convert txt2tags file to html. It was not "rebranded", so it can be easily integrated into other projects already using marked. __Note__: we have also produced an automatically exported version of showdown.js from txt2tags.js so you can also integrate it into projects initially set up for markdown. **Download [txt2tags.js BASEURLT2T/txt2tagsjs.zip]** == Usage == Developers can use Txt2tags.js to: - Add in-browser preview to existing Txt2tags apps Txt2tags.js' output is (almost always) identical to txt2tags.py, so the server can reproduce exactly the output that the user saw. (See below for exceptions.) - Add Txt2tags input to programs that don't support it Any app that accepts HTML input can now be made to speak Txt2tags by modifying the input pages's HTML. If your application lets users edit documents again later, then they won't have access to the original Txt2tags text. But this should be good enough for many uses -- and you can do it with just a two-line ``onsubmit`` function! - Add Txt2tags input to closed-source web apps You can write bookmarklets or userscripts to extend any standard textarea on the web so that it accepts Txt2tags instead of HTML. With a little more hacking, the same can probably be done with many rich edit controls. - Build new web apps from scratch A Txt2tags.js front-end can send back text in Txt2tags, HTML or both, so you can trade bandwidth for server load to reduce your cost of operation. If your app requires JavaScript, you won't need to do any Txt2tags processing on the server at all. == Quick Example == ``` Txt2tagsjs - Txt2tags in Javascript ``` For some working examples, see: - inline: [sample_inline.html sample_inline.html] //(based on showdown)// - loading external file: [sample_external_file.html sample_external_file.html] //(based on showdown)// - inline: [sample_marked_inline.html sample_marked_inline.html] //(based on marked)// - loading external file: [sample_marked_external_file.html sample_marked_external_file.html] //(based on marked)// You can also look at [txt2tagsjs-gui.html txt2tagsjs-gui.html] for a live renderer on txt2tags. Furthermore, there is [markdown2txt2tags/markdown2txt2tags.html markdown2txt2tags/markdown2txt2tags.html] which can convert from markdown to txt2tags syntax. //(work in progress, it's also based on showdown, a js port of markdown)// == Browser Compatibility == Txt2tags.js has been tested successfully with: - Firefox - Chromium % - Safari % - Opera - Konqueror - Midori % - Internet Explorer In theory, Txt2tags.js will work in any browser that supports ECMA 262 3rd Edition (JavaScript 1.5). The converter itself might even work in things that aren't web browsers, like Acrobat. No promises. == Known Differences in Output == In most cases, Txt2tags' output is identical to that of Python Txt2tags v2.6. What follows is a list of all known limitations. Please file an issue if you find more. This should work correctly: - headings - beautifulers (**bold**, //italic//, --strike-- and __underline__) - Pre-Formatted Text, code - lists - comments This doesn't work at all (yet): - macros - preprocessor (preproc / postproc) - 3 lines header This could be improved (soon, we hope): - in blockquote txt2tags marks are converted to html (yet the html code is not rendered, which is correct at least) - Tables (especially in txt2tags.js, the marked.js version should work most correctly) - definition lists (partial support) - links (some errors when multiple links are on the same line) - images (centering images) - some ordered **sublists** will be turned to unordered lists when you mix both types (txt2tags.js only) Basically, the marked.js version should be slightly better. == Related projects == - t2t-editor, a txt2tags text editor based on showdown and codemirror: - code: https://github.com/farvardin/t2t-editor/tree/txt2tags (forked from https://github.com/lepture/editor/) - demo: BASEURLT2T/t2t-editor/ - what is txt2tags - https://github.com/farvardin/whatistxt2tags (forked from https://github.com/kirkstrobeck/whatismarkdown.com) - "txt2tags here", a txt2tags converter for rich-form (for thunderbird email client and webmails) - code: https://github.com/farvardin/txt2tags-here (forked from https://github.com/adam-p/markdown-here) - download: BASEURLT2T/ - Minimalist Online Txt2tags Editor: - code: https://github.com/farvardin/MinimalistOnlineTxt2tagsEditor (forked from https://github.com/pioul/MinimalistOnlineMarkdownEditor) - demo: BASEURLT2T/mote == Tests (TODO: not yet) == A suite of tests is available which require node.js. Once node is installed, run the following command from the project root to install the development dependencies: ``` npm install --dev Once installed the tests can be run from the project root using: ``` npm test New test cases can easily be added. Create a txt2tags file (ending in ``.t2t``) which contains the txt2tags to test. Create a ``.html`` file of the exact same name. It will automatically be tested when the tests are executed with ``mocha``. == Credits == This project was forked from https://github.com/coreyti Showdown Copyright (c) 2007 John Fraser. http://www.attacklab.net/ Showdown maintained by Corey Innis https://github.com/coreyti and others Marked.js Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed) txt2tags.js hacks by Eric Forgeot