├── markdown-service ├── config.ru ├── lib │ └── markdown │ │ ├── service │ │ ├── views │ │ │ ├── debug.erb │ │ │ ├── editor.erb │ │ │ ├── service.erb │ │ │ ├── index.erb │ │ │ ├── _libs.erb │ │ │ ├── layout.erb │ │ │ ├── _version.erb │ │ │ ├── _editor_head.erb │ │ │ ├── _editor_setup.erb │ │ │ ├── _about.erb │ │ │ ├── _libs_service.erb │ │ │ ├── _debug.erb │ │ │ ├── _editor.erb │ │ │ └── _service.erb │ │ ├── public │ │ │ ├── i │ │ │ │ └── dots-white.gif │ │ │ ├── style.css │ │ │ ├── css │ │ │ │ └── markdown │ │ │ │ │ ├── themes │ │ │ │ │ └── basic.css │ │ │ │ │ └── note.css │ │ │ ├── note.html │ │ │ └── js │ │ │ │ ├── markdown.lib.js │ │ │ │ ├── markdown.api.js │ │ │ │ ├── markdown.note.js │ │ │ │ └── lib3rd │ │ │ │ └── showdown.min.js │ │ ├── docs │ │ │ └── welcome.md │ │ └── version.rb │ │ └── service.rb ├── HISTORY.md ├── .gitignore ├── boot.rb ├── Gemfile ├── Rakefile ├── README.md └── Manifest.txt ├── markdown.note ├── .gitignore ├── i │ └── dots-white.gif ├── README.md ├── css │ └── markdown │ │ ├── themes │ │ └── basic.css │ │ └── note.css ├── note.html └── js │ ├── markdown.lib.js │ ├── markdown.api.js │ ├── markdown.note.js │ └── lib3rd │ └── showdown.min.js ├── kramdown-service ├── config.ru ├── lib │ └── kramdown │ │ ├── service │ │ ├── views │ │ │ ├── debug.erb │ │ │ ├── editor.erb │ │ │ ├── service.erb │ │ │ ├── index.erb │ │ │ ├── _editor_head.erb │ │ │ ├── _editor_setup.erb │ │ │ ├── _version.erb │ │ │ ├── layout.erb │ │ │ ├── _debug.erb │ │ │ ├── _editor.erb │ │ │ └── _service.erb │ │ ├── public │ │ │ ├── i │ │ │ │ └── dots-white.gif │ │ │ ├── style.css │ │ │ ├── css │ │ │ │ └── markdown │ │ │ │ │ ├── themes │ │ │ │ │ └── basic.css │ │ │ │ │ └── note.css │ │ │ └── js │ │ │ │ ├── kramdown.js │ │ │ │ └── markdown.note.js │ │ ├── docs │ │ │ └── welcome.md │ │ └── version.rb │ │ └── service.rb ├── HISTORY.md ├── test │ ├── helper.rb │ ├── test_kramdown.rb │ ├── test_markdown.rb │ └── test_babelmark.rb ├── bin │ └── kramup ├── .gitignore ├── boot.rb ├── Gemfile ├── TODOS.md ├── Gemfile.lock ├── Rakefile ├── Manifest.txt ├── README.md └── NOTES.md ├── markdown.note.starter ├── .gitignore ├── css │ ├── markdown.themes.basic.css │ └── markdown.note.css ├── README.md ├── note.html └── js │ ├── markdown.note.js │ └── showdown.min.js ├── markdown-tools ├── HISTORY.md ├── Manifest.txt ├── .gitignore ├── lib │ └── markdown │ │ ├── cli │ │ ├── opts.rb │ │ ├── version.rb │ │ ├── gen.rb │ │ └── runner.rb │ │ └── tools.rb ├── bin │ └── markdown ├── Rakefile └── README.md ├── markdown ├── HISTORY.md ├── TODO.md ├── test │ ├── helper.rb │ ├── test_redcarpet.rb │ └── test_kramdown.rb ├── .gitignore ├── lib │ ├── markdown │ │ ├── engines │ │ │ ├── rpeg_markdown.rb │ │ │ ├── bluecloth.rb │ │ │ ├── maruku.rb │ │ │ ├── rdiscount.rb │ │ │ ├── pandoc_ruby.rb │ │ │ ├── redcarpet.rb │ │ │ └── kramdown.rb │ │ ├── version.rb │ │ ├── wrapper.rb │ │ └── config.rb │ └── markdown.rb ├── Manifest.txt ├── Rakefile ├── sandbox │ ├── bench.rb │ ├── rest.text │ └── test.text └── README.md ├── markdown.lib.js ├── README.md └── markdown.lib.js ├── markdown.themes ├── README.md └── basic.css ├── markdown.api.js ├── README.md └── markdown.api.js ├── README.md └── LICENSE.md /markdown-service/config.ru: -------------------------------------------------------------------------------- 1 | require './boot' 2 | run Markdown::Server 3 | -------------------------------------------------------------------------------- /markdown.note/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Komodo project files 3 | 4 | *.kpf 5 | 6 | -------------------------------------------------------------------------------- /kramdown-service/config.ru: -------------------------------------------------------------------------------- 1 | require './boot' 2 | 3 | run Kramdown::Service 4 | 5 | -------------------------------------------------------------------------------- /kramdown-service/lib/kramdown/service/views/debug.erb: -------------------------------------------------------------------------------- 1 | 2 | <%= erb :'_debug' %> 3 | 4 | -------------------------------------------------------------------------------- /markdown-service/lib/markdown/service/views/debug.erb: -------------------------------------------------------------------------------- 1 | 2 | <%= erb :'_debug' %> 3 | 4 | -------------------------------------------------------------------------------- /markdown.note.starter/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Komodo project files 3 | 4 | *.kpf 5 | 6 | -------------------------------------------------------------------------------- /kramdown-service/HISTORY.md: -------------------------------------------------------------------------------- 1 | ### 0.0.1 / 2016-04-15 2 | 3 | * Everything is new. First release 4 | -------------------------------------------------------------------------------- /markdown-service/HISTORY.md: -------------------------------------------------------------------------------- 1 | ### 0.1 / 2014-12-06 2 | 3 | * Everything is new. First release 4 | -------------------------------------------------------------------------------- /markdown-tools/HISTORY.md: -------------------------------------------------------------------------------- 1 | ### 0.1 / 2014-12-06 2 | 3 | * Everything is new. First release 4 | -------------------------------------------------------------------------------- /markdown/HISTORY.md: -------------------------------------------------------------------------------- 1 | ### 1.2.1 2 | 3 | ### 0.1 / 2012-05-26 4 | 5 | * Everything is new. First release -------------------------------------------------------------------------------- /markdown/TODO.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Minor 4 | 5 | * in --about add version of gem dependencies (e.g. props etc.) 6 | -------------------------------------------------------------------------------- /markdown.note/i/dots-white.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rubycocos/markdown/HEAD/markdown.note/i/dots-white.gif -------------------------------------------------------------------------------- /kramdown-service/lib/kramdown/service/views/editor.erb: -------------------------------------------------------------------------------- 1 | 2 | <%= erb :'_editor' %> 3 | 4 | -------------------------------------------------------------------------------- /markdown-service/lib/markdown/service/views/editor.erb: -------------------------------------------------------------------------------- 1 | 2 | <%= erb :'_editor' %> 3 | 4 | -------------------------------------------------------------------------------- /kramdown-service/lib/kramdown/service/views/service.erb: -------------------------------------------------------------------------------- 1 | 2 | <%= erb :'_service' %> 3 | 4 | 5 | -------------------------------------------------------------------------------- /kramdown-service/lib/kramdown/service/views/index.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | <%= erb :'_editor' %> 4 | 5 | 6 | -------------------------------------------------------------------------------- /kramdown-service/lib/kramdown/service/public/i/dots-white.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rubycocos/markdown/HEAD/kramdown-service/lib/kramdown/service/public/i/dots-white.gif -------------------------------------------------------------------------------- /markdown-service/lib/markdown/service/public/i/dots-white.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rubycocos/markdown/HEAD/markdown-service/lib/markdown/service/public/i/dots-white.gif -------------------------------------------------------------------------------- /kramdown-service/test/helper.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | # minitest setup 4 | require 'minitest/autorun' 5 | 6 | 7 | ## our own code 8 | require 'kramdown/service' 9 | 10 | 11 | -------------------------------------------------------------------------------- /markdown-service/lib/markdown/service/views/service.erb: -------------------------------------------------------------------------------- 1 | 2 | <%= erb :'_service' %> 3 | 4 | <%= erb :'_libs_service' %> 5 | 6 | -------------------------------------------------------------------------------- /markdown/test/helper.rb: -------------------------------------------------------------------------------- 1 | 2 | ## $:.unshift(File.dirname(__FILE__)) 3 | 4 | ## minitest setup 5 | 6 | require 'minitest/autorun' 7 | 8 | 9 | ## our own code 10 | $LOAD_PATH.unshift( './lib' ) 11 | 12 | require 'markdown' 13 | 14 | -------------------------------------------------------------------------------- /markdown-tools/Manifest.txt: -------------------------------------------------------------------------------- 1 | HISTORY.md 2 | Manifest.txt 3 | README.md 4 | Rakefile 5 | bin/markdown 6 | lib/markdown/cli/gen.rb 7 | lib/markdown/cli/opts.rb 8 | lib/markdown/cli/runner.rb 9 | lib/markdown/cli/version.rb 10 | lib/markdown/tools.rb 11 | -------------------------------------------------------------------------------- /kramdown-service/bin/kramup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | ## for testing use: 4 | ## $ ruby -I ./lib bin/kramup 5 | 6 | ## note: use chmod a+x kramup to add execute flag 7 | 8 | 9 | require 'kramdown/service' 10 | 11 | 12 | Kramdown::Service.run! 13 | -------------------------------------------------------------------------------- /markdown-service/lib/markdown/service/views/index.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | <%= erb :'_editor' %> 4 | 5 | 6 | <%= erb :'_libs' %> 7 | 8 | 9 | <%= erb :'_service' %> 10 | 11 | 12 | <%= erb :'_about' %> 13 | 14 | -------------------------------------------------------------------------------- /kramdown-service/.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | .config 5 | coverage 6 | InstalledFiles 7 | lib/bundler/man 8 | pkg 9 | rdoc 10 | spec/reports 11 | test/tmp 12 | test/version_tmp 13 | tmp 14 | 15 | # YARD artifacts 16 | .yardoc 17 | _yardoc 18 | doc/ 19 | 20 | -------------------------------------------------------------------------------- /markdown-service/.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | .config 5 | coverage 6 | InstalledFiles 7 | lib/bundler/man 8 | pkg 9 | rdoc 10 | spec/reports 11 | test/tmp 12 | test/version_tmp 13 | tmp 14 | 15 | # YARD artifacts 16 | .yardoc 17 | _yardoc 18 | doc/ 19 | 20 | -------------------------------------------------------------------------------- /markdown-tools/.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | .config 5 | coverage 6 | InstalledFiles 7 | lib/bundler/man 8 | pkg 9 | rdoc 10 | spec/reports 11 | test/tmp 12 | test/version_tmp 13 | tmp 14 | 15 | # YARD artifacts 16 | .yardoc 17 | _yardoc 18 | doc/ 19 | 20 | -------------------------------------------------------------------------------- /markdown-tools/lib/markdown/cli/opts.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | module Markdown 4 | 5 | class Opts 6 | 7 | def output_path=(value) 8 | @output_path = value 9 | end 10 | 11 | def output_path 12 | @output_path || '.' 13 | end 14 | 15 | end # class Opts 16 | end # module Markdown 17 | -------------------------------------------------------------------------------- /kramdown-service/boot.rb: -------------------------------------------------------------------------------- 1 | 2 | 3 | ENV['RACK_ENV'] ||= 'development' 4 | 5 | puts "ENV['RACK_ENV'] = #{ENV['RACK_ENV']}" 6 | 7 | ## NB: no DB required/in use for now; just simple service calls 8 | 9 | ## add lib to load path 10 | 11 | $LOAD_PATH << "./lib" 12 | 13 | require './lib/kramdown/service.rb' 14 | 15 | -------------------------------------------------------------------------------- /kramdown-service/Gemfile: -------------------------------------------------------------------------------- 1 | source 'http://rubygems.org' 2 | 3 | gem 'sinatra', :require => 'sinatra/base' 4 | 5 | 6 | gem 'kramdown' 7 | gem 'kramdown-service' ## :path => '.' ## try to use local (in-place) version 8 | 9 | 10 | ################### 11 | # more libs 12 | 13 | gem 'rouge' # syntax highlighter 14 | 15 | 16 | -------------------------------------------------------------------------------- /markdown-tools/bin/markdown: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | ################### 4 | # == DEV TIPS: 5 | # 6 | # For local testing run like: 7 | # 8 | # ruby -Ilib bin/markdown 9 | # 10 | # Set the executable bit in Linux. Example: 11 | # 12 | # % chmod a+x bin/markdown 13 | # 14 | 15 | require 'markdown/tools' 16 | 17 | Markdown.main 18 | -------------------------------------------------------------------------------- /markdown-service/lib/markdown/service/views/_libs.erb: -------------------------------------------------------------------------------- 1 | 2 |
| <%= lib %> | 10 |<%= conv.version %> | 11 |12 | |
6 | What's the markdown gem?
7 |
8 |
9 | The Markdown Engine Wrapper (markdown) Ruby gem lets you use
10 | your markdown library of choice in Ruby.
11 | Find out more »
12 |
15 | Questions? Comments? 16 | Send them along to the Free Web Slide Show Alternatives (S5, S6, S9, Slidy And Friends) Forum/Mailing List. 17 | Thanks! 18 |
19 | 20 |License 21 | The markdown scripts are dedicated to the public domain. 22 | Use it as you please with no restrictions whatsoever. 23 |
24 | -------------------------------------------------------------------------------- /markdown-tools/lib/markdown/tools.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require 'markdown' 4 | require 'markdown/service' # pull in markdown HTTP JSON service addon 5 | 6 | 7 | # our own code 8 | 9 | require 'markdown/cli/version' # note: let version always go first 10 | require 'markdown/cli/gen' 11 | require 'markdown/cli/opts' 12 | require 'markdown/cli/runner' 13 | 14 | 15 | module Markdown 16 | 17 | def self.main 18 | 19 | # allow env variable to set RUBYOPT-style default command line options 20 | # e.g. -o site 21 | markdownopt = ENV[ 'MARKDOWNOPT' ] 22 | 23 | args = [] 24 | args += markdownopt.split if markdownopt 25 | args += ARGV.dup 26 | 27 | Runner.new.run(args) 28 | end 29 | 30 | end # module Markdown 31 | 32 | 33 | Markdown.main if __FILE__ == $0 34 | -------------------------------------------------------------------------------- /markdown.api.js/README.md: -------------------------------------------------------------------------------- 1 | # markdown.api.js 2 | 3 | markdown HTTP JSON API (also known as dingus) 4 | 5 | 6 | Use "standard (default)" markdown library (engine/processor): 7 | 8 | ``` 9 | GET /dingus?text=Hello+World 10 | ``` 11 | 12 | or use lib parameter to select 13 | 14 | ``` 15 | GET /dingus?lib=kramdown&text=Hello+World 16 | ``` 17 | 18 | results in: 19 | 20 | ```json 21 | { 22 | name: "kramdown", 23 | html: "Hello World
", 24 | version: "1.5.6" 25 | } 26 | ``` 27 | 28 | 29 | 30 | 31 | ## License 32 | 33 | The `markdown.api.js` scripts are dedicated to the public domain. 34 | Use it as you please with no restrictions whatsoever. 35 | 36 | ## Questions? Comments? 37 | 38 | Send them along to the [Markdown Mailing List](http://six.pairlist.net/mailman/listinfo/markdown-discuss). 39 | Thanks! 40 | -------------------------------------------------------------------------------- /markdown-tools/Rakefile: -------------------------------------------------------------------------------- 1 | require 'hoe' 2 | require './lib/markdown/cli/version.rb' 3 | 4 | Hoe.spec 'markdown-tools' do 5 | 6 | self.version = MarkdownCli::VERSION 7 | 8 | self.summary = 'markdown-tools gem - markdown command line tools' 9 | self.description = summary 10 | 11 | self.urls = ['https://github.com/rubylibs/markdown-tools'] 12 | 13 | self.author = 'Gerald Bauer' 14 | self.email = 'webslideshow@googlegroups.com' 15 | 16 | self.extra_deps = [ 17 | ['markdown'], 18 | ['markdown-service'], 19 | ] 20 | 21 | # switch extension to .markdown for gihub formatting 22 | self.readme_file = 'README.md' 23 | self.history_file = 'HISTORY.md' 24 | 25 | self.licenses = ['Public Domain'] 26 | 27 | self.spec_extras = { 28 | required_ruby_version: '>= 1.9.2' 29 | } 30 | 31 | end 32 | -------------------------------------------------------------------------------- /markdown-service/Rakefile: -------------------------------------------------------------------------------- 1 | require 'hoe' 2 | require './lib/markdown/service/version.rb' 3 | 4 | Hoe.spec 'markdown-service' do 5 | 6 | self.version = MarkdownService::VERSION 7 | 8 | self.summary = 'markdown-service gem - markdown HTTP JSON API service' 9 | self.description = summary 10 | 11 | self.urls = ['https://github.com/rubylibs/markdown-service'] 12 | 13 | self.author = 'Gerald Bauer' 14 | self.email = 'webslideshow@googlegroups.com' 15 | 16 | self.extra_deps = [ 17 | ['markdown'], 18 | ['sinatra'], 19 | ] 20 | 21 | # switch extension to .markdown for gihub formatting 22 | self.readme_file = 'README.md' 23 | self.history_file = 'HISTORY.md' 24 | 25 | self.licenses = ['Public Domain'] 26 | 27 | self.spec_extras = { 28 | required_ruby_version: '>= 1.9.2' 29 | } 30 | 31 | end 32 | -------------------------------------------------------------------------------- /markdown-service/lib/markdown/service/views/_libs_service.erb: -------------------------------------------------------------------------------- 1 | 2 || <%= lib %> | 10 |/ <%= conv.version %> | 11 | -
12 | GET
13 |
14 | /markdown?lib=<%= lib %>&text=Hello+World!
15 |
16 |
17 | |
18 |
19 | • GET
20 |
21 | /dingus?lib=<%= lib %>&text=Hello+World!
22 |
23 |
24 | |
25 |
7 | <%= params.inspect %> 8 |9 | 10 | 11 |
14 | request.scheme <%= request.scheme %> 15 | request.script_name <%= request.script_name %> 16 | request.path_info <%= request.path_info %> 17 | request.port <%= request.port %> 18 | request.request_method <%= request.request_method %> 19 | request.query_string <%= request.query_string %> 20 | request.host <%= request.host %> 21 | request.referrer <%= request.referrer %> 22 | request.user_agent <%= request.user_agent %> 23 | request.url <%= request.url %> 24 | request.path <%= request.path %> 25 | request.ip <%= request.ip %> 26 |27 | 28 | -------------------------------------------------------------------------------- /markdown/Rakefile: -------------------------------------------------------------------------------- 1 | require 'hoe' 2 | require './lib/markdown/version.rb' 3 | 4 | Hoe.spec 'markdown' do 5 | 6 | self.version = Markdown::VERSION 7 | 8 | self.summary = 'Markdown Engine Wrapper - Use Your Markdown Library of Choice' 9 | self.description = summary 10 | 11 | self.urls = { home: 'https://github.com/rubylibs/markdown' } 12 | 13 | self.author = 'Gerald Bauer' 14 | self.email = 'gerald.bauer@gmail.com' 15 | 16 | self.extra_deps = [ 17 | ['props','>= 1.1.2'], 18 | ['textutils','>=0.10.0'], 19 | ['kramdown','>= 1.5.0'] 20 | ] 21 | 22 | # switch extension to .markdown for github formatting 23 | self.readme_file = 'README.md' 24 | self.history_file = 'HISTORY.md' 25 | 26 | self.licenses = ['Public Domain'] 27 | 28 | self.spec_extras = { 29 | required_ruby_version: '>= 1.9.2' 30 | } 31 | 32 | end 33 | -------------------------------------------------------------------------------- /kramdown-service/Rakefile: -------------------------------------------------------------------------------- 1 | require 'hoe' 2 | require './lib/kramdown/service/version.rb' 3 | 4 | Hoe.spec 'kramdown-service' do 5 | 6 | self.version = KramdownService::VERSION 7 | 8 | self.summary = 'kramdown-service gem - kramdown HTTP JSON API service (convert markdown to HTML or LaTeX)' 9 | self.description = summary 10 | 11 | self.urls = ['https://github.com/writekit/kramdown-service'] 12 | 13 | self.author = 'Gerald Bauer' 14 | self.email = 'wwwmake@googlegroups.com' 15 | 16 | self.extra_deps = [ 17 | ['kramdown', '>=1.17.0'], ## markdown converter 18 | ['rouge'], ## syntax highlighter 19 | ['sinatra', '>=2.0.4'], 20 | ] 21 | 22 | # switch extension to .markdown for gihub formatting 23 | self.readme_file = 'README.md' 24 | self.history_file = 'HISTORY.md' 25 | 26 | self.licenses = ['Public Domain'] 27 | 28 | self.spec_extras = { 29 | required_ruby_version: '>= 2.2.2' 30 | } 31 | 32 | end 33 | -------------------------------------------------------------------------------- /kramdown-service/lib/kramdown/service/views/layout.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
16 | kramdown Online Editor17 | |
18 | 19 | HTTP JSON API Service • 20 | About 21 | | 22 |
Hello World!
\n", html ) 28 | end 29 | 30 | def test_to_html_banner_true 31 | html = Markdown.new( 'Hello World!', banner: true ).to_html 32 | assert( html =~ /^$/ ) 35 | end 36 | 37 | 38 | end # class TestRedcarpet 39 | -------------------------------------------------------------------------------- /markdown-service/lib/markdown/service/public/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; } 3 | 4 | a, a:visited { 5 | color: #8B0000; 6 | text-decoration: none; } 7 | 8 | a:hover { 9 | color: #8B0000; 10 | background-color: gold; 11 | text-decoration: underline; } 12 | 13 | .params { 14 | color: green; 15 | font-style: italic; 16 | font-weight: bold; } 17 | 18 | pre { 19 | background-color: #F3F3F3; 20 | border-bottom: 1px solid #BBBBBB; 21 | border-top: 1px solid #BBBBBB; 22 | padding: 4px; } 23 | 24 | 25 | h3 { 26 | border-bottom: 1px solid black; 27 | } 28 | 29 | /**************** 30 | * api 31 | */ 32 | 33 | .api a, .api a:visited { 34 | color: black; 35 | } 36 | 37 | 38 | /********** 39 | * version / powered by 40 | */ 41 | 42 | .version { 43 | text-align: center; 44 | margin-top: 10px; 45 | color: grey; } 46 | .version a, 47 | .version a:visited, 48 | .version span { 49 | font-size: 12px; 50 | color: grey; } 51 | 52 | -------------------------------------------------------------------------------- /kramdown-service/lib/kramdown/service/views/_debug.erb: -------------------------------------------------------------------------------- 1 | 2 |7 | <%= params.inspect %> 8 |9 | 10 | 11 |
14 | request.scheme <%= request.scheme %> 15 | request.script_name <%= request.script_name %> 16 | request.path_info <%= request.path_info %> 17 | request.port <%= request.port %> 18 | request.request_method <%= request.request_method %> 19 | request.query_string <%= request.query_string %> 20 | request.host <%= request.host %> 21 | request.referrer <%= request.referrer %> 22 | request.user_agent <%= request.user_agent %> 23 | request.url <%= request.url %> 24 | request.path <%= request.path %> 25 | request.ip <%= request.ip %> 26 |27 | 28 | 29 |
36 | <%= JSON.pretty_generate( doc.options ) %> 37 |38 | 39 | -------------------------------------------------------------------------------- /markdown/lib/markdown.rb: -------------------------------------------------------------------------------- 1 | # core and stlibs 2 | 3 | require 'yaml' 4 | require 'json' 5 | require 'pp' 6 | require 'logger' 7 | require 'optparse' 8 | require 'fileutils' 9 | 10 | 11 | # gems 12 | 13 | require 'props' # manage properties/settings/env 14 | 15 | class Env 16 | def self.markdown_lib 17 | ENV['MARKDOWN_LIB'] 18 | end 19 | end # class Env 20 | 21 | 22 | require 'textutils' # text filters and helpers 23 | 24 | 25 | # our own code 26 | 27 | require_relative 'markdown/version' # Note: let version always go first 28 | require_relative 'markdown/config' 29 | require_relative 'markdown/engines/bluecloth' 30 | require_relative 'markdown/engines/kramdown' 31 | require_relative 'markdown/engines/maruku' 32 | require_relative 'markdown/engines/pandoc_ruby' 33 | require_relative 'markdown/engines/rdiscount' 34 | require_relative 'markdown/engines/redcarpet' 35 | require_relative 'markdown/engines/rpeg_markdown' 36 | require_relative 'markdown/wrapper' 37 | 38 | 39 | 40 | # say hello 41 | puts Markdown.banner if $DEBUG || (defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG) 42 | -------------------------------------------------------------------------------- /kramdown-service/Manifest.txt: -------------------------------------------------------------------------------- 1 | HISTORY.md 2 | Manifest.txt 3 | README.md 4 | Rakefile 5 | bin/kramup 6 | lib/kramdown/service.rb 7 | lib/kramdown/service/docs/welcome.md 8 | lib/kramdown/service/public/css/markdown/note.css 9 | lib/kramdown/service/public/css/markdown/themes/basic.css 10 | lib/kramdown/service/public/i/dots-white.gif 11 | lib/kramdown/service/public/js/kramdown.js 12 | lib/kramdown/service/public/js/lib3rd/jquery-2.0.1.min.js 13 | lib/kramdown/service/public/js/markdown.note.js 14 | lib/kramdown/service/public/style.css 15 | lib/kramdown/service/version.rb 16 | lib/kramdown/service/views/_debug.erb 17 | lib/kramdown/service/views/_editor.erb 18 | lib/kramdown/service/views/_editor_head.erb 19 | lib/kramdown/service/views/_editor_setup.erb 20 | lib/kramdown/service/views/_service.erb 21 | lib/kramdown/service/views/_version.erb 22 | lib/kramdown/service/views/debug.erb 23 | lib/kramdown/service/views/editor.erb 24 | lib/kramdown/service/views/index.erb 25 | lib/kramdown/service/views/layout.erb 26 | lib/kramdown/service/views/service.erb 27 | test/helper.rb 28 | test/test_babelmark.rb 29 | test/test_kramdown.rb 30 | test/test_markdown.rb 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # markdown tools, libraries & scripts 2 | 3 | Gems: 4 | 5 | - [markdown](markdown) - markdown engine wrapper - use your markdown library of choice 6 | - [markdown-service](markdown-service) - markdown HTTP JSON API service 7 | - [markdown-tools](markdown-tools) - markdown command line tools 8 | 9 | 10 | 11 | - [kramdown-service](kramdown-service) - kramdown HTTP JSON API service (convert markdown to HTML or LaTeX) 12 | 13 | 14 | - [markdown.note](markdown.note) - another simple single-page, server-less markdown editor in javascript & hypertext 15 | - [markdown.note.starter](markdown.note.starter) - another simple single-page, server-less markdown editor in javaScript & hypertext (started edition) 16 | - [markdown.api.js](markdown.api.js) - markdown HTTP JSON API (also known as dingus) 17 | - [markdown.lib.js](markdown.lib.js) - markdown (wrapper) for libraries in JavaScript 18 | 19 | 20 | - [markdown.themes](markdown.themes) - markdown themes (styles) 21 | 22 | 23 | 24 | ## License 25 | 26 | The scripts are dedicated to the public domain. 27 | Use it as you please with no restrictions whatsoever. 28 | 29 | -------------------------------------------------------------------------------- /markdown-service/lib/markdown/service/views/_editor.erb: -------------------------------------------------------------------------------- 1 | 2 | <%= erb :'_editor_setup' %> 3 | 4 | 5 |
|
12 |
13 |
14 |
15 |
16 |
17 |
18 | |
19 | 20 | 21 | 22 | 23 | 24 | 25 | | 26 |
| 29 | 30 | 31 | 32 | Use 33 | 34 | 35 | [ Update ] 36 | [ Use White Color Theme ] 37 | 38 | 39 | 40 | | 41 |42 | 43 | [ Show HTML ] 44 | 45 | | 46 |
Hello, World!
\n" 25 | latex = "Hello, World!\n\n" 26 | 27 | assert_equal html, doc.to_html 28 | assert_equal latex, doc.to_latex 29 | end # method test_kramdown 30 | 31 | 32 | def test_gfm_w_rouge 33 | 34 | text = "A Line.\nAnother Line.\n" 35 | 36 | doc = Kramdown::Document.new( text, 37 | input: 'GFM', 38 | hard_wrap: false, 39 | syntax_highlighter: 'rouge' ) 40 | 41 | puts "options:" 42 | pp doc.options 43 | 44 | html = "A Line.\nAnother Line.
\n" 45 | 46 | pp doc.to_html 47 | 48 | assert_equal html, doc.to_html 49 | end # method test_gfm_w_rouge 50 | 51 | 52 | 53 | end # class TestKramdown 54 | 55 | -------------------------------------------------------------------------------- /kramdown-service/lib/kramdown/service/public/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; } 3 | 4 | 5 | a, a:visited { 6 | color: black; /* was #8B0000; */ 7 | text-decoration: none; } 8 | 9 | a:hover { 10 | color: black; /* was #8B0000; */ 11 | text-decoration: underline; } 12 | 13 | .header .title a, 14 | .header .title a:visited { 15 | text-decoration: none; 16 | } 17 | 18 | .footer { 19 | margin: 10px; 20 | } 21 | 22 | 23 | 24 | .params { 25 | color: green; 26 | font-style: italic; 27 | font-weight: bold; } 28 | 29 | pre { 30 | background-color: #F3F3F3; 31 | border-bottom: 1px solid #BBBBBB; 32 | border-top: 1px solid #BBBBBB; 33 | padding: 4px; } 34 | 35 | 36 | h3 { 37 | border-bottom: 1px solid black; 38 | } 39 | 40 | /**************** 41 | * api 42 | */ 43 | 44 | .api a, .api a:visited { 45 | color: black; 46 | } 47 | 48 | 49 | /********** 50 | * version / powered by 51 | */ 52 | 53 | .version { 54 | text-align: center; 55 | margin-top: 10px; 56 | color: grey; } 57 | .version a, 58 | .version a:visited, 59 | .version span { 60 | font-size: 12px; 61 | color: grey; } 62 | 63 | -------------------------------------------------------------------------------- /markdown/test/test_kramdown.rb: -------------------------------------------------------------------------------- 1 | ### 2 | # NB: for local testing run like: 3 | # 4 | # 1.9.x: ruby -Ilib test/test_kramdown.rb 5 | 6 | # core and stlibs 7 | 8 | require_relative 'helper' 9 | 10 | 11 | class TestKramdown < Minitest::Test 12 | 13 | def setup 14 | puts 'enter setup' 15 | lib = Markdown.lib 16 | puts ' set lib=kramdown' 17 | Markdown.lib = 'kramdown' 18 | end 19 | 20 | def test_lib 21 | lib = Markdown.lib 22 | assert_equal( 'kramdown', lib ) 23 | end 24 | 25 | def test_to_html_banner_false 26 | md = Markdown.new( 'Hello World!', banner: false ) 27 | 28 | assert_equal( "Hello World!
\n", md.to_html ) 29 | assert_equal( "Hello World!
\n", md.to_html ) 30 | assert_equal( "Hello World!
\n", md.to_html ) 31 | end 32 | 33 | def test_to_html_banner_true 34 | md = Markdown.new( 'Hello World!', banner: true ) 35 | html1 = md.to_html 36 | html2 = md.to_html 37 | assert( html1 =~ /^$/ ) 41 | end 42 | 43 | end # class TestKramdown 44 | -------------------------------------------------------------------------------- /kramdown-service/lib/kramdown/service/views/_editor.erb: -------------------------------------------------------------------------------- 1 | 2 | <%= erb :'_editor_setup' %> 3 | 4 ||
7 |
8 |
9 |
10 | Use
11 |
12 |
13 | 14 | [ Update ] 15 | 16 | 17 | 18 | 19 | |
20 |
21 | 22 | 27 | | 28 |
|
39 |
40 |
41 |
42 |
43 |
44 |
45 | |
46 | 47 | 48 | 49 | 50 | 51 | 52 | | 53 |
Hello, World!
\n" 32 | assert_equal html, last_response.body 33 | end # method test_hello_world 34 | 35 | 36 | def test_latex_hello_world 37 | get '/markdown', { text: 'Hello, World!', to: 'latex' } 38 | 39 | assert last_response.ok? 40 | assert_equal 'text/latex;charset=utf-8', last_response.headers['Content-Type'] 41 | 42 | pp last_response.body 43 | 44 | latex = "Hello, World!\n\n" 45 | assert_equal latex, last_response.body 46 | end # method test_latex_hello_world 47 | 48 | 49 | 50 | end # class TestMarkdown 51 | 52 | -------------------------------------------------------------------------------- /markdown-service/README.md: -------------------------------------------------------------------------------- 1 | # markdown-service gem - markdown HTTP JSON API service 2 | 3 | * home :: [github.com/rubylibs/markdown-service](https://github.com/writekit/markdown-service) 4 | * bugs :: [github.com/rubylibs/markdown-service/issues](https://github.com/writekit/markdown-service/issues) 5 | * gem :: [rubygems.org/gems/markdown-service](https://rubygems.org/gems/markdown-service) 6 | * rdoc :: [rubydoc.info/gems/markdown-service](http://rubydoc.info/gems/markdown-service) 7 | 8 | 9 | ## Usage - Web Service / HTTP (JSON) API - `GET /markdown` 10 | 11 | Try the `markdown` HTTP (JSON) API running 12 | on Heroku [`note.herokuapp.com`](http://note.herokuapp.com). 13 | 14 | Example: 15 | 16 | GET /markdown?text=Hello+World! 17 | 18 |Hello World!
19 | 20 | 21 | 22 | ## Dependencies / Building Blocks 23 | 24 | [Markdown Note](https://github.com/writekit/markdown-note) - Another simple single-page, server-less Markdown editor 25 | in JavaScript & Hypertext. 26 | 27 | 28 | ## License 29 | 30 | The `markdown-service` scripts are dedicated to the public domain. 31 | Use it as you please with no restrictions whatsoever. 32 | 33 | 34 | ## Questions? Comments? 35 | 36 | Send them along to the 37 | [wwwmake forum/mailing list](http://groups.google.com/group/wwwmake). 38 | Thanks! 39 | -------------------------------------------------------------------------------- /markdown.note/README.md: -------------------------------------------------------------------------------- 1 | # Markdown Note 2 | 3 | Another simple single-page, server-less Markdown editor in JavaScript & Hypertext. 4 | 5 | ## Live Demo 6 | 7 | Try Markdown Note running 8 | on GitHub Pages [`writekit.github.io/markdown.note/note.html`](http://writekit.github.io/markdown.note/note.html). 9 | 10 | 11 | ## How to Use 12 | 13 | ### Step 1: Get a copy of the repo 14 | 15 | Option 1) Use `git clone` 16 | 17 | ~~~ 18 | $ git clone https://github.com/writekit/markdown.note.git 19 | ~~~ 20 | 21 | or 22 | 23 | Option 2) Use zip archive 24 | 25 | Download a copy of the zip archive and unzip it. 26 | 27 | Note: Look for the "Download ZIP" button on this page on the right side at the bottom of the "<> Code" tab. 28 | If you can't find the "Download ZIP" button, use the [`markdown.note/archive/gh-pages.zip`](https://github.com/writekit/markdown.note/archive/gh-pages.zip) link. 29 | 30 | ### Step 2: Open the `note.html` page in your web browser 31 | 32 | That's it. Enjoy. 33 | 34 | 35 | ## License 36 | 37 | The `markdown-note` scripts are dedicated to the public domain. 38 | Use it as you please with no restrictions whatsoever. 39 | 40 | 41 | ## Questions? Comments? 42 | 43 | Send them along to the [Markdown Mailing List](http://six.pairlist.net/mailman/listinfo/markdown-discuss). 44 | Thanks! 45 | -------------------------------------------------------------------------------- /markdown.themes/basic.css: -------------------------------------------------------------------------------- 1 | 2 | /*********** 3 | * fix: use scss or less; cleanup css 4 | * 5 | ****/ 6 | 7 | 8 | .markdown a, 9 | .markdown a:visited { 10 | color: #2e80d3; 11 | text-decoration: underline; 12 | } 13 | 14 | .markdown em { 15 | background-color: #fffeca; 16 | padding: 0 0.08em; 17 | } 18 | 19 | .markdown abbr { 20 | border-bottom: 1px dashed; 21 | cursor: help; 22 | } 23 | 24 | .markdown blockquote { 25 | border-left: 5px solid #ddd; 26 | color: #555; 27 | margin: 0 0 1em; 28 | padding-left: 0.6em; 29 | } 30 | 31 | .markdown pre { 32 | background-color: #f8f8ff; 33 | border: 1px solid #dedede; 34 | color: #444; 35 | font-family: "Bitstream Vera Sans Mono", Courier, monospace; 36 | font-size: 0.8em; 37 | line-height: 1.5em; 38 | margin: 0 0 2em; 39 | overflow: auto; 40 | padding: 0.5em; 41 | } 42 | 43 | .markdown pre code { 44 | background-color: #f8f8ff; 45 | border: medium none; 46 | font-size: 1em; 47 | padding: 0; 48 | } 49 | 50 | .markdown code { 51 | background-color: #f8f8ff; 52 | border: 1px solid #dedede; 53 | color: #444; 54 | padding: 0 0.2em; 55 | font-family: "Bitstream Vera Sans Mono", Courier, monospace; 56 | font-size: 0.8em; 57 | } 58 | -------------------------------------------------------------------------------- /markdown.note/css/markdown/themes/basic.css: -------------------------------------------------------------------------------- 1 | 2 | /*********** 3 | * fix: use scss or less; cleanup css 4 | * 5 | ****/ 6 | 7 | 8 | .markdown a, 9 | .markdown a:visited { 10 | color: #2e80d3; 11 | text-decoration: underline; 12 | } 13 | 14 | .markdown em { 15 | background-color: #fffeca; 16 | padding: 0 0.08em; 17 | } 18 | 19 | .markdown abbr { 20 | border-bottom: 1px dashed; 21 | cursor: help; 22 | } 23 | 24 | .markdown blockquote { 25 | border-left: 5px solid #ddd; 26 | color: #555; 27 | margin: 0 0 1em; 28 | padding-left: 0.6em; 29 | } 30 | 31 | .markdown pre { 32 | background-color: #f8f8ff; 33 | border: 1px solid #dedede; 34 | color: #444; 35 | font-family: "Bitstream Vera Sans Mono", Courier, monospace; 36 | font-size: 0.8em; 37 | line-height: 1.5em; 38 | margin: 0 0 2em; 39 | overflow: auto; 40 | padding: 0.5em; 41 | } 42 | 43 | .markdown pre code { 44 | background-color: #f8f8ff; 45 | border: medium none; 46 | font-size: 1em; 47 | padding: 0; 48 | } 49 | 50 | .markdown code { 51 | background-color: #f8f8ff; 52 | border: 1px solid #dedede; 53 | color: #444; 54 | padding: 0 0.2em; 55 | font-family: "Bitstream Vera Sans Mono", Courier, monospace; 56 | font-size: 0.8em; 57 | } 58 | -------------------------------------------------------------------------------- /markdown.note.starter/css/markdown.themes.basic.css: -------------------------------------------------------------------------------- 1 | 2 | /*********** 3 | * fix: use scss or less; cleanup css 4 | * 5 | ****/ 6 | 7 | 8 | .markdown a, 9 | .markdown a:visited { 10 | color: #2e80d3; 11 | text-decoration: underline; 12 | } 13 | 14 | .markdown em { 15 | background-color: #fffeca; 16 | padding: 0 0.08em; 17 | } 18 | 19 | .markdown abbr { 20 | border-bottom: 1px dashed; 21 | cursor: help; 22 | } 23 | 24 | .markdown blockquote { 25 | border-left: 5px solid #ddd; 26 | color: #555; 27 | margin: 0 0 1em; 28 | padding-left: 0.6em; 29 | } 30 | 31 | .markdown pre { 32 | background-color: #f8f8ff; 33 | border: 1px solid #dedede; 34 | color: #444; 35 | font-family: "Bitstream Vera Sans Mono", Courier, monospace; 36 | font-size: 0.8em; 37 | line-height: 1.5em; 38 | margin: 0 0 2em; 39 | overflow: auto; 40 | padding: 0.5em; 41 | } 42 | 43 | .markdown pre code { 44 | background-color: #f8f8ff; 45 | border: medium none; 46 | font-size: 1em; 47 | padding: 0; 48 | } 49 | 50 | .markdown code { 51 | background-color: #f8f8ff; 52 | border: 1px solid #dedede; 53 | color: #444; 54 | padding: 0 0.2em; 55 | font-family: "Bitstream Vera Sans Mono", Courier, monospace; 56 | font-size: 0.8em; 57 | } 58 | -------------------------------------------------------------------------------- /markdown-service/Manifest.txt: -------------------------------------------------------------------------------- 1 | HISTORY.md 2 | Manifest.txt 3 | README.md 4 | Rakefile 5 | lib/markdown/service.rb 6 | lib/markdown/service/docs/welcome.md 7 | lib/markdown/service/public/css/markdown/note.css 8 | lib/markdown/service/public/css/markdown/themes/basic.css 9 | lib/markdown/service/public/i/dots-white.gif 10 | lib/markdown/service/public/js/lib3rd/jquery-2.0.1.min.js 11 | lib/markdown/service/public/js/lib3rd/pagedown.js 12 | lib/markdown/service/public/js/lib3rd/showdown.min.js 13 | lib/markdown/service/public/js/markdown.api.js 14 | lib/markdown/service/public/js/markdown.lib.js 15 | lib/markdown/service/public/js/markdown.note.js 16 | lib/markdown/service/public/note.html 17 | lib/markdown/service/public/style.css 18 | lib/markdown/service/version.rb 19 | lib/markdown/service/views/_about.erb 20 | lib/markdown/service/views/_debug.erb 21 | lib/markdown/service/views/_editor.erb 22 | lib/markdown/service/views/_editor_head.erb 23 | lib/markdown/service/views/_editor_setup.erb 24 | lib/markdown/service/views/_libs.erb 25 | lib/markdown/service/views/_libs_service.erb 26 | lib/markdown/service/views/_service.erb 27 | lib/markdown/service/views/_version.erb 28 | lib/markdown/service/views/debug.erb 29 | lib/markdown/service/views/editor.erb 30 | lib/markdown/service/views/index.erb 31 | lib/markdown/service/views/layout.erb 32 | lib/markdown/service/views/service.erb 33 | -------------------------------------------------------------------------------- /markdown-service/lib/markdown/service/public/css/markdown/themes/basic.css: -------------------------------------------------------------------------------- 1 | 2 | /*********** 3 | * fix: use scss or less; cleanup css 4 | * 5 | ****/ 6 | 7 | 8 | .markdown a, 9 | .markdown a:visited { 10 | color: #2e80d3; 11 | text-decoration: underline; 12 | } 13 | 14 | .markdown em { 15 | background-color: #fffeca; 16 | padding: 0 0.08em; 17 | } 18 | 19 | .markdown abbr { 20 | border-bottom: 1px dashed; 21 | cursor: help; 22 | } 23 | 24 | .markdown blockquote { 25 | border-left: 5px solid #ddd; 26 | color: #555; 27 | margin: 0 0 1em; 28 | padding-left: 0.6em; 29 | } 30 | 31 | .markdown pre { 32 | background-color: #f8f8ff; 33 | border: 1px solid #dedede; 34 | color: #444; 35 | font-family: "Bitstream Vera Sans Mono", Courier, monospace; 36 | font-size: 0.8em; 37 | line-height: 1.5em; 38 | margin: 0 0 2em; 39 | overflow: auto; 40 | padding: 0.5em; 41 | } 42 | 43 | .markdown pre code { 44 | background-color: #f8f8ff; 45 | border: medium none; 46 | font-size: 1em; 47 | padding: 0; 48 | } 49 | 50 | .markdown code { 51 | background-color: #f8f8ff; 52 | border: 1px solid #dedede; 53 | color: #444; 54 | padding: 0 0.2em; 55 | font-family: "Bitstream Vera Sans Mono", Courier, monospace; 56 | font-size: 0.8em; 57 | } 58 | -------------------------------------------------------------------------------- /markdown.note.starter/README.md: -------------------------------------------------------------------------------- 1 | # Markdown Note (Starter Edition) 2 | 3 | Another simple single-page, server-less Markdown editor in JavaScript & Hypertext. 4 | 5 | 6 | ## Live Demo 7 | 8 | Try Markdown Note running 9 | on GitHub Pages [`writekit.github.io/markdown.note.starter/note.html`](http://writekit.github.io/markdown.note.starter/note.html). 10 | 11 | 12 | ## How to Use 13 | 14 | ### Step 1: Get a copy of the repo 15 | 16 | Option 1) Use `git clone` 17 | 18 | ~~~ 19 | $ git clone https://github.com/writekit/markdown.note.starter.git 20 | ~~~ 21 | 22 | or 23 | 24 | Option 2) Use zip archive 25 | 26 | Download a copy of the zip archive and unzip it. 27 | 28 | Note: Look for the "Download ZIP" button on this page on the right side at the bottom of the "<> Code" tab. 29 | If you can't find the "Download ZIP" button, use the [`markdown.note.starter/archive/gh-pages.zip`](https://github.com/writekit/markdown.note.starter/archive/gh-pages.zip) link. 30 | 31 | ### Step 2: Open the `note.html` page in your web browser 32 | 33 | That's it. Enjoy. 34 | 35 | 36 | ## License 37 | 38 | The `markdown.note.starter` scripts are dedicated to the public domain. 39 | Use it as you please with no restrictions whatsoever. 40 | 41 | 42 | ## Questions? Comments? 43 | 44 | Send them along to the [Markdown Mailing List](http://six.pairlist.net/mailman/listinfo/markdown-discuss). 45 | Thanks! 46 | -------------------------------------------------------------------------------- /markdown.note.starter/note.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 ||
29 |
30 |
31 |
32 |
33 | |
34 | 35 | 36 | 37 | 38 | | 39 |
| 42 | 43 | [ Update ] 44 | [ Use White Color Theme ] 45 | | 46 |47 | 48 | [ Show HTML ] 49 | | 50 |
Hello, World!
\n" 33 | 34 | assert_equal 'kramdown', data['name'] 35 | assert_equal Kramdown::VERSION, data['version'] 36 | assert_equal html, data['html'] 37 | 38 | end # method test_hello_world 39 | 40 | def test_nil 41 | 42 | get '/babelmark' 43 | 44 | assert last_response.ok? 45 | assert_equal 'application/json', last_response.headers['Content-Type'] 46 | 47 | data = JSON.parse( last_response.body ) 48 | pp data 49 | 50 | html ="\n" # note: empty string w/ kramdown becomes empty string w/ newline 51 | 52 | assert_equal 'kramdown', data['name'] 53 | assert_equal Kramdown::VERSION, data['version'] 54 | assert_equal html, data['html'] 55 | end # method test_nil 56 | 57 | 58 | end # class TestBabelmark 59 | 60 | -------------------------------------------------------------------------------- /markdown.note/css/markdown/note.css: -------------------------------------------------------------------------------- 1 | 2 | body { 3 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 4 | background-color: #EEEEEC; 5 | } 6 | 7 | /*********** 8 | * fix: use scss or less; cleanup css 9 | * 10 | ****/ 11 | 12 | a#output-toggle, a#output-toggle:visited, a#output-toggle:hover, 13 | a#output-update, a#output-update:visited, a#output-update:hover, 14 | a#input-toggle, a#input-toggle:visited, a#input-toggle:hover { 15 | color: black; 16 | text-decoration: none; } 17 | 18 | 19 | 20 | #input #note { 21 | width: 100%; min-height: 400px; 22 | 23 | -moz-box-sizing: border-box; 24 | -webkit-box-sizing: border-box; 25 | box-sizing: border-box; 26 | } 27 | 28 | 29 | .black { 30 | background-color: #2E3436; 31 | border: medium none; 32 | border-radius: 4px 4px 4px 4px; 33 | padding: 6px; 34 | color: #FFFFFF; 35 | font-weight: bold; 36 | } 37 | 38 | 39 | #output { 40 | width: 100%; 41 | /* padding-left: 10px; */ 42 | background-color: white; 43 | border-radius: 4px 4px 4px 4px; 44 | padding: 6px; 45 | 46 | -moz-box-sizing: border-box; 47 | -webkit-box-sizing: border-box; 48 | box-sizing: border-box; 49 | } 50 | 51 | 52 | #output-source { 53 | display: none; 54 | width: 100%; min-height: 400px; 55 | background-color: #EEEEEC; 56 | border: none; 57 | 58 | -moz-box-sizing: border-box; 59 | -webkit-box-sizing: border-box; 60 | box-sizing: border-box; 61 | } 62 | 63 | 64 | #output-loading { 65 | display: none; 66 | width: 21px; 67 | height: 5px; 68 | background: url('../../i/dots-white.gif') no-repeat; 69 | /* -webkit-transition: all 0.1s linear; */ 70 | } -------------------------------------------------------------------------------- /kramdown-service/lib/kramdown/service/public/css/markdown/note.css: -------------------------------------------------------------------------------- 1 | 2 | body { 3 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 4 | background-color: #EEEEEC; 5 | } 6 | 7 | /*********** 8 | * fix: use scss or less; cleanup css 9 | * 10 | ****/ 11 | 12 | a#output-toggle, a#output-toggle:visited, a#output-toggle:hover, 13 | a#output-update, a#output-update:visited, a#output-update:hover, 14 | a#input-toggle, a#input-toggle:visited, a#input-toggle:hover { 15 | color: black; 16 | text-decoration: none; } 17 | 18 | 19 | 20 | #input #note { 21 | width: 100%; min-height: 600px; 22 | 23 | -moz-box-sizing: border-box; 24 | -webkit-box-sizing: border-box; 25 | box-sizing: border-box; 26 | } 27 | 28 | 29 | .black { 30 | background-color: #2E3436; 31 | border: medium none; 32 | border-radius: 4px 4px 4px 4px; 33 | padding: 6px; 34 | color: #FFFFFF; 35 | font-weight: bold; 36 | } 37 | 38 | 39 | #output { 40 | width: 100%; 41 | /* padding-left: 10px; */ 42 | background-color: white; 43 | border-radius: 4px 4px 4px 4px; 44 | padding: 6px; 45 | 46 | -moz-box-sizing: border-box; 47 | -webkit-box-sizing: border-box; 48 | box-sizing: border-box; 49 | } 50 | 51 | 52 | #output-source { 53 | display: none; 54 | width: 100%; min-height: 600px; 55 | background-color: #EEEEEC; 56 | border: none; 57 | 58 | -moz-box-sizing: border-box; 59 | -webkit-box-sizing: border-box; 60 | box-sizing: border-box; 61 | } 62 | 63 | 64 | #output-loading { 65 | display: none; 66 | width: 21px; 67 | height: 5px; 68 | background: url('../../i/dots-white.gif') no-repeat; 69 | /* -webkit-transition: all 0.1s linear; */ 70 | } -------------------------------------------------------------------------------- /markdown-service/lib/markdown/service/public/css/markdown/note.css: -------------------------------------------------------------------------------- 1 | 2 | body { 3 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 4 | background-color: #EEEEEC; 5 | } 6 | 7 | /*********** 8 | * fix: use scss or less; cleanup css 9 | * 10 | ****/ 11 | 12 | a#output-toggle, a#output-toggle:visited, a#output-toggle:hover, 13 | a#output-update, a#output-update:visited, a#output-update:hover, 14 | a#input-toggle, a#input-toggle:visited, a#input-toggle:hover { 15 | color: black; 16 | text-decoration: none; } 17 | 18 | 19 | 20 | #input #note { 21 | width: 100%; min-height: 600px; 22 | 23 | -moz-box-sizing: border-box; 24 | -webkit-box-sizing: border-box; 25 | box-sizing: border-box; 26 | } 27 | 28 | 29 | .black { 30 | background-color: #2E3436; 31 | border: medium none; 32 | border-radius: 4px 4px 4px 4px; 33 | padding: 6px; 34 | color: #FFFFFF; 35 | font-weight: bold; 36 | } 37 | 38 | 39 | #output { 40 | width: 100%; 41 | /* padding-left: 10px; */ 42 | background-color: white; 43 | border-radius: 4px 4px 4px 4px; 44 | padding: 6px; 45 | 46 | -moz-box-sizing: border-box; 47 | -webkit-box-sizing: border-box; 48 | box-sizing: border-box; 49 | } 50 | 51 | 52 | #output-source { 53 | display: none; 54 | width: 100%; min-height: 600px; 55 | background-color: #EEEEEC; 56 | border: none; 57 | 58 | -moz-box-sizing: border-box; 59 | -webkit-box-sizing: border-box; 60 | box-sizing: border-box; 61 | } 62 | 63 | 64 | #output-loading { 65 | display: none; 66 | width: 21px; 67 | height: 5px; 68 | background: url('../../i/dots-white.gif') no-repeat; 69 | /* -webkit-transition: all 0.1s linear; */ 70 | } -------------------------------------------------------------------------------- /markdown/lib/markdown/engines/redcarpet.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | module Markdown 4 | module Engine 5 | 6 | def redcarpet_version 7 | Redcarpet::VERSION 8 | end 9 | 10 | def redcarpet_to_html( content, options={} ) 11 | 12 | ## NB: uses redcarpet2 13 | # 14 | # see https://github.com/tanoku/redcarpet 15 | 16 | extensions_ary = options.fetch( 'extensions', [] ) 17 | show_banner = options.fetch( 'banner', true ) 18 | 19 | extensions_hash = {} 20 | extensions_ary.each do |e| 21 | extensions_hash[ e.to_sym ] = true 22 | end 23 | 24 | puts " Converting Markdown-text (#{content.length} bytes) to HTML using library redcarpet (#{Redcarpet::VERSION}) w/ HTML render" 25 | puts " using extensions: #{extensions_ary.to_json}" 26 | 27 | redcarpet = Redcarpet::Markdown.new( Redcarpet::Render::HTML, extensions_hash ) 28 | content = redcarpet.render( content ) 29 | 30 | if show_banner 31 | # todo: check content size and newlines 32 | # check banner option? 33 | # only add banner if some newlines and size > treshold? 34 | 35 | banner_begin =<GET /markdown
7 |
8 |
9 | 10 | Input: 11 |
12 | 13 |kramdown, redcarpet, etc)
20 | Example:
21 | GET
22 |
23 | /markdown?text=Hello+World!
24 |
25 |
26 |
29 | Response: 30 |
31 | 32 |Status: 200 OK
33 | Content-Type: text/html
34 |
35 | <p>Hello World!<p>
36 |
37 |
38 |
39 | GET /dingus
42 |
43 |
44 | 45 | Input: 46 |
47 | 48 |kramdown, redcarpet, etc)Example:
56 | GET
57 |
58 | /dingus?text=Hello+World!
59 |
60 |
61 |
64 | Response: 65 |
66 | 67 |Status: 200 OK
68 | Content-Type: application/json
69 |
70 | {
71 | 'name': 'kramdown',
72 | 'html': '<p>Hello World!<p>',
73 | 'version': '1.0.2'
74 | }
75 |
76 |
--------------------------------------------------------------------------------
/markdown.note/note.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | |
34 |
35 |
36 |
37 |
38 |
39 |
40 | |
41 | 42 | 43 | 44 | 45 | 46 | 47 | | 48 |
| 51 | 52 | 53 | 54 | Use 55 | 56 | 57 | [ Update ] 58 | [ Use White Color Theme ] 59 | 60 | 61 | 62 | | 63 |64 | 65 | [ Show HTML ] 66 | 67 | | 68 |
|
34 |
35 |
36 |
37 |
38 |
39 |
40 | |
41 | 42 | 43 | 44 | 45 | 46 | 47 | | 48 |
| 51 | 52 | 53 | 54 | Use 55 | 56 | 57 | [ Update ] 58 | [ Use White Color Theme ] 59 | 60 | 61 | 62 | | 63 |64 | 65 | [ Show HTML ] 66 | 67 | | 68 |
Hello World!
45 | 46 | 47 | Example 2 - Converting to LaTeX: 48 | 49 | GET /markdown?text=Hello+World!&to=latex 50 | 51 | Hello World! 52 | 53 | 54 | 55 | 56 | ## License 57 | 58 | The `kramdown-service` scripts are dedicated to the public domain. 59 | Use it as you please with no restrictions whatsoever. 60 | 61 | 62 | ## Questions? Comments? 63 | 64 | Send them along to the 65 | [wwwmake forum/mailing list](http://groups.google.com/group/wwwmake). 66 | Thanks! 67 | -------------------------------------------------------------------------------- /markdown.lib.js/markdown.lib.js: -------------------------------------------------------------------------------- 1 | 2 | var markdown_libs_new = function() { 3 | 4 | // Showdown usage: 5 | // 6 | // var text = "Markdown *rocks*."; 7 | // 8 | // var converter = new Showdown.converter(); 9 | // var html = converter.makeHtml(text); 10 | // 11 | // alert(html); 12 | 13 | var showdownConverter; 14 | 15 | 16 | // pagedown Usage: 17 | // 18 | // var text = "Markdown *rocks*."; 19 | // 20 | // var converter = new Markdown.Converter(); 21 | // var html = converter.makeHtml(text); 22 | // 23 | // alert(html); 24 | // 25 | 26 | var pagedownConverter; 27 | 28 | function showdown( text, handle_html ) 29 | { 30 | // todo: get version from code possible? how? 31 | 32 | var html = showdownConverter.makeHtml( text ); 33 | 34 | var banner_begin = "\n\n" 39 | 40 | var banner_end = "\n\n"; 41 | 42 | handle_html( banner_begin + html + banner_end ); 43 | } 44 | 45 | function pagedown( text, handle_html ) 46 | { 47 | var html = pagedownConverter.makeHtml( text ); 48 | 49 | var banner_begin = "\n\n" 54 | 55 | var banner_end = "\n\n"; 56 | 57 | handle_html( banner_begin + html + banner_end ); 58 | } 59 | 60 | 61 | function _init() 62 | { 63 | showdownConverter = new Showdown.converter(); 64 | pagedownConverter = new Markdown.Converter(); 65 | } 66 | 67 | _init(); 68 | 69 | return { 70 | showdown: showdown, 71 | pagedown: pagedown 72 | } 73 | } // fn makrdown_libs_new 74 | 75 | 76 | var markdown_libs = markdown_libs_new(); 77 | 78 | //////////////// 79 | // use like 80 | // 81 | // markdown_libs.showdown( text, success ); 82 | // etc. 83 | -------------------------------------------------------------------------------- /markdown.note/js/markdown.lib.js: -------------------------------------------------------------------------------- 1 | 2 | var markdown_libs_new = function() { 3 | 4 | // Showdown usage: 5 | // 6 | // var text = "Markdown *rocks*."; 7 | // 8 | // var converter = new Showdown.converter(); 9 | // var html = converter.makeHtml(text); 10 | // 11 | // alert(html); 12 | 13 | var showdownConverter; 14 | 15 | 16 | // pagedown Usage: 17 | // 18 | // var text = "Markdown *rocks*."; 19 | // 20 | // var converter = new Markdown.Converter(); 21 | // var html = converter.makeHtml(text); 22 | // 23 | // alert(html); 24 | // 25 | 26 | var pagedownConverter; 27 | 28 | function showdown( text, handle_html ) 29 | { 30 | // todo: get version from code possible? how? 31 | 32 | var html = showdownConverter.makeHtml( text ); 33 | 34 | var banner_begin = "\n\n" 39 | 40 | var banner_end = "\n\n"; 41 | 42 | handle_html( banner_begin + html + banner_end ); 43 | } 44 | 45 | function pagedown( text, handle_html ) 46 | { 47 | var html = pagedownConverter.makeHtml( text ); 48 | 49 | var banner_begin = "\n\n" 54 | 55 | var banner_end = "\n\n"; 56 | 57 | handle_html( banner_begin + html + banner_end ); 58 | } 59 | 60 | 61 | function _init() 62 | { 63 | showdownConverter = new Showdown.converter(); 64 | pagedownConverter = new Markdown.Converter(); 65 | } 66 | 67 | _init(); 68 | 69 | return { 70 | showdown: showdown, 71 | pagedown: pagedown 72 | } 73 | } // fn makrdown_libs_new 74 | 75 | 76 | var markdown_libs = markdown_libs_new(); 77 | 78 | //////////////// 79 | // use like 80 | // 81 | // markdown_libs.showdown( text, success ); 82 | // etc. 83 | -------------------------------------------------------------------------------- /markdown-service/lib/markdown/service/public/js/markdown.lib.js: -------------------------------------------------------------------------------- 1 | 2 | var markdown_libs_new = function() { 3 | 4 | // Showdown usage: 5 | // 6 | // var text = "Markdown *rocks*."; 7 | // 8 | // var converter = new Showdown.converter(); 9 | // var html = converter.makeHtml(text); 10 | // 11 | // alert(html); 12 | 13 | var showdownConverter; 14 | 15 | 16 | // pagedown Usage: 17 | // 18 | // var text = "Markdown *rocks*."; 19 | // 20 | // var converter = new Markdown.Converter(); 21 | // var html = converter.makeHtml(text); 22 | // 23 | // alert(html); 24 | // 25 | 26 | var pagedownConverter; 27 | 28 | function showdown( text, handle_html ) 29 | { 30 | // todo: get version from code possible? how? 31 | 32 | var html = showdownConverter.makeHtml( text ); 33 | 34 | var banner_begin = "\n\n" 39 | 40 | var banner_end = "\n\n"; 41 | 42 | handle_html( banner_begin + html + banner_end ); 43 | } 44 | 45 | function pagedown( text, handle_html ) 46 | { 47 | var html = pagedownConverter.makeHtml( text ); 48 | 49 | var banner_begin = "\n\n" 54 | 55 | var banner_end = "\n\n"; 56 | 57 | handle_html( banner_begin + html + banner_end ); 58 | } 59 | 60 | 61 | function _init() 62 | { 63 | showdownConverter = new Showdown.converter(); 64 | pagedownConverter = new Markdown.Converter(); 65 | } 66 | 67 | _init(); 68 | 69 | return { 70 | showdown: showdown, 71 | pagedown: pagedown 72 | } 73 | } // fn makrdown_libs_new 74 | 75 | 76 | var markdown_libs = markdown_libs_new(); 77 | 78 | //////////////// 79 | // use like 80 | // 81 | // markdown_libs.showdown( text, success ); 82 | // etc. 83 | -------------------------------------------------------------------------------- /kramdown-service/lib/kramdown/service/views/_service.erb: -------------------------------------------------------------------------------- 1 | 2 |GET /markdown
7 |
8 |
9 | 10 | Input: 11 |
12 | 13 |
23 | Example (HTML):
24 | GET
25 |
26 | /markdown?text=Hello+World!
27 |
28 |
29 |
32 | Response: 33 |
34 | 35 |Status: 200 OK
36 | Content-Type: text/html
37 |
38 | <p>Hello World!<p>
39 |
40 |
41 |
42 |
43 |
44 |
45 | Example (LaTeX):
46 | GET
47 |
48 | /markdown?text=Hello+World!&to=latex
49 |
50 |
51 |
54 | Response: 55 |
56 | 57 |Status: 200 OK
58 | Content-Type: text/latex
59 |
60 | Hello World
61 |
62 |
63 |
64 |
65 |
66 | GET /babelmark
69 |
70 |
71 | 72 | Input: 73 |
74 | 75 |Example:
81 | GET
82 |
83 | /babelmark?text=Hello+World!
84 |
85 |
86 |
89 | Response: 90 |
91 | 92 |Status: 200 OK
93 | Content-Type: application/json
94 |
95 | {
96 | 'name': 'kramdown',
97 | 'html': '<p>Hello World!<p>',
98 | 'version': '1.10.0'
99 | }
100 |
101 |
102 |
--------------------------------------------------------------------------------
/markdown/lib/markdown/engines/kramdown.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module Markdown
4 | module Engine
5 |
6 | def kramdown_version
7 | Kramdown::VERSION
8 | end
9 |
10 | def kramdown_to_html( content, options={} )
11 |
12 | h = {}
13 |
14 | # todo: find an easier (more generic?) way to setup hash - possible?
15 | h[ :auto_ids ] = options.fetch( 'auto_ids', nil ) if options.fetch( 'auto_ids', nil )
16 | h[ :footnote_nr ] = options.fetch( 'footnote_nr',nil ) if options.fetch( 'footnote_nr', nil )
17 | h[ :entity_output ] = options.fetch( 'entity_output',nil ) if options.fetch( 'entity_output', nil )
18 | h[ :toc_levels ] = options.fetch( 'toc_levels',nil ) if options.fetch( 'toc_levels', nil )
19 | h[ :smart_quotes ] = options.fetch( 'smart_quotes',nil ) if options.fetch( 'smart_quotes', nil )
20 |
21 | show_banner = options.fetch( 'banner', true)
22 |
23 | # puts " Converting Markdown-text (#{content.length} bytes) to HTML using library kramdown (#{Kramdown::VERSION})"
24 | # puts " using options: #{h.to_json}"
25 |
26 | ## allow fenced blocks a la github flavored markup
27 | # -- thanks zenweb for inspiration:
28 | # https://github.com/seattlerb/zenweb/blob/master/lib/zenweb/plugins/markdown.rb
29 |
30 | content = content.
31 | gsub(/^``` *(\w+)/) { "{:lang=\"#$1\"}\n~~~" }.
32 | gsub(/^```/, '~~~')
33 |
34 | content = Kramdown::Document.new( content, h ).to_html
35 |
36 | if show_banner
37 |
38 | # todo: check content size and newlines
39 | # check banner option?
40 | # only add banner if some newlines and size > treshold?
41 |
42 | banner_begin =<186 | This can contain only *span* level elements. 187 |
188 | 189 | 190 | 191 | Emphasis 192 | -------- 193 | 194 | This is *emphasized*, 195 | _this_ too! 196 | 197 | 198 | This is **strong**, 199 | __this__ too! 200 | 201 | 202 | This w**ork**s as expected! 203 | 204 | 205 | 206 | Inline Code 207 | ----------- 208 | 209 | Use `Markdown.new(text).to_html` 210 | to convert the `text` in markdown 211 | syntax to HTML. 212 | 213 | 214 | Footnotes 215 | --------- 216 | 217 | This is a text with a footnote[^1]. 218 | 219 | [^1]: And here is the definition. 220 | 221 | 222 | This is a text with another footnote[^2]. 223 | 224 | [^2]: And here is the definition. 225 | 226 | 227 | This is a text with a footnote[^3]. 228 | 229 | [^3]: 230 | And here is the definition. 231 | 232 | > With a quote! 233 | -------------------------------------------------------------------------------- /markdown.note.starter/js/markdown.note.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | var markdown_note_new = function() { 4 | 5 | // use module pattern (see JavaScript - The Good Parts) 6 | 7 | var _converter = new Showdown.converter(); 8 | 9 | function markdown( text, onsuccess ) 10 | { 11 | // todo: get version from code possible? how? 12 | 13 | var banner_begin = "\n\n"; 18 | 19 | var banner_end = "\n\n"; 20 | 21 | var html = _converter.makeHtml( text ); 22 | 23 | onsuccess( banner_begin + html + banner_end ); 24 | } 25 | 26 | 27 | var $input, 28 | $input_toggle, 29 | $output, 30 | $output_source, 31 | $output_update, 32 | $output_toggle; 33 | 34 | var show_html = false; 35 | var use_white_color_theme = false; 36 | 37 | var welcome = 38 | "Welcome to Markdown. We hope you **really** enjoy using this." + 39 | "\n\n" + 40 | "Just type some [markdown](http://daringfireball.net/projects/markdown) on the left and see it on the right. *Simple as that.*"; 41 | 42 | var settings = { 43 | welcome: welcome, 44 | input_toggle: { 45 | label_black: '[ Use Black Color Theme]', 46 | label_white: '[ Use White Color Theme]' 47 | }, 48 | output_toggle: { 49 | label_show: '[ Show HTML ]', 50 | label_hide: '[ Hide HTML ]' 51 | } 52 | }; 53 | 54 | 55 | function toggle_output() 56 | { 57 | show_html = !show_html; 58 | 59 | if( show_html ) { 60 | $output_toggle.innerHTML = settings.output_toggle.label_hide; 61 | $output.style.display = 'none'; // hide() 62 | $output_source.style.display = 'block'; // show() 63 | } 64 | else { 65 | $output_toggle.innerHTML = settings.output_toggle.label_show; 66 | $output.style.display = 'block'; // show() 67 | $output_source.style.display = 'none'; // hide() 68 | } 69 | } 70 | 71 | 72 | function _toggle_color_theme() 73 | { 74 | use_white_color_theme = !use_white_color_theme; 75 | 76 | if( use_white_color_theme ) { 77 | $input.classList.remove( 'black' ); 78 | $input_toggle.innerHTML = settings.input_toggle.label_black; 79 | } 80 | else { 81 | $input.classList.add( 'black' ); 82 | $input_toggle.innerHTML = settings.input_toggle.label_white; 83 | } 84 | } 85 | 86 | function update_output() 87 | { 88 | var text = $input.value; // get markdown text 89 | 90 | markdown( text, function( html ) { 91 | $output.innerHTML = html; 92 | $output_source.innerHTML = html; 93 | }); 94 | } 95 | 96 | 97 | function _init() 98 | { 99 | $input = document.getElementById( 'note' ); // textarea for markdown source ); 100 | $input_toggle = document.getElementById( 'input-toggle' ); 101 | 102 | $output = document.getElementById( 'output' ); 103 | $output_source = document.getElementById( 'output-source' ); 104 | $output_update = document.getElementById( 'output-update' ); // a/link for update action 105 | $output_toggle = document.getElementById( 'output-toggle' ); 106 | 107 | $input_toggle.addEventListener( 'click', _toggle_color_theme, false); 108 | 109 | $output_update.addEventListener( 'click', update_output, false); 110 | $output_toggle.addEventListener( 'click', toggle_output, false); 111 | 112 | $input.value = settings.welcome; 113 | update_output(); 114 | } 115 | 116 | _init(); 117 | 118 | return { 119 | update: update_output, 120 | toggle: toggle_output 121 | } 122 | } // fn markdown_note_new 123 | -------------------------------------------------------------------------------- /markdown/lib/markdown/wrapper.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | module Markdown 4 | 5 | ## todo: use Converter inside Wrapper to avoid duplication 6 | 7 | class Converter 8 | def initialize( lib, mn_to_html, mn_version ) 9 | @lib = lib 10 | @mn_to_html = mn_to_html 11 | @mn_version = mn_version 12 | end 13 | 14 | def convert( text, options={} ) 15 | # call markdown filter; turn markdown lib name into method_name (mn) 16 | # eg. rpeg-markdown => rpeg_markdown_to_html 17 | send( @mn_to_html, text, options ) # call 1st configured markdown engine e.g. kramdown_to_html( content ) 18 | end 19 | 20 | def version 21 | send( @mn_version ) # call 1st configured markdown engine e.g. kramdown_version 22 | end 23 | 24 | include Engine 25 | end 26 | 27 | 28 | class Wrapper 29 | 30 | def initialize( lib, mn, content, options={} ) 31 | @lib = lib 32 | @mn = mn 33 | @content = content 34 | @options = options 35 | end 36 | 37 | def to_html 38 | # call markdown filter; turn markdown lib name into method_name (mn) 39 | # eg. rpeg-markdown => rpeg_markdown_to_html 40 | send( @mn, @content, @options ) # call 1st configured markdown engine e.g. kramdown_to_html( content ) 41 | end 42 | 43 | include Engine 44 | 45 | end # class Wrapper 46 | 47 | 48 | 49 | @@config = nil 50 | 51 | def self.lib=( lib ) 52 | if @@config.nil? 53 | @@config = Config.new 54 | end 55 | @@config.markdown_lib = lib 56 | end 57 | 58 | def self.lib 59 | if @@config.nil? 60 | @@config = Config.new 61 | end 62 | @@config.markdown_lib 63 | end 64 | 65 | def self.libs 66 | if @@config.nil? 67 | @@config = Config.new 68 | end 69 | @@config.markdown_libs 70 | end 71 | 72 | def self.extnames 73 | if @@config.nil? 74 | @@config = Config.new 75 | end 76 | @@config.markdown_extnames 77 | end 78 | 79 | def self.filters 80 | if @@config.nil? 81 | @@config = Config.new 82 | end 83 | @@config.markdown_filters 84 | end 85 | 86 | def self.dump # dump settings for debug/verbose flag 87 | if @@config.nil? 88 | @@config = Config.new 89 | end 90 | @@config.dump 91 | end 92 | 93 | 94 | def self.create_converter( lib ) 95 | if @@config.nil? 96 | @@config = Config.new 97 | end 98 | 99 | mn_to_html = @@config.markdown_to_html_method( lib ) # lets you use differnt options/converters for a single markdown lib 100 | mn_version = @@config.markdown_version_method( lib ) 101 | 102 | Converter.new( lib, mn_to_html, mn_version ) 103 | end 104 | 105 | 106 | def self.new( content, options={} ) 107 | 108 | ## options 109 | ## make sure keys are strings, that is, allow symbols for easy use 110 | ## but internally only use string (yaml gets use strings) 111 | 112 | ## fix: use stringify_keys! from activesupport (include dependency ?? why? why not??) 113 | options.keys.each do |key| 114 | options[ key.to_s ] = options.delete(key) 115 | end 116 | 117 | 118 | ## todo: allow options to pass in 119 | ## lets you change markdown engine/converter for every call 120 | ## e.g. lets you add config properties (as headers) to your document (for example) 121 | 122 | if @@config.nil? 123 | @@config = Config.new 124 | end 125 | 126 | lib = @@config.markdown_lib 127 | mn = @@config.markdown_to_html_method( lib ) # lets you use differnt options/converters for a single markdown lib 128 | defaults = @@config.markdown_lib_defaults( lib ) ## todo/fix: use mn / converter from defaults hash?? mn no longer needed?? 129 | 130 | props = Props.new( options, 'USER', Props.new( defaults, 'SYSTEM' )) 131 | 132 | Wrapper.new( lib, mn, content, props ) 133 | end 134 | 135 | end # module Markdown 136 | -------------------------------------------------------------------------------- /markdown-service/lib/markdown/service.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | ###### 4 | # NB: use rackup to startup Sinatra service (see config.ru) 5 | # 6 | # e.g. config.ru: 7 | # require './boot' 8 | # run Markdown::Server 9 | 10 | 11 | # 3rd party libs/gems 12 | 13 | require 'sinatra/base' 14 | 15 | # require 'logutils' 16 | # require 'logutils/activerecord' 17 | 18 | 19 | # our own code 20 | 21 | require 'markdown/service/version' # let version always go first 22 | 23 | 24 | 25 | module Markdown 26 | 27 | class Server < Sinatra::Base 28 | 29 | PUBLIC_FOLDER = "#{MarkdownService.root}/lib/markdown/service/public" 30 | VIEWS_FOLDER = "#{MarkdownService.root}/lib/markdown/service/views" 31 | 32 | puts "[boot] markdown-service - setting public folder to: #{PUBLIC_FOLDER}" 33 | puts "[boot] markdown-service - setting views folder to: #{VIEWS_FOLDER}" 34 | 35 | set :public_folder, PUBLIC_FOLDER # set up the static dir (with images/js/css inside) 36 | set :views, VIEWS_FOLDER # set up the views dir 37 | 38 | set :static, true # set up static file routing 39 | 40 | 41 | ############################################## 42 | # Controllers / Routing / Request Handlers 43 | 44 | def welcome_markdown 45 | ## todo: rotate welcome / use random number for index 46 | # place markdown docs in server/docs 47 | text = File.read( "#{MarkdownService.root}/lib/markdown/service/docs/welcome.md" ) 48 | text 49 | end 50 | 51 | 52 | get %r{/(service|services|srv|s)$} do 53 | erb :service 54 | end 55 | 56 | get %r{/(note|notes|n)$} do 57 | # for testing/debugging use copied sources 1:1 from markdown-notepad repo 58 | redirect '/note.html' 59 | end 60 | 61 | get %r{/(editor|edit|ed|e)$} do 62 | # NB: use editor for "ruby-enhanced" parts of note 63 | @welcome_markdown = welcome_markdown 64 | @welcome_html = Markdown.new( @welcome_markdown ).to_html 65 | 66 | erb :editor 67 | end 68 | 69 | get '/' do 70 | @welcome_markdown = welcome_markdown 71 | @welcome_html = Markdown.new( @welcome_markdown ).to_html 72 | 73 | erb :index 74 | end 75 | 76 | 77 | ## todo: use 3rd party services from markdown.yml (lets you configure) 78 | # e.g. http://johnmacfarlane.net/cgi-bin/pandoc-dingus?text=hi 79 | 80 | 81 | def markdownify( params, opts={} ) 82 | pp params 83 | text = params[:text] 84 | lib = params[:lib] # optional 85 | pp text 86 | pp lib 87 | 88 | # fix: use activesupport -> .present? 89 | if lib.nil? == false && lib.empty? == false 90 | Markdown.lib = lib 91 | end 92 | 93 | Markdown.new( text, opts ).to_html 94 | end 95 | 96 | 97 | # return babelmark2/dingus-style json 98 | get '/markdown/dingus' do 99 | html = markdownify( params ) 100 | 101 | ## todo: use converter for markdownify 102 | lib = Markdown.lib 103 | conv = Markdown.create_converter( lib ) 104 | 105 | data = { 106 | name: lib, 107 | html: html, 108 | version: conv.version 109 | } 110 | 111 | json_or_jsonp( data.to_json ) 112 | end 113 | 114 | # return hypertext (html) 115 | get '/markdown' do 116 | content_type 'text/html' 117 | markdownify( params ) 118 | end 119 | 120 | # return html wrapped in json (follows babelfish2 dingus service api) 121 | get '/dingus' do 122 | html = markdownify( params, banner: false ) 123 | 124 | ## todo: use converter for markdownify 125 | lib = Markdown.lib 126 | conv = Markdown.create_converter( lib ) 127 | 128 | data = { 129 | name: lib, 130 | html: html, 131 | version: conv.version 132 | } 133 | 134 | json_or_jsonp( data.to_json ) 135 | end 136 | 137 | 138 | get '/d*' do 139 | erb :debug 140 | end 141 | 142 | 143 | ### helper for json or jsonp response (depending on callback para) 144 | 145 | private 146 | def json_or_jsonp( json ) 147 | callback = params.delete('callback') 148 | response = '' 149 | 150 | if callback 151 | content_type :js 152 | response = "#{callback}(#{json})" 153 | else 154 | content_type :json 155 | response = json 156 | end 157 | 158 | response 159 | end 160 | 161 | 162 | end # class Server 163 | end # module Markdown 164 | 165 | 166 | # say hello 167 | puts MarkdownService.banner 168 | puts " default markdown engine: #{Markdown.lib}" # force loading of settings/config 169 | puts " markdown engines: #{Markdown.libs.inspect}" 170 | 171 | -------------------------------------------------------------------------------- /markdown/README.md: -------------------------------------------------------------------------------- 1 | # Markdown Engine Wrapper - Use Your Markdown Library of Choice in Ruby 2 | 3 | * home :: [github.com/rubylibs/markdown](https://github.com/rubylibs/markdown) 4 | * bugs :: [github.com/rubylibs/markdown/issues](https://github.com/rubylibs/markdown/issues) 5 | * gem :: [rubygems.org/gems/markdown](https://rubygems.org/gems/markdown) 6 | * rdoc :: [rubydoc.info/gems/markdown](http://rubydoc.info/gems/markdown) 7 | 8 | 9 | The Markdown Engine Wrapper (`markdown`) Ruby gem lets you use 10 | your markdown library of choice. Preconfigured markdown libraries include 11 | 12 | * `kramdown` 13 | * `redcarpet` 14 | * `bluecloth` 15 | * `maruku` 16 | * `rpeg-markdown` 17 | * `rdiscount` 18 | * `pandoc-ruby` 19 | 20 | 21 | ## Usage - Ruby Code 22 | 23 | require 'markdown' 24 | 25 | Markdown.new( 'Hello World' ).to_html 26 | 27 | # => "Hello World
\n" 28 | 29 | 30 | ## Configuration - Markdown Engine Loading Order 31 | 32 | The default (fallback) Markdown library is `kramdown`. To use your markdown engine of choice 33 | configure the wrapper. The wrapper 34 | uses the following lookup order to find the markdown engine: 35 | 36 | ### 1) `MARKDOWN_LIB` Environment Variable 37 | 38 | Example: 39 | 40 | set MARKDOWN_LIB=kramdown 41 | 42 | ### 2) `lib` Property (in `./markdown.yml` or `~/markdown.yml`) 43 | 44 | Example: 45 | 46 | lib: kramdown 47 | 48 | ### 3) `libs` Property (in `./markdown.yml` or `~/markdown.yml`) 49 | 50 | Example: 51 | 52 | libs: 53 | - redcarpet 54 | - kramdown 55 | 56 | 57 | Markdown libraries in the list get loaded on a first-come first-serve principle, 58 | that is, the first library `require`'d successfully will get used. 59 | 60 | 61 | 62 | ## Configuration - Markdown Engine Options 63 | 64 | You can also pass along options to your Markdown library. Example: 65 | 66 | ## Let's use the Redcarpet library 67 | 68 | lib: redcarpet 69 | 70 | redcarpet: 71 | extensions: 72 | - no_intra_emphasis 73 | - fenced_code_blocks 74 | - tables 75 | - strikethrough 76 | 77 | 78 | ## Configuration -Filters (Command Line Only) 79 | 80 | For the command line tool only you can configure preprocessing filters to 81 | allow comments, Ruby helpers, and much more. Example: 82 | 83 | ## Let's use percent style comments 84 | 85 | filters: 86 | - comments-percent-style 87 | 88 | Now the filter will strip comment lines starting with percent (that is, %). Example: 89 | 90 | %%%%%%%%%%%%%%%% 91 | % Some Headers 92 | 93 | Title: Web Services REST-Style: Universal Identifiers, Formats & Protocols 94 | 95 | Becomes 96 | 97 | Title: Web Services REST-Style: Universal Identifiers, Formats & Protocols 98 | 99 | before the text gets passed along to the markdown engine. The filter 100 | also supports multiline comments with `%begin`|`comment`|`comments`/`%end` pairs. Example: 101 | 102 | %begin 103 | Using modern browser such as Firefox, Chrome and Safari you can 104 | now theme your slide shows using using "loss-free" vector graphics 105 | in plain old CSS. Thanks to gradient support in backgrounds in CSS3. 106 | %end 107 | 108 | or 109 | 110 | %comment 111 | Using modern browser such as Firefox, Chrome and Safari you can 112 | now theme your slide shows using using "loss-free" vector graphics 113 | in plain old CSS. Thanks to gradient support in backgrounds in CSS3. 114 | %end 115 | 116 | Note: As a shortcut using a single `%end` directive (that is, without a leading `%begin`) 117 | will skip everything until the end of the document. 118 | 119 | For more about filters see the [`textutils`](https://github.com/rubylibs/textutils) gem. 120 | 121 | 122 | ## Configuration - Converters 123 | 124 | The Markdown wrapper lets you configure different converter methods 125 | for each markdown engine. By default 126 | the converter method `Welcome to Markdown. We hope you really enjoy using this.
" + 23 | "Just type some markdown on the left and see it on the right. Simple as that.
" 24 | } 25 | 26 | 27 | var settings; // NB: defaults + opts merged => settings 28 | 29 | var defaults = { 30 | output: '#output', 31 | output_source: '#output-source', 32 | output_toggle: { 33 | id: '#output-toggle', 34 | label_show: '[ Show HTML ]', 35 | label_hide: '[ Hide HTML ]' }, 36 | output_update: '#output-update', // a/link for update action 37 | output_loading: '#output-loading', // div for loading gif anim 38 | 39 | input: '#note', // textarea for markdown source 40 | input_lib: '#note-lib', // select inputbox for markdown libs/engines 41 | 42 | input_toggle: { 43 | id: '#input-toggle', 44 | label_black: '[ Use Black Color Theme]', 45 | label_white: '[ Use White Color Theme]' 46 | }, 47 | 48 | engines: engines, 49 | 50 | welcome: welcome 51 | } 52 | 53 | 54 | function _debug( msg ) 55 | { 56 | if(window.console && window.console.log ) 57 | window.console.log( "[debug] " + msg ); 58 | } 59 | 60 | var $output, 61 | $output_source, 62 | $output_toggle, 63 | $output_update, 64 | $output_loading, 65 | $input, 66 | $input_lib, 67 | $input_toggle; 68 | 69 | 70 | var show_html = false; 71 | var use_white_color_theme = false; 72 | 73 | function toggle_output() 74 | { 75 | show_html = !show_html; 76 | 77 | if( show_html ) { 78 | $output_toggle.html( settings.output_toggle.label_hide ); 79 | $output.hide(); 80 | $output_source.show(); 81 | } 82 | else { 83 | $output_toggle.html( settings.output_toggle.label_show ); 84 | $output.show(); 85 | $output_source.hide(); 86 | } 87 | } 88 | 89 | 90 | function _toggle_color_theme() 91 | { 92 | /** 93 | * todo: move to addon?? out of "core" 94 | */ 95 | 96 | use_white_color_theme = !use_white_color_theme; 97 | if( use_white_color_theme ) { 98 | $input.removeClass( 'black' ); 99 | $input_toggle.html( settings.input_toggle.label_black ); 100 | } 101 | else { 102 | $input.addClass( 'black' ); 103 | $input_toggle.html( settings.input_toggle.label_white ); 104 | } 105 | } 106 | 107 | 108 | function update_output() 109 | { 110 | var text = $input.val(); // get markdown text 111 | var engine_index = parseInt( $input_lib.val(), 10); 112 | 113 | var engine = settings.engines[engine_index]; 114 | 115 | if( engine.online === true ) 116 | $output_loading.show(); 117 | 118 | engine.markdown( text, function( html ) { 119 | $output.html( html ); 120 | $output_source.html( html ); 121 | $output_loading.hide(); 122 | }); 123 | } 124 | 125 | 126 | function _init( opts ) 127 | { 128 | settings = $.extend( {}, defaults, opts ); 129 | 130 | 131 | $output = $( settings.output ); 132 | $output_source = $( settings.output_source ); 133 | $output_update = $( settings.output_update ); 134 | $output_toggle = $( settings.output_toggle.id ); 135 | $output_loading = $( settings.output_loading ); 136 | 137 | $input = $( settings.input ); 138 | $input_lib = $( settings.input_lib ); 139 | 140 | $input_toggle = $( settings.input_toggle.id ); 141 | 142 | $input.val( settings.welcome.markdown ); 143 | 144 | $output.html( settings.welcome.html ); 145 | $output_source.html( settings.welcome.html ); 146 | 147 | 148 | $output_update.click( function() { update_output(); } ); 149 | $output_toggle.click( function() { toggle_output(); } ); 150 | 151 | $input_toggle.click( function() { _toggle_color_theme(); } ); 152 | 153 | // add markdown engine/lib options 154 | var markdown_opts = ''; 155 | $.each( engines, function(index, engine) { 156 | markdown_opts += ''; 161 | 162 | _debug( 'add markdown engine [' + index + ']: ' + engine.name ); 163 | }); 164 | $input_lib.html( markdown_opts ); 165 | } 166 | 167 | _init( opts ); 168 | 169 | return { 170 | update: update_output, 171 | toggle: toggle_output 172 | } 173 | } // fn markdown_note_new 174 | -------------------------------------------------------------------------------- /markdown-service/lib/markdown/service/public/js/markdown.note.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | var markdown_note_new = function( opts ) { 4 | 5 | // use module pattern (see JavaScript - The Good Parts) 6 | 7 | var engines = [ 8 | { name: 'Standard (Offline)', online: false, markdown: markdown_libs.showdown }, 9 | { name: 'Standard (Online)', online: true, markdown: markdown_apis.ruby }, 10 | { name: 'JavaScript - Showdown (Offline)', online: false, markdown: markdown_libs.showdown }, 11 | { name: 'JavaScript - pagedown (Offline)', online: false, markdown: markdown_libs.pagedown }, 12 | { name: 'Ruby - kramdown (Online)', online: true, markdown: markdown_apis.ruby_kramdown }, 13 | { name: 'Ruby - Redcarpet (Online)', online: true, markdown: markdown_apis.ruby_redcarpet }, 14 | { name: 'Ruby - Maruku (Online)', online: true, markdown: markdown_apis.ruby_maruku }, 15 | { name: 'Ruby - BlueCloth (Online)', online: true, markdown: markdown_apis.ruby_bluecloth } 16 | ]; 17 | 18 | var welcome = { 19 | markdown: "Welcome to Markdown. We hope you **really** enjoy using this."+ 20 | "\n\n"+ 21 | "Just type some [markdown](http://daringfireball.net/projects/markdown) on the left and see it on the right. *Simple as that.*", 22 | html: "Welcome to Markdown. We hope you really enjoy using this.
" + 23 | "Just type some markdown on the left and see it on the right. Simple as that.
" 24 | } 25 | 26 | 27 | var settings; // NB: defaults + opts merged => settings 28 | 29 | var defaults = { 30 | output: '#output', 31 | output_source: '#output-source', 32 | output_toggle: { 33 | id: '#output-toggle', 34 | label_show: '[ Show HTML ]', 35 | label_hide: '[ Hide HTML ]' }, 36 | output_update: '#output-update', // a/link for update action 37 | output_loading: '#output-loading', // div for loading gif anim 38 | 39 | input: '#note', // textarea for markdown source 40 | input_lib: '#note-lib', // select inputbox for markdown libs/engines 41 | 42 | input_toggle: { 43 | id: '#input-toggle', 44 | label_black: '[ Use Black Color Theme]', 45 | label_white: '[ Use White Color Theme]' 46 | }, 47 | 48 | engines: engines, 49 | 50 | welcome: welcome 51 | } 52 | 53 | 54 | function _debug( msg ) 55 | { 56 | if(window.console && window.console.log ) 57 | window.console.log( "[debug] " + msg ); 58 | } 59 | 60 | var $output, 61 | $output_source, 62 | $output_toggle, 63 | $output_update, 64 | $output_loading, 65 | $input, 66 | $input_lib, 67 | $input_toggle; 68 | 69 | 70 | var show_html = false; 71 | var use_white_color_theme = false; 72 | 73 | function toggle_output() 74 | { 75 | show_html = !show_html; 76 | 77 | if( show_html ) { 78 | $output_toggle.html( settings.output_toggle.label_hide ); 79 | $output.hide(); 80 | $output_source.show(); 81 | } 82 | else { 83 | $output_toggle.html( settings.output_toggle.label_show ); 84 | $output.show(); 85 | $output_source.hide(); 86 | } 87 | } 88 | 89 | 90 | function _toggle_color_theme() 91 | { 92 | /** 93 | * todo: move to addon?? out of "core" 94 | */ 95 | 96 | use_white_color_theme = !use_white_color_theme; 97 | if( use_white_color_theme ) { 98 | $input.removeClass( 'black' ); 99 | $input_toggle.html( settings.input_toggle.label_black ); 100 | } 101 | else { 102 | $input.addClass( 'black' ); 103 | $input_toggle.html( settings.input_toggle.label_white ); 104 | } 105 | } 106 | 107 | 108 | function update_output() 109 | { 110 | var text = $input.val(); // get markdown text 111 | var engine_index = parseInt( $input_lib.val(), 10); 112 | 113 | var engine = settings.engines[engine_index]; 114 | 115 | if( engine.online === true ) 116 | $output_loading.show(); 117 | 118 | engine.markdown( text, function( html ) { 119 | $output.html( html ); 120 | $output_source.html( html ); 121 | $output_loading.hide(); 122 | }); 123 | } 124 | 125 | 126 | function _init( opts ) 127 | { 128 | settings = $.extend( {}, defaults, opts ); 129 | 130 | 131 | $output = $( settings.output ); 132 | $output_source = $( settings.output_source ); 133 | $output_update = $( settings.output_update ); 134 | $output_toggle = $( settings.output_toggle.id ); 135 | $output_loading = $( settings.output_loading ); 136 | 137 | $input = $( settings.input ); 138 | $input_lib = $( settings.input_lib ); 139 | 140 | $input_toggle = $( settings.input_toggle.id ); 141 | 142 | $input.val( settings.welcome.markdown ); 143 | 144 | $output.html( settings.welcome.html ); 145 | $output_source.html( settings.welcome.html ); 146 | 147 | 148 | $output_update.click( function() { update_output(); } ); 149 | $output_toggle.click( function() { toggle_output(); } ); 150 | 151 | $input_toggle.click( function() { _toggle_color_theme(); } ); 152 | 153 | // add markdown engine/lib options 154 | var markdown_opts = ''; 155 | $.each( engines, function(index, engine) { 156 | markdown_opts += ''; 161 | 162 | _debug( 'add markdown engine [' + index + ']: ' + engine.name ); 163 | }); 164 | $input_lib.html( markdown_opts ); 165 | } 166 | 167 | _init( opts ); 168 | 169 | return { 170 | update: update_output, 171 | toggle: toggle_output 172 | } 173 | } // fn markdown_note_new 174 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | CC0 1.0 Universal 2 | 3 | Statement of Purpose 4 | 5 | The laws of most jurisdictions throughout the world automatically confer 6 | exclusive Copyright and Related Rights (defined below) upon the creator and 7 | subsequent owner(s) (each and all, an "owner") of an original work of 8 | authorship and/or a database (each, a "Work"). 9 | 10 | Certain owners wish to permanently relinquish those rights to a Work for the 11 | purpose of contributing to a commons of creative, cultural and scientific 12 | works ("Commons") that the public can reliably and without fear of later 13 | claims of infringement build upon, modify, incorporate in other works, reuse 14 | and redistribute as freely as possible in any form whatsoever and for any 15 | purposes, including without limitation commercial purposes. These owners may 16 | contribute to the Commons to promote the ideal of a free culture and the 17 | further production of creative, cultural and scientific works, or to gain 18 | reputation or greater distribution for their Work in part through the use and 19 | efforts of others. 20 | 21 | For these and/or other purposes and motivations, and without any expectation 22 | of additional consideration or compensation, the person associating CC0 with a 23 | Work (the "Affirmer"), to the extent that he or she is an owner of Copyright 24 | and Related Rights in the Work, voluntarily elects to apply CC0 to the Work 25 | and publicly distribute the Work under its terms, with knowledge of his or her 26 | Copyright and Related Rights in the Work and the meaning and intended legal 27 | effect of CC0 on those rights. 28 | 29 | 1. Copyright and Related Rights. A Work made available under CC0 may be 30 | protected by copyright and related or neighboring rights ("Copyright and 31 | Related Rights"). Copyright and Related Rights include, but are not limited 32 | to, the following: 33 | 34 | i. the right to reproduce, adapt, distribute, perform, display, communicate, 35 | and translate a Work; 36 | 37 | ii. moral rights retained by the original author(s) and/or performer(s); 38 | 39 | iii. publicity and privacy rights pertaining to a person's image or likeness 40 | depicted in a Work; 41 | 42 | iv. rights protecting against unfair competition in regards to a Work, 43 | subject to the limitations in paragraph 4(a), below; 44 | 45 | v. rights protecting the extraction, dissemination, use and reuse of data in 46 | a Work; 47 | 48 | vi. database rights (such as those arising under Directive 96/9/EC of the 49 | European Parliament and of the Council of 11 March 1996 on the legal 50 | protection of databases, and under any national implementation thereof, 51 | including any amended or successor version of such directive); and 52 | 53 | vii. other similar, equivalent or corresponding rights throughout the world 54 | based on applicable law or treaty, and any national implementations thereof. 55 | 56 | 2. Waiver. To the greatest extent permitted by, but not in contravention of, 57 | applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and 58 | unconditionally waives, abandons, and surrenders all of Affirmer's Copyright 59 | and Related Rights and associated claims and causes of action, whether now 60 | known or unknown (including existing as well as future claims and causes of 61 | action), in the Work (i) in all territories worldwide, (ii) for the maximum 62 | duration provided by applicable law or treaty (including future time 63 | extensions), (iii) in any current or future medium and for any number of 64 | copies, and (iv) for any purpose whatsoever, including without limitation 65 | commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes 66 | the Waiver for the benefit of each member of the public at large and to the 67 | detriment of Affirmer's heirs and successors, fully intending that such Waiver 68 | shall not be subject to revocation, rescission, cancellation, termination, or 69 | any other legal or equitable action to disrupt the quiet enjoyment of the Work 70 | by the public as contemplated by Affirmer's express Statement of Purpose. 71 | 72 | 3. Public License Fallback. Should any part of the Waiver for any reason be 73 | judged legally invalid or ineffective under applicable law, then the Waiver 74 | shall be preserved to the maximum extent permitted taking into account 75 | Affirmer's express Statement of Purpose. In addition, to the extent the Waiver 76 | is so judged Affirmer hereby grants to each affected person a royalty-free, 77 | non transferable, non sublicensable, non exclusive, irrevocable and 78 | unconditional license to exercise Affirmer's Copyright and Related Rights in 79 | the Work (i) in all territories worldwide, (ii) for the maximum duration 80 | provided by applicable law or treaty (including future time extensions), (iii) 81 | in any current or future medium and for any number of copies, and (iv) for any 82 | purpose whatsoever, including without limitation commercial, advertising or 83 | promotional purposes (the "License"). The License shall be deemed effective as 84 | of the date CC0 was applied by Affirmer to the Work. Should any part of the 85 | License for any reason be judged legally invalid or ineffective under 86 | applicable law, such partial invalidity or ineffectiveness shall not 87 | invalidate the remainder of the License, and in such case Affirmer hereby 88 | affirms that he or she will not (i) exercise any of his or her remaining 89 | Copyright and Related Rights in the Work or (ii) assert any associated claims 90 | and causes of action with respect to the Work, in either case contrary to 91 | Affirmer's express Statement of Purpose. 92 | 93 | 4. Limitations and Disclaimers. 94 | 95 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 96 | surrendered, licensed or otherwise affected by this document. 97 | 98 | b. Affirmer offers the Work as-is and makes no representations or warranties 99 | of any kind concerning the Work, express, implied, statutory or otherwise, 100 | including without limitation warranties of title, merchantability, fitness 101 | for a particular purpose, non infringement, or the absence of latent or 102 | other defects, accuracy, or the present or absence of errors, whether or not 103 | discoverable, all to the greatest extent permissible under applicable law. 104 | 105 | c. Affirmer disclaims responsibility for clearing rights of other persons 106 | that may apply to the Work or any use thereof, including without limitation 107 | any person's Copyright and Related Rights in the Work. Further, Affirmer 108 | disclaims responsibility for obtaining any necessary consents, permissions 109 | or other rights required for any use of the Work. 110 | 111 | d. Affirmer understands and acknowledges that Creative Commons is not a 112 | party to this document and has no duty or obligation with respect to this 113 | CC0 or use of the Work. 114 | 115 | For more information, please see 116 |Welcome to Markdown. We hope you really enjoy using this.
" + 36 | "Just type some markdown on the left and see it on the right. Simple as that.
" 37 | } 38 | 39 | 40 | var settings; // NB: defaults + opts merged => settings 41 | 42 | var defaults = { 43 | output: '#output', 44 | output_source: '#output-source', 45 | output_toggle: { 46 | id: '#output-toggle', 47 | label_show: '[ Show HTML ]', 48 | label_hide: '[ Hide HTML ]' }, 49 | output_update: '#output-update', // a/link for update action 50 | output_loading: '#output-loading', // div for loading gif anim 51 | 52 | input: '#note', // textarea for markdown source 53 | input_lib: '#note-lib', // select inputbox for markdown libs/engines 54 | 55 | input_toggle: { 56 | id: '#input-toggle', 57 | label_black: '[ Use Black Color Theme]', 58 | label_white: '[ Use White Color Theme]' 59 | }, 60 | 61 | engines: engines, 62 | 63 | welcome: welcome 64 | } 65 | 66 | 67 | function _debug( msg ) 68 | { 69 | if(window.console && window.console.log ) 70 | window.console.log( "[debug] " + msg ); 71 | } 72 | 73 | var $output, 74 | $output_source, 75 | $output_toggle, 76 | $output_update, 77 | $output_loading, 78 | $input, 79 | $input_lib, 80 | $input_toggle; 81 | 82 | 83 | var show_html = false; 84 | var use_white_color_theme = false; 85 | var show_latex = false; 86 | 87 | function show_latex_output() { 88 | show_latex = true; 89 | 90 | $output.hide(); 91 | $output_toggle.hide(); // hide toggle show html button 92 | $output_source.show(); 93 | } 94 | 95 | function restore_html_output() { 96 | // restore output view to before entering "latex" mode 97 | if (show_latex == true) { 98 | show_latex = false; 99 | 100 | $output_toggle.show(); 101 | if( !show_html ) { // switch back in "preview" mode ? 102 | $output_source.hide(); 103 | $output.show(); 104 | } 105 | } 106 | } 107 | 108 | function toggle_output() 109 | { 110 | show_html = !show_html; 111 | 112 | if( show_html ) { 113 | $output_toggle.html( settings.output_toggle.label_hide ); 114 | $output.hide(); 115 | $output_source.show(); 116 | } 117 | else { 118 | $output_toggle.html( settings.output_toggle.label_show ); 119 | $output.show(); 120 | $output_source.hide(); 121 | } 122 | } 123 | 124 | 125 | function _toggle_color_theme() 126 | { 127 | /** 128 | * todo: move to addon?? out of "core" 129 | */ 130 | 131 | use_white_color_theme = !use_white_color_theme; 132 | if( use_white_color_theme ) { 133 | $input.removeClass( 'black' ); 134 | $input_toggle.html( settings.input_toggle.label_black ); 135 | } 136 | else { 137 | $input.addClass( 'black' ); 138 | $input_toggle.html( settings.input_toggle.label_white ); 139 | } 140 | } 141 | 142 | 143 | function update_output() 144 | { 145 | var text = $input.val(); // get markdown text 146 | var engine_index = parseInt( $input_lib.val(), 10); 147 | 148 | var engine = settings.engines[engine_index]; 149 | 150 | $output_loading.show(); // show progress bar/spinner 151 | 152 | engine.markdown( text, function( html ) { 153 | $output.html( html ); 154 | $output_source.html( html ); 155 | $output_loading.hide(); 156 | 157 | if( engine.format == 'LaTeX' ) // for latex always show source (only) 158 | show_latex_output(); 159 | else 160 | restore_html_output(); 161 | }); 162 | } 163 | 164 | 165 | function _init( opts ) 166 | { 167 | settings = $.extend( {}, defaults, opts ); 168 | 169 | $output = $( settings.output ); 170 | $output_source = $( settings.output_source ); 171 | $output_update = $( settings.output_update ); 172 | $output_toggle = $( settings.output_toggle.id ); 173 | $output_loading = $( settings.output_loading ); 174 | 175 | $input = $( settings.input ); 176 | $input_lib = $( settings.input_lib ); 177 | 178 | $input_toggle = $( settings.input_toggle.id ); 179 | 180 | $input.val( settings.welcome.markdown ); 181 | 182 | $output.html( settings.welcome.html ); 183 | $output_source.html( settings.welcome.html ); 184 | 185 | 186 | $output_update.click( function() { update_output(); } ); 187 | $output_toggle.click( function() { toggle_output(); } ); 188 | 189 | $input_toggle.click( function() { _toggle_color_theme(); } ); 190 | 191 | // add markdown engine/lib options 192 | var markdown_opts = ''; 193 | $.each( engines, function(index, engine) { 194 | markdown_opts += ''; 199 | 200 | _debug( 'add markdown engine [' + index + ']: ' + engine.name ); 201 | }); 202 | $input_lib.html( markdown_opts ); 203 | } 204 | 205 | _init( opts ); 206 | 207 | return { 208 | update: update_output, 209 | toggle: toggle_output 210 | } 211 | } // fn markdown_note_new 212 | -------------------------------------------------------------------------------- /markdown.note.starter/js/showdown.min.js: -------------------------------------------------------------------------------- 1 | // 2 | // showdown.js -- A javascript port of Markdown. 3 | // 4 | // Copyright (c) 2007 John Fraser. 5 | // 6 | // Original Markdown Copyright (c) 2004-2005 John Gruber 7 | //"+d+"\n",A(d)+e}),a=a.replace(/~0/,""),a},z=function(a){return a+="~0",a=a.replace(/(?:^|\n)```(.*)\n([\s\S]*?)\n```/g,function(a,b,c){var d=b,e=c;return e=C(e),e=M(e),e=e.replace(/^\n+/g,""),e=e.replace(/\n+$/g,""),e=""+e+"\n",A(e)}),a=a.replace(/~0/,""),a},A=function(a){return a=a.replace(/(^\n+|\n+$)/g,""),"\n\n~K"+(d.push(a)-1)+"K\n\n"},B=function(a){return a=a.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,function(a,b,c,d,e){var f=d;return f=f.replace(/^([ \t]*)/g,""),f=f.replace(/[ \t]*$/g,""),f=C(f),b+""+f+""}),a},C=function(a){return a=a.replace(/&/g,"&"),a=a.replace(//g,">"),a=N(a,"*_{}[]\\",!1),a},D=function(a){return a=a.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,"$2"),a=a.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,"$2"),a},E=function(a){return a=a.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,function(a,b){var c=b;return c=c.replace(/^[ \t]*>[ \t]?/gm,"~0"),c=c.replace(/~0/g,""),c=c.replace(/^[ \t]+$/gm,""),c=o(c),c=c.replace(/(^|\n)/g,"$1 "),c=c.replace(/(\s*[^\r]+?<\/pre>)/gm,function(a,b){var c=b;return c=c.replace(/^ /mg,"~0"),c=c.replace(/~0/g,""),c}),A("\n"+c+"\n
")}),a},F=function(a){a=a.replace(/^\n+/g,""),a=a.replace(/\n+$/g,"");var b=a.split(/\n{2,}/g),c=[],e=b.length;for(var f=0;f=0?c.push(g):g.search(/\S/)>=0&&(g=p(g),g=g.replace(/^([ \t]*)/g,""),g+="
",c.push(g))}e=c.length;for(var f=0;f=0){var h=d[RegExp.$1];h=h.replace(/\$/g,"$$$$"),c[f]=c[f].replace(/~K\d+K/,h)}return c.join("\n\n")},G=function(a){return a=a.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&"),a=a.replace(/<(?![a-z\/?\$!])/gi,"<"),a},H=function(a){return a=a.replace(/\\(\\)/g,O),a=a.replace(/\\([`*_{}\[\]()>#+-.!])/g,O),a},I=function(a){return a=a.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,'$1'),a=a.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,function(a,b){return J(K(b))}),a},J=function(a){var b=[function(a){return""+a.charCodeAt(0)+";"},function(a){return""+a.charCodeAt(0).toString(16)+";"},function(a){return a}];return a="mailto:"+a,a=a.replace(/./g,function(a){if(a=="@")a=b[Math.floor(Math.random()*2)](a);else if(a!=":"){var c=Math.random();a=c>.9?b[2](a):c>.45?b[1](a):b[0](a)}return a}),a=''+a+"",a=a.replace(/">.+:/g,'">'),a},K=function(a){return a=a.replace(/~E(\d+)E/g,function(a,b){var c=parseInt(b);return String.fromCharCode(c)}),a},L=function(a){return a=a.replace(/^(\t|[ ]{1,4})/gm,"~0"),a=a.replace(/~0/g,""),a},M=function(a){return a=a.replace(/\t(?=\t)/g," "),a=a.replace(/\t/g,"~A~B"),a=a.replace(/~B(.+?)~A/g,function(a,b,c){var d=b,e=4-d.length%4;for(var f=0;f
8 | //
9 | // Redistributable under a BSD-style open source license.
10 | // See license.txt for more information.
11 | //
12 | // The full source distribution is at:
13 | //
14 | // A A L
15 | // T C A
16 | // T K B
17 | //
18 | //
19 | //
20 | //
21 | // Wherever possible, Showdown is a straight, line-by-line port
22 | // of the Perl version of Markdown.
23 | //
24 | // This is not a normal parser design; it's basically just a
25 | // series of string substitutions. It's hard to read and
26 | // maintain this way, but keeping Showdown close to the original
27 | // design makes it easier to port new features.
28 | //
29 | // More importantly, Showdown behaves like markdown.pl in most
30 | // edge cases. So web applications can do client-side preview
31 | // in Javascript, and then build identical HTML on the server.
32 | //
33 | // This port needs the new RegExp functionality of ECMA 262,
34 | // 3rd Edition (i.e. Javascript 1.5). Most modern web browsers
35 | // should do fine. Even with the new regular expression features,
36 | // We do a lot of work to emulate Perl's regex functionality.
37 | // The tricky changes in this file mostly have the "attacklab:"
38 | // label. Major or self-explanatory changes don't.
39 | //
40 | // Smart diff tools like Araxis Merge will be able to match up
41 | // this file with markdown.pl in a useful way. A little tweaking
42 | // helps: in a copy of markdown.pl, replace "#" with "//" and
43 | // replace "$text" with "text". Be sure to ignore whitespace
44 | // and line endings.
45 | //
46 | //
47 | // Showdown usage:
48 | //
49 | // var text = "Markdown *rocks*.";
50 | //
51 | // var converter = new Showdown.converter();
52 | // var html = converter.makeHtml(text);
53 | //
54 | // alert(html);
55 | //
56 | // Note: move the sample code to the bottom of this
57 | // file before uncommenting it.
58 | //
59 | //
60 | // Showdown namespace
61 | //
62 | var Showdown={extensions:{}},forEach=Showdown.forEach=function(a,b){if(typeof a.forEach=="function")a.forEach(b);else{var c,d=a.length;for(c=0;c?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|(?=~0))/gm,function(a,d,e,f,g){return d=d.toLowerCase(),b[d]=G(e),f?f+g:(g&&(c[d]=g.replace(/"/g,""")),"")}),a=a.replace(/~0/,""),a},m=function(a){a=a.replace(/\n/g,"\n\n");var b="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del|style|section|header|footer|nav|article|aside",c="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|style|section|header|footer|nav|article|aside";return a=a.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,n),a=a.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|style|section|header|footer|nav|article|aside)\b[^\r]*?<\/\2>[ \t]*(?=\n+)\n)/gm,n),a=a.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,n),a=a.replace(/(\n\n[ ]{0,3}[ \t]*(?=\n{2,}))/g,n),a=a.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,n),a=a.replace(/\n\n/g,"\n"),a},n=function(a,b){var c=b;return c=c.replace(/\n\n/g,"\n"),c=c.replace(/^\n/,""),c=c.replace(/\n+$/g,""),c="\n\n~K"+(d.push(c)-1)+"K\n\n",c},o=function(a){a=v(a);var b=A("
");return a=a.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,b),a=a.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,b),a=a.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,b),a=x(a),a=y(a),a=E(a),a=m(a),a=F(a),a},p=function(a){return a=B(a),a=q(a),a=H(a),a=t(a),a=r(a),a=I(a),a=G(a),a=D(a),a=a.replace(/ +\n/g,"
\n"),a},q=function(a){var b=/(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|)/gi;return a=a.replace(b,function(a){var b=a.replace(/(.)<\/?code>(?=.)/g,"$1`");return b=N(b,"\\`*_"),b}),a},r=function(a){return a=a.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,s),a=a.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()(.*?(?:\(.*?\).*?)?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,s),a=a.replace(/(\[([^\[\]]+)\])()()()()()/g,s),a},s=function(a,d,e,f,g,h,i,j){j==undefined&&(j="");var k=d,l=e,m=f.toLowerCase(),n=g,o=j;if(n==""){m==""&&(m=l.toLowerCase().replace(/ ?\n/g," ")),n="#"+m;if(b[m]!=undefined)n=b[m],c[m]!=undefined&&(o=c[m]);else{if(!(k.search(/\(\s*\)$/m)>-1))return k;n=""}}n=N(n,"*_");var p='"+l+"",p},t=function(a){return a=a.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,u),a=a.replace(/(!\[(.*?)\]\s?\([ \t]*()(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,u),a},u=function(a,d,e,f,g,h,i,j){var k=d,l=e,m=f.toLowerCase(),n=g,o=j;o||(o="");if(n==""){m==""&&(m=l.toLowerCase().replace(/ ?\n/g," ")),n="#"+m;if(b[m]==undefined)return k;n=b[m],c[m]!=undefined&&(o=c[m])}l=l.replace(/"/g,"""),n=N(n,"*_");var p='
",p},v=function(a){function b(a){return a.replace(/[^\w]/g,"").toLowerCase()}return a=a.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,function(a,c){return A(''+p(c)+"
")}),a=a.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,function(a,c){return A(''+p(c)+"
")}),a=a.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,function(a,c,d){var e=c.length;return A("'+p(d)+" ")}),a},w,x=function(a){a+="~0";var b=/^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;return e?a=a.replace(b,function(a,b,c){var d=b,e=c.search(/[*+-]/g)>-1?"ul":"ol";d=d.replace(/\n{2,}/g,"\n\n\n");var f=w(d);return f=f.replace(/\s+$/,""),f="<"+e+">"+f+""+e+">\n",f}):(b=/(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g,a=a.replace(b,function(a,b,c,d){var e=b,f=c,g=d.search(/[*+-]/g)>-1?"ul":"ol",f=f.replace(/\n{2,}/g,"\n\n\n"),h=w(f);return h=e+"<"+g+">\n"+h+""+g+">\n",h})),a=a.replace(/~0/,""),a};w=function(a){return e++,a=a.replace(/\n{2,}$/,"\n"),a+="~0",a=a.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,function(a,b,c,d,e){var f=e,g=b,h=c;return g||f.search(/\n{2,}/)>-1?f=o(L(f)):(f=x(L(f)),f=f.replace(/\n$/,""),f=p(f)),""+f+" \n"}),a=a.replace(/~0/g,""),e--,a};var y=function(a){return a+="~0",a=a.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,function(a,b,c){var d=b,e=c;return d=C(L(d)),d=M(d),d=d.replace(/^\n+/g,""),d=d.replace(/\n+$/g,""),d=""+d+"\n
",A(d)+e}),a=a.replace(/~0/,""),a},z=function(a){return a+="~0",a=a.replace(/(?:^|\n)```(.*)\n([\s\S]*?)\n```/g,function(a,b,c){var d=b,e=c;return e=C(e),e=M(e),e=e.replace(/^\n+/g,""),e=e.replace(/\n+$/g,""),e=""+e+"\n
",A(e)}),a=a.replace(/~0/,""),a},A=function(a){return a=a.replace(/(^\n+|\n+$)/g,""),"\n\n~K"+(d.push(a)-1)+"K\n\n"},B=function(a){return a=a.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,function(a,b,c,d,e){var f=d;return f=f.replace(/^([ \t]*)/g,""),f=f.replace(/[ \t]*$/g,""),f=C(f),b+""+f+""}),a},C=function(a){return a=a.replace(/&/g,"&"),a=a.replace(//g,">"),a=N(a,"*_{}[]\\",!1),a},D=function(a){return a=a.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,"$2"),a=a.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,"$2"),a},E=function(a){return a=a.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,function(a,b){var c=b;return c=c.replace(/^[ \t]*>[ \t]?/gm,"~0"),c=c.replace(/~0/g,""),c=c.replace(/^[ \t]+$/gm,""),c=o(c),c=c.replace(/(^|\n)/g,"$1 "),c=c.replace(/(\s*[^\r]+?<\/pre>)/gm,function(a,b){var c=b;return c=c.replace(/^ /mg,"~0"),c=c.replace(/~0/g,""),c}),A("\n"+c+"\n
")}),a},F=function(a){a=a.replace(/^\n+/g,""),a=a.replace(/\n+$/g,"");var b=a.split(/\n{2,}/g),c=[],e=b.length;for(var f=0;f=0?c.push(g):g.search(/\S/)>=0&&(g=p(g),g=g.replace(/^([ \t]*)/g,""),g+="
",c.push(g))}e=c.length;for(var f=0;f=0){var h=d[RegExp.$1];h=h.replace(/\$/g,"$$$$"),c[f]=c[f].replace(/~K\d+K/,h)}return c.join("\n\n")},G=function(a){return a=a.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&"),a=a.replace(/<(?![a-z\/?\$!])/gi,"<"),a},H=function(a){return a=a.replace(/\\(\\)/g,O),a=a.replace(/\\([`*_{}\[\]()>#+-.!])/g,O),a},I=function(a){return a=a.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,'$1'),a=a.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,function(a,b){return J(K(b))}),a},J=function(a){var b=[function(a){return""+a.charCodeAt(0)+";"},function(a){return""+a.charCodeAt(0).toString(16)+";"},function(a){return a}];return a="mailto:"+a,a=a.replace(/./g,function(a){if(a=="@")a=b[Math.floor(Math.random()*2)](a);else if(a!=":"){var c=Math.random();a=c>.9?b[2](a):c>.45?b[1](a):b[0](a)}return a}),a=''+a+"",a=a.replace(/">.+:/g,'">'),a},K=function(a){return a=a.replace(/~E(\d+)E/g,function(a,b){var c=parseInt(b);return String.fromCharCode(c)}),a},L=function(a){return a=a.replace(/^(\t|[ ]{1,4})/gm,"~0"),a=a.replace(/~0/g,""),a},M=function(a){return a=a.replace(/\t(?=\t)/g," "),a=a.replace(/\t/g,"~A~B"),a=a.replace(/~B(.+?)~A/g,function(a,b,c){var d=b,e=4-d.length%4;for(var f=0;f
8 | //
9 | // Redistributable under a BSD-style open source license.
10 | // See license.txt for more information.
11 | //
12 | // The full source distribution is at:
13 | //
14 | // A A L
15 | // T C A
16 | // T K B
17 | //
18 | //
19 | //
20 | //
21 | // Wherever possible, Showdown is a straight, line-by-line port
22 | // of the Perl version of Markdown.
23 | //
24 | // This is not a normal parser design; it's basically just a
25 | // series of string substitutions. It's hard to read and
26 | // maintain this way, but keeping Showdown close to the original
27 | // design makes it easier to port new features.
28 | //
29 | // More importantly, Showdown behaves like markdown.pl in most
30 | // edge cases. So web applications can do client-side preview
31 | // in Javascript, and then build identical HTML on the server.
32 | //
33 | // This port needs the new RegExp functionality of ECMA 262,
34 | // 3rd Edition (i.e. Javascript 1.5). Most modern web browsers
35 | // should do fine. Even with the new regular expression features,
36 | // We do a lot of work to emulate Perl's regex functionality.
37 | // The tricky changes in this file mostly have the "attacklab:"
38 | // label. Major or self-explanatory changes don't.
39 | //
40 | // Smart diff tools like Araxis Merge will be able to match up
41 | // this file with markdown.pl in a useful way. A little tweaking
42 | // helps: in a copy of markdown.pl, replace "#" with "//" and
43 | // replace "$text" with "text". Be sure to ignore whitespace
44 | // and line endings.
45 | //
46 | //
47 | // Showdown usage:
48 | //
49 | // var text = "Markdown *rocks*.";
50 | //
51 | // var converter = new Showdown.converter();
52 | // var html = converter.makeHtml(text);
53 | //
54 | // alert(html);
55 | //
56 | // Note: move the sample code to the bottom of this
57 | // file before uncommenting it.
58 | //
59 | //
60 | // Showdown namespace
61 | //
62 | var Showdown={extensions:{}},forEach=Showdown.forEach=function(a,b){if(typeof a.forEach=="function")a.forEach(b);else{var c,d=a.length;for(c=0;c?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|(?=~0))/gm,function(a,d,e,f,g){return d=d.toLowerCase(),b[d]=G(e),f?f+g:(g&&(c[d]=g.replace(/"/g,""")),"")}),a=a.replace(/~0/,""),a},m=function(a){a=a.replace(/\n/g,"\n\n");var b="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del|style|section|header|footer|nav|article|aside",c="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|style|section|header|footer|nav|article|aside";return a=a.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,n),a=a.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|style|section|header|footer|nav|article|aside)\b[^\r]*?<\/\2>[ \t]*(?=\n+)\n)/gm,n),a=a.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,n),a=a.replace(/(\n\n[ ]{0,3}[ \t]*(?=\n{2,}))/g,n),a=a.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,n),a=a.replace(/\n\n/g,"\n"),a},n=function(a,b){var c=b;return c=c.replace(/\n\n/g,"\n"),c=c.replace(/^\n/,""),c=c.replace(/\n+$/g,""),c="\n\n~K"+(d.push(c)-1)+"K\n\n",c},o=function(a){a=v(a);var b=A("
");return a=a.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,b),a=a.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,b),a=a.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,b),a=x(a),a=y(a),a=E(a),a=m(a),a=F(a),a},p=function(a){return a=B(a),a=q(a),a=H(a),a=t(a),a=r(a),a=I(a),a=G(a),a=D(a),a=a.replace(/ +\n/g,"
\n"),a},q=function(a){var b=/(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|)/gi;return a=a.replace(b,function(a){var b=a.replace(/(.)<\/?code>(?=.)/g,"$1`");return b=N(b,"\\`*_"),b}),a},r=function(a){return a=a.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,s),a=a.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()(.*?(?:\(.*?\).*?)?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,s),a=a.replace(/(\[([^\[\]]+)\])()()()()()/g,s),a},s=function(a,d,e,f,g,h,i,j){j==undefined&&(j="");var k=d,l=e,m=f.toLowerCase(),n=g,o=j;if(n==""){m==""&&(m=l.toLowerCase().replace(/ ?\n/g," ")),n="#"+m;if(b[m]!=undefined)n=b[m],c[m]!=undefined&&(o=c[m]);else{if(!(k.search(/\(\s*\)$/m)>-1))return k;n=""}}n=N(n,"*_");var p='"+l+"",p},t=function(a){return a=a.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,u),a=a.replace(/(!\[(.*?)\]\s?\([ \t]*()(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,u),a},u=function(a,d,e,f,g,h,i,j){var k=d,l=e,m=f.toLowerCase(),n=g,o=j;o||(o="");if(n==""){m==""&&(m=l.toLowerCase().replace(/ ?\n/g," ")),n="#"+m;if(b[m]==undefined)return k;n=b[m],c[m]!=undefined&&(o=c[m])}l=l.replace(/"/g,"""),n=N(n,"*_");var p='
",p},v=function(a){function b(a){return a.replace(/[^\w]/g,"").toLowerCase()}return a=a.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,function(a,c){return A(''+p(c)+"
")}),a=a.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,function(a,c){return A(''+p(c)+"
")}),a=a.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,function(a,c,d){var e=c.length;return A("'+p(d)+" ")}),a},w,x=function(a){a+="~0";var b=/^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;return e?a=a.replace(b,function(a,b,c){var d=b,e=c.search(/[*+-]/g)>-1?"ul":"ol";d=d.replace(/\n{2,}/g,"\n\n\n");var f=w(d);return f=f.replace(/\s+$/,""),f="<"+e+">"+f+""+e+">\n",f}):(b=/(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g,a=a.replace(b,function(a,b,c,d){var e=b,f=c,g=d.search(/[*+-]/g)>-1?"ul":"ol",f=f.replace(/\n{2,}/g,"\n\n\n"),h=w(f);return h=e+"<"+g+">\n"+h+""+g+">\n",h})),a=a.replace(/~0/,""),a};w=function(a){return e++,a=a.replace(/\n{2,}$/,"\n"),a+="~0",a=a.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,function(a,b,c,d,e){var f=e,g=b,h=c;return g||f.search(/\n{2,}/)>-1?f=o(L(f)):(f=x(L(f)),f=f.replace(/\n$/,""),f=p(f)),""+f+" \n"}),a=a.replace(/~0/g,""),e--,a};var y=function(a){return a+="~0",a=a.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,function(a,b,c){var d=b,e=c;return d=C(L(d)),d=M(d),d=d.replace(/^\n+/g,""),d=d.replace(/\n+$/g,""),d=""+d+"\n
",A(d)+e}),a=a.replace(/~0/,""),a},z=function(a){return a+="~0",a=a.replace(/(?:^|\n)```(.*)\n([\s\S]*?)\n```/g,function(a,b,c){var d=b,e=c;return e=C(e),e=M(e),e=e.replace(/^\n+/g,""),e=e.replace(/\n+$/g,""),e=""+e+"\n
",A(e)}),a=a.replace(/~0/,""),a},A=function(a){return a=a.replace(/(^\n+|\n+$)/g,""),"\n\n~K"+(d.push(a)-1)+"K\n\n"},B=function(a){return a=a.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,function(a,b,c,d,e){var f=d;return f=f.replace(/^([ \t]*)/g,""),f=f.replace(/[ \t]*$/g,""),f=C(f),b+""+f+""}),a},C=function(a){return a=a.replace(/&/g,"&"),a=a.replace(//g,">"),a=N(a,"*_{}[]\\",!1),a},D=function(a){return a=a.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,"$2"),a=a.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,"$2"),a},E=function(a){return a=a.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,function(a,b){var c=b;return c=c.replace(/^[ \t]*>[ \t]?/gm,"~0"),c=c.replace(/~0/g,""),c=c.replace(/^[ \t]+$/gm,""),c=o(c),c=c.replace(/(^|\n)/g,"$1 "),c=c.replace(/(\s*[^\r]+?<\/pre>)/gm,function(a,b){var c=b;return c=c.replace(/^ /mg,"~0"),c=c.replace(/~0/g,""),c}),A("\n"+c+"\n
")}),a},F=function(a){a=a.replace(/^\n+/g,""),a=a.replace(/\n+$/g,"");var b=a.split(/\n{2,}/g),c=[],e=b.length;for(var f=0;f=0?c.push(g):g.search(/\S/)>=0&&(g=p(g),g=g.replace(/^([ \t]*)/g,""),g+="
",c.push(g))}e=c.length;for(var f=0;f=0){var h=d[RegExp.$1];h=h.replace(/\$/g,"$$$$"),c[f]=c[f].replace(/~K\d+K/,h)}return c.join("\n\n")},G=function(a){return a=a.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&"),a=a.replace(/<(?![a-z\/?\$!])/gi,"<"),a},H=function(a){return a=a.replace(/\\(\\)/g,O),a=a.replace(/\\([`*_{}\[\]()>#+-.!])/g,O),a},I=function(a){return a=a.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,'$1'),a=a.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,function(a,b){return J(K(b))}),a},J=function(a){var b=[function(a){return""+a.charCodeAt(0)+";"},function(a){return""+a.charCodeAt(0).toString(16)+";"},function(a){return a}];return a="mailto:"+a,a=a.replace(/./g,function(a){if(a=="@")a=b[Math.floor(Math.random()*2)](a);else if(a!=":"){var c=Math.random();a=c>.9?b[2](a):c>.45?b[1](a):b[0](a)}return a}),a=''+a+"",a=a.replace(/">.+:/g,'">'),a},K=function(a){return a=a.replace(/~E(\d+)E/g,function(a,b){var c=parseInt(b);return String.fromCharCode(c)}),a},L=function(a){return a=a.replace(/^(\t|[ ]{1,4})/gm,"~0"),a=a.replace(/~0/g,""),a},M=function(a){return a=a.replace(/\t(?=\t)/g," "),a=a.replace(/\t/g,"~A~B"),a=a.replace(/~B(.+?)~A/g,function(a,b,c){var d=b,e=4-d.length%4;for(var f=0;f