├── 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 |

Markdown Libs

3 | 4 | 5 | <% Markdown.libs.each do |lib| 6 | conv = Markdown.create_converter( lib ) 7 | %> 8 | 9 | 10 | 11 | 12 | 13 | <% end %> 14 |
<%= lib %><%= conv.version %>
15 | -------------------------------------------------------------------------------- /kramdown-service/TODOS.md: -------------------------------------------------------------------------------- 1 | # TODOs 2 | 3 | - [ ] remove view-source: from sample links in service docu 4 | 5 | - [ ] check GFM if hard breaks are enforced by defaut? if yes, always add hard_breaks: false or something 6 | 7 | - [ ] add kramup bin in /bin to startup server 8 | - [ ] add rouge syntax highlighter 9 | - [ ] add some tests for the service use rack-test ?? 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /markdown/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore generated folders 2 | pkg/ 3 | doc/ 4 | 5 | # ignore jekyll generated output 6 | site/_site/ 7 | 8 | # ignore generated test html pages 9 | ./*.html 10 | sandbox/*.html 11 | 12 | 13 | # ignore output folders 14 | 15 | o/ 16 | kramdown/ 17 | k/ 18 | redcarpet/ 19 | r/ 20 | 21 | # ignore local markdown.yml (used for testing only) 22 | 23 | markdown.yml 24 | -------------------------------------------------------------------------------- /markdown/lib/markdown/engines/rpeg_markdown.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | module Markdown 4 | module Engine 5 | 6 | def rpeg_markdown_to_html( content, options={} ) 7 | puts " Converting Markdown-text (#{content.length} bytes) to HTML using library rpeg_markdown..." 8 | 9 | PEGMarkdown.new( content ).to_html 10 | end 11 | 12 | end # module Engine 13 | end # module Markdown 14 | -------------------------------------------------------------------------------- /kramdown-service/lib/kramdown/service/views/_editor_head.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /markdown-service/lib/markdown/service/views/layout.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | markdown ruby gem - use your markdown library of choice in ruby 6 | 7 | 8 | <%= erb :'_editor_head' %> 9 | 10 | 11 | 12 | <%= yield %> 13 | 14 | <%= erb :'_version' %> 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /markdown-service/lib/markdown/service/views/_version.erb: -------------------------------------------------------------------------------- 1 |
2 | Questions? Comments? | 3 | markdown/<%= Markdown::VERSION %> - 4 | Ruby/<%= "#{RUBY_VERSION} (#{RUBY_RELEASE_DATE}/#{RUBY_PLATFORM})" %> on 5 | Sinatra/<%= Sinatra::VERSION %> (<%= ENV['RACK_ENV'] %>) 6 |
7 | -------------------------------------------------------------------------------- /markdown.lib.js/README.md: -------------------------------------------------------------------------------- 1 | # markdown.lib.js 2 | 3 | markdown (wrapper) for libraries in JavaScript 4 | 5 | 6 | 7 | 8 | ## License 9 | 10 | The `markdown.lib.js` scripts are dedicated to the public domain. 11 | Use it as you please with no restrictions whatsoever. 12 | 13 | ## Questions? Comments? 14 | 15 | Send them along to the [Markdown Mailing List](http://six.pairlist.net/mailman/listinfo/markdown-discuss). 16 | Thanks! 17 | -------------------------------------------------------------------------------- /markdown.themes/README.md: -------------------------------------------------------------------------------- 1 | # markdown.themes 2 | 3 | markdown themes (styles) 4 | 5 | 6 | 7 | 8 | 9 | 10 | ## License 11 | 12 | The `markdown.themes` scripts and styles are dedicated to the public domain. 13 | Use it as you please with no restrictions whatsoever. 14 | 15 | ## Questions? Comments? 16 | 17 | Send them along to the [Markdown Mailing List](http://six.pairlist.net/mailman/listinfo/markdown-discuss). 18 | Thanks! 19 | -------------------------------------------------------------------------------- /markdown/Manifest.txt: -------------------------------------------------------------------------------- 1 | HISTORY.md 2 | Manifest.txt 3 | README.md 4 | Rakefile 5 | lib/markdown.rb 6 | lib/markdown/config.rb 7 | lib/markdown/engines/bluecloth.rb 8 | lib/markdown/engines/kramdown.rb 9 | lib/markdown/engines/maruku.rb 10 | lib/markdown/engines/pandoc_ruby.rb 11 | lib/markdown/engines/rdiscount.rb 12 | lib/markdown/engines/redcarpet.rb 13 | lib/markdown/engines/rpeg_markdown.rb 14 | lib/markdown/version.rb 15 | lib/markdown/wrapper.rb 16 | -------------------------------------------------------------------------------- /markdown/lib/markdown/engines/bluecloth.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | module Markdown 4 | module Engine 5 | 6 | def bluecloth_version 7 | BlueCloth::VERSION 8 | end 9 | 10 | def bluecloth_to_html( content, options={} ) 11 | puts " Converting Markdown-text (#{content.length} bytes) to HTML using library bluecloth..." 12 | 13 | BlueCloth.new( content ).to_html 14 | end 15 | 16 | end # module Engine 17 | end # module Markdown 18 | -------------------------------------------------------------------------------- /markdown/lib/markdown/engines/maruku.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | module Markdown 4 | module Engine 5 | 6 | def maruku_version 7 | Maruku::VERSION 8 | end 9 | 10 | def maruku_to_html( content, options={} ) 11 | puts " Converting Markdown-text (#{content.length} bytes) to HTML using library maruku..." 12 | 13 | Maruku.new( content, {:on_error => :raise} ).to_html 14 | end 15 | 16 | end # module Engine 17 | end # module Markdown -------------------------------------------------------------------------------- /markdown/lib/markdown/engines/rdiscount.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | module Markdown 4 | module Engine 5 | 6 | def rdiscount_version 7 | RDiscount::VERSION 8 | end 9 | 10 | def rdiscount_to_html( content, options={} ) 11 | puts " Converting Markdown-text (#{content.length} bytes) to HTML using library rdiscount..." 12 | 13 | RDiscount.new( content ).to_html 14 | end 15 | 16 | 17 | end # module Engine 18 | end # module Markdown -------------------------------------------------------------------------------- /markdown-service/boot.rb: -------------------------------------------------------------------------------- 1 | 2 | # ruby stdlibs 3 | 4 | require 'pp' 5 | 6 | 7 | 8 | ENV['RACK_ENV'] ||= 'development' 9 | 10 | puts "ENV['RACK_ENV'] = #{ENV['RACK_ENV']}" 11 | 12 | ## NB: no DB required/in use for now; just simple service calls 13 | 14 | ## add lib to load path 15 | 16 | $LOAD_PATH << "./lib" 17 | 18 | # magic flag for config settings (see lib/markdown/config.rb) 19 | $MARKDOWN_USE_SERVICE_CONFIG = true 20 | 21 | require 'markdown' 22 | 23 | require './lib/markdown/service.rb' 24 | -------------------------------------------------------------------------------- /markdown-service/lib/markdown/service/docs/welcome.md: -------------------------------------------------------------------------------- 1 | # Header 1 2 | 3 | ## Header 2 4 | 5 | ### Header 3 6 | 7 | Welcome to [Markdown](/). We hope you **really** enjoy using this. 8 | 9 | Just type some [markdown](http://daringfireball.net/projects/markdown) on the left and see it on the right. *Simple as that.* 10 | 11 | > Quote goes here. 12 | 13 | A list: 14 | 15 | - One 16 | - Two 17 | - Three 18 | 19 | Some inline code `to_html` and a preformatted code block: 20 | 21 | ``` 22 | Markdown.new( 'Hello Markdown!' ).to_html 23 | ``` 24 | -------------------------------------------------------------------------------- /kramdown-service/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: http://rubygems.org/ 3 | specs: 4 | kramdown (1.10.0) 5 | kramdown-service (0.3.0) 6 | kramdown 7 | rouge 8 | sinatra 9 | rack (1.6.4) 10 | rack-protection (1.5.3) 11 | rack 12 | rouge (1.10.1) 13 | sinatra (1.4.7) 14 | rack (~> 1.5) 15 | rack-protection (~> 1.4) 16 | tilt (>= 1.3, < 3) 17 | tilt (2.0.2) 18 | 19 | PLATFORMS 20 | x86-mingw32 21 | 22 | DEPENDENCIES 23 | kramdown 24 | kramdown-service 25 | rouge 26 | sinatra 27 | -------------------------------------------------------------------------------- /kramdown-service/lib/kramdown/service/views/_editor_setup.erb: -------------------------------------------------------------------------------- 1 | 22 | -------------------------------------------------------------------------------- /markdown-tools/lib/markdown/cli/version.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | module MarkdownCli 4 | 5 | MAJOR = 1 6 | MINOR = 2 7 | PATCH = 0 8 | VERSION = [MAJOR,MINOR,PATCH].join('.') 9 | 10 | def self.version 11 | VERSION 12 | end 13 | 14 | def self.banner 15 | "markdown-tools/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]" 16 | end 17 | 18 | def self.root 19 | "#{File.expand_path( File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) )}" 20 | end 21 | 22 | end # module MarkdownCli 23 | 24 | -------------------------------------------------------------------------------- /markdown-service/Gemfile: -------------------------------------------------------------------------------- 1 | source 'http://rubygems.org' 2 | 3 | gem 'sinatra', :require => 'sinatra/base' 4 | 5 | ########################## 6 | # markdown libs/engines 7 | 8 | gem 'kramdown' 9 | gem 'redcarpet' 10 | gem 'maruku' 11 | gem 'bluecloth' 12 | 13 | # gem 'rdiscount' # compilation error on heroku; sorry excluded for now 14 | 15 | # gem 'rpeg-markdown' # compilation error w/ bundler - exclude for now; still active, anyway? 16 | 17 | 18 | ################### 19 | # more libs 20 | 21 | gem 'textutils' 22 | gem 'props' 23 | 24 | gem 'markdown' 25 | 26 | -------------------------------------------------------------------------------- /kramdown-service/lib/kramdown/service/docs/welcome.md: -------------------------------------------------------------------------------- 1 | # Heading 1 2 | 3 | ## Heading 2 4 | 5 | ### Heading 3 6 | 7 | Welcome to the [kramdown Online Editor](/). We hope you **really** enjoy using this. 8 | 9 | Just type some [markdown](http://en.wikipedia.org/wiki/Markdown) 10 | on the left and see it on the right. *Simple as that.* 11 | 12 | > Quote goes here. 13 | 14 | A list: 15 | 16 | - One 17 | - Two 18 | - Three 19 | 20 | Some inline code `to_html` and a preformatted code block: 21 | 22 | ``` 23 | Kramdown::Document.new( 'Hello Markdown!' ).to_html 24 | ``` 25 | -------------------------------------------------------------------------------- /kramdown-service/lib/kramdown/service/views/_version.erb: -------------------------------------------------------------------------------- 1 |
2 | Questions? Comments? | 3 | 4 | kramdown-service/<%= KramdownService::VERSION %> using 5 | 6 | kramdown/<%= Kramdown::VERSION %> - 7 | Ruby/<%= "#{RUBY_VERSION} (#{RUBY_RELEASE_DATE}/#{RUBY_PLATFORM})" %> on 8 | Sinatra/<%= Sinatra::VERSION %> (<%= ENV['RACK_ENV'] %>) 9 |
10 | -------------------------------------------------------------------------------- /markdown/lib/markdown/version.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | module Markdown 4 | 5 | MAJOR = 1 6 | MINOR = 2 7 | PATCH = 1 8 | VERSION = [MAJOR,MINOR,PATCH].join('.') 9 | 10 | def self.version 11 | VERSION 12 | end 13 | 14 | 15 | # version string for generator meta tag (includes ruby version) 16 | def self.banner 17 | "markdown/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})" 18 | end 19 | 20 | def self.root 21 | File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) ) 22 | end 23 | 24 | end # module Markdown 25 | 26 | -------------------------------------------------------------------------------- /markdown-service/lib/markdown/service/views/_editor_head.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /markdown-service/lib/markdown/service/version.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | module MarkdownService 4 | 5 | MAJOR = 1 6 | MINOR = 2 7 | PATCH = 0 8 | VERSION = [MAJOR,MINOR,PATCH].join('.') 9 | 10 | def self.version 11 | VERSION 12 | end 13 | 14 | def self.banner 15 | "markdown-service/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] on Sinatra/#{Sinatra::VERSION} (#{ENV['RACK_ENV']})" 16 | end 17 | 18 | def self.root 19 | "#{File.expand_path( File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) )}" 20 | end 21 | 22 | end # module MarkdownService 23 | 24 | -------------------------------------------------------------------------------- /markdown-service/lib/markdown/service/views/_editor_setup.erb: -------------------------------------------------------------------------------- 1 | 27 | -------------------------------------------------------------------------------- /kramdown-service/lib/kramdown/service/version.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | module KramdownService 4 | 5 | MAJOR = 1 6 | MINOR = 0 7 | PATCH = 0 8 | VERSION = [MAJOR,MINOR,PATCH].join('.') 9 | 10 | 11 | def self.version 12 | VERSION 13 | end 14 | 15 | def self.banner 16 | "kramdown-service/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] " + 17 | "using kramdown/#{Kramdown::VERSION} " + 18 | "on Sinatra/#{Sinatra::VERSION} (#{ENV['RACK_ENV']})" 19 | end 20 | 21 | def self.root 22 | "#{File.expand_path( File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) )}" 23 | end 24 | 25 | end # module KramdownService 26 | -------------------------------------------------------------------------------- /markdown-service/lib/markdown/service/views/_about.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Markdown Gem / About

4 | 5 |

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 |

13 | 14 |

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 |

Markdown Libs / Live Examples

3 | 4 | 5 | <% Markdown.libs.each do |lib| 6 | conv = Markdown.create_converter( lib ) 7 | %> 8 | 9 | 10 | 11 | 18 | 25 | 26 | <% end %> 27 |
<%= lib %> / <%= conv.version %> - 12 | GET 13 | 14 | /markdown?lib=<%= lib %>&text=Hello+World! 15 | 16 | 17 | 19 | • GET 20 | 21 | /dingus?lib=<%= lib %>&text=Hello+World! 22 | 23 | 24 |
28 | -------------------------------------------------------------------------------- /markdown-service/lib/markdown/service/views/_debug.erb: -------------------------------------------------------------------------------- 1 | 2 |

Debug

3 | 4 |

Params

5 | 6 |
 7 |   <%= params.inspect %>
 8 | 
9 | 10 | 11 |

Request

12 | 13 |
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 | try kramdown - kramdown-service ruby gem - convert markdown to HTML or LaTeX 6 | 7 | 8 | <%= erb :'_editor_head' %> 9 | 10 | 11 | 12 | 13 | 14 | 15 | 18 | 22 | 23 |
16 |

kramdown Online Editor

17 |
19 | HTTP JSON API Service • 20 | About 21 |
24 | 25 | 26 | <%= yield %> 27 | 28 | 29 | 32 | 33 | <%= erb :'_version' %> 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /markdown/test/test_redcarpet.rb: -------------------------------------------------------------------------------- 1 | ### 2 | # NB: for local testing run like: 3 | # 4 | # 1.9.x: ruby -Ilib test/test_redcarpet.rb 5 | 6 | # core and stlibs 7 | 8 | require 'helper' 9 | 10 | 11 | class TestRedcarpet < MiniTest::Test 12 | 13 | def setup 14 | puts 'enter setup' 15 | lib = Markdown.lib 16 | puts ' set lib=redcarpet' 17 | Markdown.lib = 'redcarpet' 18 | end 19 | 20 | def test_lib 21 | lib = Markdown.lib 22 | assert_equal( 'redcarpet', lib ) 23 | end 24 | 25 | def test_to_html_banner_false 26 | html = Markdown.new( 'Hello World!', banner: false ).to_html 27 | assert_equal( "

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 |

Debug

3 | 4 |

Params

5 | 6 |
 7 |   <%= params.inspect %>
 8 | 
9 | 10 | 11 |

Request

12 | 13 |
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 |

kramdown opts

30 | 31 | <% 32 | doc = Kramdown::Document.new( '', preprocess_opts( params_to_opts( params )) ) 33 | %> 34 | 35 |
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 | 6 | 7 | 8 | 9 | 10 | 11 | 19 | 26 | 27 | 28 | 41 | 46 | 47 |
12 | 13 | 14 |
15 | 16 |
17 | 18 |
20 | 21 | 22 |
23 | 24 | 25 |
29 | 30 | 31 | 32 | Use 33 | 34 | 35 | [ Update ] 36 | [ Use White Color Theme ] 37 | 38 | 39 |
40 |
42 | 43 | [ Show HTML ] 44 | 45 |
48 | -------------------------------------------------------------------------------- /kramdown-service/test/test_kramdown.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | ### 4 | # to run use 5 | # ruby -I ./lib -I ./test test/test_kramdown.rb 6 | 7 | 8 | 9 | require 'helper' 10 | 11 | 12 | class TestKramdown < MiniTest::Test 13 | 14 | 15 | def test_kramdown 16 | 17 | text = 'Hello, World!' 18 | 19 | doc = Kramdown::Document.new( text ) 20 | 21 | puts "options:" 22 | pp doc.options 23 | 24 | html = "

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 | 5 | 6 | 20 | 21 | 28 |
29 | 30 | 31 | 32 |
7 | 8 | 9 | 10 | Use 11 | 12 | 13 |
14 | [ Update ] 15 | 16 | 17 |
18 | 19 |
22 |
23 | Options:
24 | [ Use White Color Theme ] 25 | [ Show HTML ] 26 |
27 |
33 | 34 | 35 | 36 | 37 | 38 | 46 | 53 | 54 |
39 | 40 | 41 |
42 | 43 |
44 | 45 |
47 | 48 | 49 |
50 | 51 | 52 |
55 | -------------------------------------------------------------------------------- /kramdown-service/test/test_markdown.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | ### 4 | # to run use 5 | # ruby -I ./lib -I ./test test/test_markdown.rb 6 | 7 | 8 | ENV['RACK_ENV'] = 'test' ## move to helper - why? why not?? 9 | 10 | 11 | require 'helper' 12 | 13 | require 'rack/test' ## move to helper - why? why not?? 14 | 15 | 16 | class TestMarkdown < MiniTest::Test 17 | include Rack::Test::Methods 18 | 19 | def app 20 | Kramdown::Service 21 | end 22 | 23 | def test_hello_world 24 | get '/markdown', { text: 'Hello, World!' } 25 | 26 | assert last_response.ok? 27 | assert_equal 'text/html;charset=utf-8', last_response.headers['Content-Type'] 28 | 29 | pp last_response.body 30 | 31 | html = "

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 | Markdown Note 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 34 | 39 | 40 | 41 | 46 | 50 | 51 |
29 | 30 |
31 | 32 |
33 |
35 | 36 |
37 | 38 |
42 | 43 | [ Update ] 44 | [ Use White Color Theme ] 45 | 47 | 48 | [ Show HTML ] 49 |
52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /kramdown-service/lib/kramdown/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 a:hover { 15 | background-color: gold; 16 | } 17 | 18 | 19 | .markdown em { 20 | background-color: #fffeca; 21 | padding: 0 0.08em; 22 | } 23 | 24 | .markdown abbr { 25 | border-bottom: 1px dashed; 26 | cursor: help; 27 | } 28 | 29 | .markdown blockquote { 30 | border-left: 5px solid #ddd; 31 | color: #555; 32 | margin: 0 0 1em; 33 | padding-left: 0.6em; 34 | } 35 | 36 | .markdown pre { 37 | background-color: #f8f8ff; 38 | border: 1px solid #dedede; 39 | color: #444; 40 | font-family: "Bitstream Vera Sans Mono", Courier, monospace; 41 | font-size: 0.8em; 42 | line-height: 1.5em; 43 | margin: 0 0 2em; 44 | overflow: auto; 45 | padding: 0.5em; 46 | } 47 | 48 | .markdown pre code { 49 | background-color: #f8f8ff; 50 | border: medium none; 51 | font-size: 1em; 52 | padding: 0; 53 | } 54 | 55 | .markdown code { 56 | background-color: #f8f8ff; 57 | border: 1px solid #dedede; 58 | color: #444; 59 | padding: 0 0.2em; 60 | font-family: "Bitstream Vera Sans Mono", Courier, monospace; 61 | font-size: 0.8em; 62 | } 63 | -------------------------------------------------------------------------------- /markdown.note.starter/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#input-toggle, a#input-toggle:visited, a#input-toggle:hover, 13 | a#output-toggle, a#output-toggle:visited, a#output-toggle:hover, 14 | a#output-update, a#output-update:visited, a#output-update: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 | -------------------------------------------------------------------------------- /markdown/lib/markdown/engines/pandoc_ruby.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | module Markdown 4 | module Engine 5 | 6 | def pandoc_ruby_to_html( content, options={} ) 7 | puts " Converting Markdown-text (#{content.length} bytes) to HTML using library pandoc_ruby..." 8 | 9 | content = PandocRuby.new( content, :from => :markdown, :to => :html ).convert 10 | end 11 | 12 | def pandoc_ruby_to_html_incremental( content, options={} ) 13 | content = PandocRuby.new( content, :from => :markdown, :to => :html ).convert 14 | content = content.gsub(/<(ul|ol)/) do |match| 15 | "#{Regexp.last_match(0)} class='step'" 16 | end 17 | content 18 | end 19 | 20 | # sample how to use your own converter 21 | # configure in markdown.yml 22 | # pandoc-ruby: 23 | # converter: pandoc-ruby-to-s5 24 | 25 | def pandoc_ruby_to_s5( content, options={} ) 26 | content = PandocRuby.new( content, {:from => :markdown, :to => :s5}, :smart ).convert 27 | content = content.gsub(/class="incremental"/,'class="step"') 28 | content = content.to_a[13..-1].join # remove the layout div 29 | end 30 | 31 | def pandoc_ruby_to_s5_incremental( content, options={} ) 32 | content = PandocRuby.new( content, {:from => :markdown, :to => :s5 }, :incremental, :smart ).convert 33 | content = content.gsub(/class="incremental"/,'class="step"') 34 | content = content.to_a[13..-1].join # remove the layout div 35 | end 36 | 37 | end # module Engine 38 | end # module Markdown -------------------------------------------------------------------------------- /kramdown-service/test/test_babelmark.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | ### 4 | # to run use 5 | # ruby -I ./lib -I ./test test/test_babelmark.rb 6 | 7 | 8 | ENV['RACK_ENV'] = 'test' ## move to helper - why? why not?? 9 | 10 | 11 | require 'helper' 12 | 13 | require 'rack/test' ## move to helper - why? why not?? 14 | 15 | 16 | class TestBabelmark < MiniTest::Test 17 | include Rack::Test::Methods 18 | 19 | def app 20 | Kramdown::Service 21 | end 22 | 23 | def test_hello_world 24 | get '/babelmark', { text: 'Hello, World!' } 25 | 26 | assert last_response.ok? 27 | assert_equal 'application/json', last_response.headers['Content-Type'] 28 | 29 | data = JSON.parse( last_response.body ) 30 | pp data 31 | 32 | html = "

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 =< 42 | EOS 43 | 44 | banner_end =< 46 | EOS 47 | 48 | content = banner_begin + content + banner_end 49 | end # if show_banner 50 | 51 | content 52 | 53 | end 54 | 55 | end # module Engine 56 | end # module Markdown 57 | -------------------------------------------------------------------------------- /markdown-service/lib/markdown/service/views/_service.erb: -------------------------------------------------------------------------------- 1 | 2 |

Markdown Web Service / HTTP JSON(P) API

3 | 4 |

Render Markdown

5 | 6 |
GET /markdown
 7 | 
8 | 9 |

10 | Input: 11 |

12 | 13 | 18 | 19 |

20 | Example: 21 | GET 22 | 23 | /markdown?text=Hello+World! 24 | 25 | 26 |

27 | 28 |

29 | Response: 30 |

31 | 32 |
Status: 200 OK
33 | Content-Type: text/html
34 | 
35 | <p>Hello World!<p>
36 | 
37 | 38 | 39 |

Render Markdown (Babelmark2-Style)

40 | 41 |
GET /dingus
42 | 
43 | 44 |

45 | Input: 46 |

47 | 48 | 53 | 54 | 55 |

Example: 56 | GET 57 | 58 | /dingus?text=Hello+World! 59 | 60 | 61 |

62 | 63 |

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 | Markdown Note 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 41 | 48 | 49 | 50 | 63 | 68 | 69 |
34 | 35 | 36 |
37 | 38 |
39 | 40 |
42 | 43 | 44 |
45 | 46 | 47 |
51 | 52 | 53 | 54 | Use 55 | 56 | 57 | [ Update ] 58 | [ Use White Color Theme ] 59 | 60 | 61 |
62 |
64 | 65 | [ Show HTML ] 66 | 67 |
70 | 71 | 72 | -------------------------------------------------------------------------------- /markdown-service/lib/markdown/service/public/note.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Markdown Note 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 41 | 48 | 49 | 50 | 63 | 68 | 69 |
34 | 35 | 36 |
37 | 38 |
39 | 40 |
42 | 43 | 44 |
45 | 46 | 47 |
51 | 52 | 53 | 54 | Use 55 | 56 | 57 | [ Update ] 58 | [ Use White Color Theme ] 59 | 60 | 61 |
62 |
64 | 65 | [ Show HTML ] 66 | 67 |
70 | 71 | 72 | -------------------------------------------------------------------------------- /kramdown-service/lib/kramdown/service/public/js/kramdown.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | var kramdown_new = function( opts ) { 4 | 5 | var settings; // NB: defaults + opts merged => settings 6 | 7 | var defaults = { 8 | api_url: 'http://trykramdown.herokuapp.com/markdown' 9 | } 10 | 11 | 12 | function _debug( msg ) 13 | { 14 | if(window.console && window.console.log ) 15 | window.console.log( "[debug] " + msg ); 16 | } 17 | 18 | 19 | function _init( opts ) { 20 | settings = $.extend( {}, defaults, opts ); 21 | } 22 | 23 | _init( opts ); 24 | 25 | 26 | function _convert( text, more_params, handler ) 27 | { 28 | var params = $.extend( { text: text }, more_params ); // merge in more params; use text for required param 29 | 30 | $.get( settings.api_url, params, function( data ) { 31 | handler( data ); 32 | }); 33 | } 34 | 35 | function convert_to_html( text, handler ) { 36 | // note: make gfm (github-flavored markdown) the default parser 37 | _convert( text, { to: 'html' }, handler ); 38 | } 39 | 40 | function convert_to_html_with_syntax_highlighter( text, handler ) { 41 | // note: make gfm (github-flavored markdown) the default parser 42 | _convert( text, { to: 'html', syntax_highlighter: 'rouge' }, handler ); 43 | } 44 | 45 | function convert_to_html_with_classic( text, handler ) { 46 | // note: use "classic" "standard" kramdown parser/reader 47 | _convert( text, { to: 'html', input: 'classic' }, handler ); 48 | } 49 | 50 | 51 | 52 | function convert_to_latex( text, handler ) { 53 | _convert( text, { to: 'latex' }, handler ); 54 | } 55 | 56 | return { 57 | convert_to_html: convert_to_html, 58 | convert_to_html_with_syntax_highlighter: convert_to_html_with_syntax_highlighter, 59 | convert_to_html_with_classic: convert_to_html_with_classic, 60 | convert_to_latex: convert_to_latex 61 | } 62 | 63 | } // fn kramdown_new 64 | 65 | -------------------------------------------------------------------------------- /markdown-tools/README.md: -------------------------------------------------------------------------------- 1 | # markdown-tools gem - markdown command line tools 2 | 3 | * home :: [github.com/rubylibs/markdown-tools](https://github.com/rubylibs/markdown-tools) 4 | * bugs :: [github.com/rubylibs/markdown-tools/issues](https://github.com/rubylibs/markdown-tools/issues) 5 | * gem :: [rubygems.org/gems/markdown-tools](https://rubygems.org/gems/markdown-tools) 6 | * rdoc :: [rubydoc.info/gems/markdown-tools](http://rubydoc.info/gems/markdown-tools) 7 | 8 | 9 | 10 | 11 | ## Usage - Command Line 12 | 13 | The `markdown-tools` gem includes a little command line tool. Try `markdown -h` for details: 14 | 15 | markdown - Lets you convert plain text documents to hypertext with your Markdown engine of choice 16 | and preprocessing text filters. 17 | 18 | Usage: markdown [options] files_or_dirs 19 | -o, --output PATH Output Path 20 | -v, --verbose Show debug trace 21 | 22 | 23 | Examples: 24 | markdown # Process all documents in working folder (that is, .) 25 | markdown quickref # Process document or folder using Markdown 26 | markdown quickref.text # Process document using Markdown 27 | markdown -o site quickref # Output documents to site folder 28 | 29 | Note: 30 | markdown server # Starts builtin markdown server 31 | # (aliases for server include serve, service, s) 32 | 33 | 34 | 35 | ## Install 36 | 37 | Just install the gem: 38 | 39 | $ gem install markdown-tools 40 | 41 | 42 | 43 | ## License 44 | 45 | The `markdown-tools` scripts are dedicated to the public domain. 46 | Use it as you please with no restrictions whatsoever. 47 | 48 | 49 | ## Questions? Comments? 50 | 51 | Send them along to the 52 | [Free Web Slide Show Alternatives (S5, S6, S9, Slidy And Friends) Forum/Mailing List](http://groups.google.com/group/webslideshow). 53 | Thanks! 54 | -------------------------------------------------------------------------------- /kramdown-service/README.md: -------------------------------------------------------------------------------- 1 | # kramdown-service gem - kramdown HTTP JSON API service (convert markdown to HTML or LaTeX) 2 | 3 | * home :: [github.com/writekit/kramdown-service](https://github.com/writekit/kramdown-service) 4 | * bugs :: [github.com/writekit/kramdown-service/issues](https://github.com/writekit/kramdown-service/issues) 5 | * gem :: [rubygems.org/gems/kramdown-service](https://rubygems.org/gems/kramdown-service) 6 | * rdoc :: [rubydoc.info/gems/kramdown-service](http://rubydoc.info/gems/kramdown-service) 7 | 8 | 9 | ## Live Version 10 | 11 | Try the `markdown` HTTP (JSON) API running 12 | on Heroku [`trykramdown.herokuapp.com`](http://trykramdown.herokuapp.com). 13 | 14 | Note: If you see an Application Error on Heroku. Sorry. It means "**Free app running time quota exhausted**". 15 | Please, check back and retry on the first day of the next upcoming month (that starts a new dyna hours quota) or use `$ kramup` to run the service on your local machine). Thanks. 16 | 17 | 18 | 19 | 20 | ## Start Your Own Local Version / Service 21 | 22 | To start your own local version on your own machine use the bundled command line tool called `kramup`. 23 | 24 | Step 0 - Install the gem e.g. 25 | 26 | $ gem install kramdown-service 27 | 28 | Step 1 - Start the server / service e.g. 29 | 30 | $ kramup 31 | 32 | Step 2 - Open up the editor page in your browser e.g. use `http://localhost:4567`. 33 | 34 | That's it. 35 | 36 | 37 | ## Usage - Web Service / HTTP (JSON) API - `GET /markdown` 38 | 39 | 40 | Example 1 - Converting to Hypertext (HTML): 41 | 42 | GET /markdown?text=Hello+World! 43 | 44 |

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 |

Kramdown Web Service / HTTP JSON(P) API

3 | 4 |

Render Markdown

5 | 6 |
GET /markdown
  7 | 
8 | 9 |

10 | Input: 11 |

12 | 13 | 16 | 19 | 20 | 21 | 22 |

23 | Example (HTML): 24 | GET 25 | 26 | /markdown?text=Hello+World! 27 | 28 | 29 |

30 | 31 |

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 |

52 | 53 |

54 | Response: 55 |

56 | 57 |
Status: 200 OK
 58 | Content-Type: text/latex
 59 | 
 60 | Hello World
 61 | 
62 | 63 | 64 | 65 | 66 |

Render Markdown (Babelmark2-Style)

67 | 68 |
GET /babelmark
 69 | 
70 | 71 |

72 | Input: 73 |

74 | 75 | 78 | 79 | 80 |

Example: 81 | GET 82 | 83 | /babelmark?text=Hello+World! 84 | 85 | 86 |

87 | 88 |

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 =< 49 | EOS 50 | 51 | banner_end =< 53 | EOS 54 | content = banner_begin + content + banner_end 55 | end # if show_banner 56 | 57 | content 58 | 59 | end 60 | 61 | end # module Engine 62 | end # module Markdown 63 | -------------------------------------------------------------------------------- /markdown/sandbox/bench.rb: -------------------------------------------------------------------------------- 1 | require 'benchmark' 2 | require 'pathname' 3 | 4 | 5 | require 'rubygems' 6 | 7 | require 'bluecloth' 8 | require 'maruku' 9 | require 'kramdown' 10 | require 'redcarpet' 11 | require 'rdiscount' 12 | 13 | ITERATIONS = 200 14 | 15 | ## todo: use longer sample text 16 | 17 | TEST_FILE = Pathname.new( __FILE__ ).dirname + 'rest.text' 18 | TEST_DATA = TEST_FILE.read 19 | TEST_DATA.freeze 20 | 21 | 22 | puts "Markdown -> Hypertext, #{ITERATIONS} iterations (using document >#{TEST_FILE}<, #{TEST_DATA.length} bytes)" 23 | 24 | class KramdownWrapper 25 | VERSION = Kramdown::VERSION 26 | 27 | def self.name 28 | 'Kramdown' 29 | end 30 | 31 | def initialize( text ) 32 | @text = text 33 | end 34 | 35 | def to_html 36 | Kramdown::Document.new( @text ).to_html 37 | end 38 | end 39 | 40 | 41 | class RedcarpetWrapper 42 | VERSION = Redcarpet::VERSION 43 | 44 | def self.name 45 | 'Redcarpet' 46 | end 47 | 48 | def initialize( text ) 49 | @text = text 50 | end 51 | 52 | def to_html 53 | engine = Redcarpet::Markdown.new(Redcarpet::Render::HTML) 54 | engine.render( @text ) 55 | end 56 | end 57 | 58 | 59 | 60 | ENGINES = [ 61 | BlueCloth, 62 | Maruku, 63 | RDiscount, 64 | KramdownWrapper, 65 | RedcarpetWrapper ] 66 | 67 | 68 | Benchmark.bmbm do |bench| 69 | ENGINES.each do |engine| 70 | heading = "%s (%s)" % [ engine.name, engine.const_get(:VERSION) ] 71 | bench.report( heading ) { ITERATIONS.times {engine.new(TEST_DATA).to_html} } 72 | end 73 | end 74 | 75 | __END__ 76 | 77 | Markdown -> Hypertext, 200 iterations (using document >sandbox/rest.text<, 2880 bytes) 78 | 79 | Rehearsal ----------------------------------------------------- 80 | BlueCloth (1.0.1) 1.466000 0.000000 1.466000 ( 1.462000) 81 | Maruku (3.1.7.3) 5.242000 0.016000 5.258000 ( 5.290000) 82 | RDiscount (1.6.8) 0.078000 0.000000 0.078000 ( 0.072000) 83 | Kramdown (0.13.7) 2.699000 0.327000 3.026000 ( 3.032000) 84 | Redcarpet (2.1.1) 0.015000 0.000000 0.015000 ( 0.019000) 85 | -------------------------------------------- total: 9.843000sec 86 | 87 | user system total real 88 | BlueCloth (1.0.1) 1.529000 0.000000 1.529000 ( 1.553000) 89 | Maruku (3.1.7.3) 5.772000 0.000000 5.772000 ( 5.780000) 90 | RDiscount (1.6.8) 0.078000 0.000000 0.078000 ( 0.072000) 91 | Kramdown (0.13.7) 2.621000 0.000000 2.621000 ( 2.611000) 92 | Redcarpet (2.1.1) 0.015000 0.000000 0.015000 ( 0.018000) -------------------------------------------------------------------------------- /markdown.api.js/markdown.api.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | var markdown_apis_new = function() { 4 | 5 | function _get_dingus( api_url, api_params, handle_html ) 6 | { 7 | var api_params_str = $.param( api_params ); 8 | api_params_str += '&callback=?' // NB: add callback for jquery jsonp; NB: need to append as string to avoid encoding of =? 9 | 10 | $.getJSON( api_url, api_params_str, function( data ) { 11 | handle_html( data.html ); // NB: assumes response { 'html': 'markup here' } 12 | }); 13 | } 14 | 15 | function _get_dingus_via_proxy( api_url, api_params, handle_html ) 16 | { 17 | api_params.url = api_url; // add url to params 18 | var api_proxy_url = 'http://note.herokuapp.com/proxy' 19 | 20 | _get_dingus( api_proxy_url, api_params, handle_html ); 21 | } 22 | 23 | function _ruby_w_lib( text, lib, handle_html ) 24 | { 25 | var api_params = { 26 | text: text, 27 | lib: lib 28 | } 29 | var api_url = 'http://note.herokuapp.com/markdown/dingus'; 30 | 31 | _get_dingus( api_url, api_params, handle_html ); 32 | } 33 | 34 | 35 | function ruby( text, handle_html ) 36 | { 37 | var api_params = { 38 | text: text 39 | } 40 | var api_url = 'http://note.herokuapp.com/markdown/dingus'; 41 | 42 | _get_dingus( api_url, api_params, handle_html ); 43 | } 44 | 45 | function pandoc( text, handle_html ) 46 | { 47 | // NB: note jsonp enabled - no cross domain request possible; use proxy server or similar 48 | // todo: find other service 49 | var api_params = { 50 | text: text 51 | } 52 | var api_url = 'http://johnmacfarlane.net/cgi-bin/pandoc-dingus' 53 | 54 | _get_dingus_via_proxy( api_url, api_params, handle_html ); 55 | } 56 | 57 | 58 | function kramdown( text, handle_html ) 59 | { 60 | _ruby_w_lib( text, 'kramdown', handle_html ); 61 | } 62 | 63 | function maruku( text, handle_html ) 64 | { 65 | _ruby_w_lib( text, 'maruku', handle_html ); 66 | } 67 | 68 | function redcarpet( text, handle_html ) 69 | { 70 | _ruby_w_lib( text, 'redcarpet', handle_html ); 71 | } 72 | 73 | function bluecloth( text, handle_html ) 74 | { 75 | _ruby_w_lib( text, 'bluecloth', handle_html ); 76 | } 77 | 78 | return { 79 | ruby: ruby, 80 | ruby_kramdown: kramdown, 81 | ruby_maruku: maruku, 82 | ruby_redcarpet: redcarpet, 83 | ruby_bluecloth: bluecloth, 84 | pandoc: pandoc 85 | } 86 | } // fn makrdown_apis_new 87 | 88 | 89 | 90 | var markdown_apis = markdown_apis_new(); 91 | 92 | //////////////// 93 | // use like 94 | // 95 | // markdown_apis.ruby( text, success ); 96 | // markdown_apis.ruby_kramdown( text, success ); 97 | // mardkown_apis.pandoc( text, success ); 98 | // etc. 99 | 100 | -------------------------------------------------------------------------------- /markdown.note/js/markdown.api.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | var markdown_apis_new = function() { 4 | 5 | function _get_dingus( api_url, api_params, handle_html ) 6 | { 7 | var api_params_str = $.param( api_params ); 8 | api_params_str += '&callback=?' // NB: add callback for jquery jsonp; NB: need to append as string to avoid encoding of =? 9 | 10 | $.getJSON( api_url, api_params_str, function( data ) { 11 | handle_html( data.html ); // NB: assumes response { 'html': 'markup here' } 12 | }); 13 | } 14 | 15 | function _get_dingus_via_proxy( api_url, api_params, handle_html ) 16 | { 17 | api_params.url = api_url; // add url to params 18 | var api_proxy_url = 'http://note.herokuapp.com/proxy' 19 | 20 | _get_dingus( api_proxy_url, api_params, handle_html ); 21 | } 22 | 23 | function _ruby_w_lib( text, lib, handle_html ) 24 | { 25 | var api_params = { 26 | text: text, 27 | lib: lib 28 | } 29 | var api_url = 'http://note.herokuapp.com/markdown/dingus'; 30 | 31 | _get_dingus( api_url, api_params, handle_html ); 32 | } 33 | 34 | 35 | function ruby( text, handle_html ) 36 | { 37 | var api_params = { 38 | text: text 39 | } 40 | var api_url = 'http://note.herokuapp.com/markdown/dingus'; 41 | 42 | _get_dingus( api_url, api_params, handle_html ); 43 | } 44 | 45 | function pandoc( text, handle_html ) 46 | { 47 | // NB: note jsonp enabled - no cross domain request possible; use proxy server or similar 48 | // todo: find other service 49 | var api_params = { 50 | text: text 51 | } 52 | var api_url = 'http://johnmacfarlane.net/cgi-bin/pandoc-dingus' 53 | 54 | _get_dingus_via_proxy( api_url, api_params, handle_html ); 55 | } 56 | 57 | 58 | function kramdown( text, handle_html ) 59 | { 60 | _ruby_w_lib( text, 'kramdown', handle_html ); 61 | } 62 | 63 | function maruku( text, handle_html ) 64 | { 65 | _ruby_w_lib( text, 'maruku', handle_html ); 66 | } 67 | 68 | function redcarpet( text, handle_html ) 69 | { 70 | _ruby_w_lib( text, 'redcarpet', handle_html ); 71 | } 72 | 73 | function bluecloth( text, handle_html ) 74 | { 75 | _ruby_w_lib( text, 'bluecloth', handle_html ); 76 | } 77 | 78 | return { 79 | ruby: ruby, 80 | ruby_kramdown: kramdown, 81 | ruby_maruku: maruku, 82 | ruby_redcarpet: redcarpet, 83 | ruby_bluecloth: bluecloth, 84 | pandoc: pandoc 85 | } 86 | } // fn makrdown_apis_new 87 | 88 | 89 | 90 | var markdown_apis = markdown_apis_new(); 91 | 92 | //////////////// 93 | // use like 94 | // 95 | // markdown_apis.ruby( text, success ); 96 | // markdown_apis.ruby_kramdown( text, success ); 97 | // mardkown_apis.pandoc( text, success ); 98 | // etc. 99 | 100 | -------------------------------------------------------------------------------- /markdown-service/lib/markdown/service/public/js/markdown.api.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | var markdown_apis_new = function() { 4 | 5 | function _get_dingus( api_url, api_params, handle_html ) 6 | { 7 | var api_params_str = $.param( api_params ); 8 | api_params_str += '&callback=?' // NB: add callback for jquery jsonp; NB: need to append as string to avoid encoding of =? 9 | 10 | $.getJSON( api_url, api_params_str, function( data ) { 11 | handle_html( data.html ); // NB: assumes response { 'html': 'markup here' } 12 | }); 13 | } 14 | 15 | function _get_dingus_via_proxy( api_url, api_params, handle_html ) 16 | { 17 | api_params.url = api_url; // add url to params 18 | var api_proxy_url = 'http://note.herokuapp.com/proxy' 19 | 20 | _get_dingus( api_proxy_url, api_params, handle_html ); 21 | } 22 | 23 | function _ruby_w_lib( text, lib, handle_html ) 24 | { 25 | var api_params = { 26 | text: text, 27 | lib: lib 28 | } 29 | var api_url = 'http://note.herokuapp.com/markdown/dingus'; 30 | 31 | _get_dingus( api_url, api_params, handle_html ); 32 | } 33 | 34 | 35 | function ruby( text, handle_html ) 36 | { 37 | var api_params = { 38 | text: text 39 | } 40 | var api_url = 'http://note.herokuapp.com/markdown/dingus'; 41 | 42 | _get_dingus( api_url, api_params, handle_html ); 43 | } 44 | 45 | function pandoc( text, handle_html ) 46 | { 47 | // NB: note jsonp enabled - no cross domain request possible; use proxy server or similar 48 | // todo: find other service 49 | var api_params = { 50 | text: text 51 | } 52 | var api_url = 'http://johnmacfarlane.net/cgi-bin/pandoc-dingus' 53 | 54 | _get_dingus_via_proxy( api_url, api_params, handle_html ); 55 | } 56 | 57 | 58 | function kramdown( text, handle_html ) 59 | { 60 | _ruby_w_lib( text, 'kramdown', handle_html ); 61 | } 62 | 63 | function maruku( text, handle_html ) 64 | { 65 | _ruby_w_lib( text, 'maruku', handle_html ); 66 | } 67 | 68 | function redcarpet( text, handle_html ) 69 | { 70 | _ruby_w_lib( text, 'redcarpet', handle_html ); 71 | } 72 | 73 | function bluecloth( text, handle_html ) 74 | { 75 | _ruby_w_lib( text, 'bluecloth', handle_html ); 76 | } 77 | 78 | return { 79 | ruby: ruby, 80 | ruby_kramdown: kramdown, 81 | ruby_maruku: maruku, 82 | ruby_redcarpet: redcarpet, 83 | ruby_bluecloth: bluecloth, 84 | pandoc: pandoc 85 | } 86 | } // fn makrdown_apis_new 87 | 88 | 89 | 90 | var markdown_apis = markdown_apis_new(); 91 | 92 | //////////////// 93 | // use like 94 | // 95 | // markdown_apis.ruby( text, success ); 96 | // markdown_apis.ruby_kramdown( text, success ); 97 | // mardkown_apis.pandoc( text, success ); 98 | // etc. 99 | 100 | -------------------------------------------------------------------------------- /kramdown-service/NOTES.md: -------------------------------------------------------------------------------- 1 | # Notes 2 | 3 | ## Alternatives 4 | 5 | Online Kramdown Editor by Daniel Perez Alvarez (aka unindented) 6 | 7 | - Live @ Heroku [kramdown.herokuapp.com](http://kramdown.herokuapp.com) 8 | - Source @ GitHub [unindented/online-kramdown-sinatra](https://github.com/unindented/online-kramdown-sinatra) 9 | 10 | 11 | 12 | ## kramdown Options 13 | 14 | doc = Kramdown::Document.new( '' ) 15 | pp doc.options 16 | 17 | ``` 18 | {:template=>"", 19 | :auto_ids=>true, 20 | :auto_id_stripping=>false, 21 | :auto_id_prefix=>"", 22 | :transliterated_header_ids=>false, 23 | :parse_block_html=>false, 24 | :parse_span_html=>true, 25 | :html_to_native=>false, 26 | :link_defs=>{}, 27 | :footnote_nr=>1, 28 | :enable_coderay=>true, 29 | :coderay_wrap=>:div, 30 | :coderay_line_numbers=>:inline, 31 | :coderay_line_number_start=>1, 32 | :coderay_tab_width=>8, 33 | :coderay_bold_every=>10, 34 | :coderay_css=>:style, 35 | :coderay_default_lang=>nil, 36 | :entity_output=>:as_char, 37 | :toc_levels=>[1, 2, 3, 4, 5, 6], 38 | :line_width=>72, 39 | :latex_headers=> 40 | ["section", 41 | "subsection", 42 | "subsubsection", 43 | "paragraph", 44 | "subparagraph", 45 | "subparagraph"], 46 | :smart_quotes=>["lsquo", "rsquo", "ldquo", "rdquo"], 47 | :remove_block_html_tags=>true, 48 | :remove_span_html_tags=>false, 49 | :header_offset=>0, 50 | :hard_wrap=>true, 51 | :syntax_highlighter=>:coderay, 52 | :syntax_highlighter_opts=>{}, 53 | :math_engine=>:mathjax, 54 | :math_engine_opts=>{}, 55 | :footnote_backlink=>"↩"} 56 | ``` 57 | 58 | doc = Kramdown::Document.new( '', input: 'GFM', hard_wrap: false, syntax_highlighter: 'rouge' ) 59 | pp doc.options 60 | 61 | ``` 62 | {:template=>"", 63 | :auto_ids=>true, 64 | :auto_id_stripping=>false, 65 | :auto_id_prefix=>"", 66 | :transliterated_header_ids=>false, 67 | :parse_block_html=>false, 68 | :parse_span_html=>true, 69 | :html_to_native=>false, 70 | :link_defs=>{}, 71 | :footnote_nr=>1, 72 | :enable_coderay=>true, 73 | :coderay_wrap=>:div, 74 | :coderay_line_numbers=>:inline, 75 | :coderay_line_number_start=>1, 76 | :coderay_tab_width=>8, 77 | :coderay_bold_every=>10, 78 | :coderay_css=>:style, 79 | :coderay_default_lang=>nil, 80 | :entity_output=>:as_char, 81 | :toc_levels=>[1, 2, 3, 4, 5, 6], 82 | :line_width=>72, 83 | :latex_headers=> 84 | ["section", 85 | "subsection", 86 | "subsubsection", 87 | "paragraph", 88 | "subparagraph", 89 | "subparagraph"], 90 | :smart_quotes=>["lsquo", "rsquo", "ldquo", "rdquo"], 91 | :remove_block_html_tags=>true, 92 | :remove_span_html_tags=>false, 93 | :header_offset=>0, 94 | :hard_wrap=>false, 95 | :syntax_highlighter=>:rouge, 96 | :syntax_highlighter_opts=>{}, 97 | :math_engine=>:mathjax, 98 | :math_engine_opts=>{}, 99 | :footnote_backlink=>"↩", 100 | :input=>"GFM"} 101 | ``` 102 | -------------------------------------------------------------------------------- /markdown-tools/lib/markdown/cli/gen.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | module Markdown 4 | 5 | class Gen 6 | 7 | include TextUtils::Filter # include filters such as comments_percent_style, etc. (see textutils gem) 8 | 9 | attr_reader :logger 10 | attr_reader :opts 11 | 12 | def initialize( logger, opts ) 13 | @logger = logger 14 | @opts = opts 15 | end 16 | 17 | def create_doc( fn ) 18 | dirname = File.dirname( fn ) 19 | basename = File.basename( fn, '.*' ) 20 | extname = File.extname( fn ) 21 | 22 | logger.debug "dirname=#{dirname}, basename=#{basename}, extname=#{extname}" 23 | 24 | if opts.output_path == '.' 25 | # expand output path in current dir 26 | outpath = File.expand_path( dirname ) 27 | else 28 | # expand output path in user supplied dir and make sure output path exists 29 | outpath = File.expand_path( opts.output_path ) 30 | FileUtils.makedirs( outpath ) unless File.directory? outpath 31 | end 32 | logger.debug "outpath=#{outpath}" 33 | 34 | # todo: add a -c option to commandline? to let you set cwd? 35 | 36 | 37 | # change working dir to sourcefile dir (that is, dirname); push working folder/dir 38 | newcwd = File.expand_path( dirname ) 39 | oldcwd = File.expand_path( Dir.pwd ) 40 | 41 | unless newcwd == oldcwd 42 | logger.debug "oldcwd=>#{oldcwd}<, newcwd=>#{newcwd}<" 43 | Dir.chdir( newcwd ) 44 | end 45 | 46 | inname = "#{basename}#{extname}" 47 | outname = "#{basename}.html" 48 | 49 | logger.debug "inname=#{inname}, outname=#{outname}" 50 | 51 | puts "*** #{inname} (#{dirname}) => #{outname} (#{(opts.output_path == '.') ? dirname : opts.output_path})..." 52 | 53 | content = File.read( inname ) 54 | 55 | # step 1) run (optional) preprocessing text filters 56 | Markdown.filters.each do |filter| 57 | mn = filter.tr( '-', '_' ).to_sym # construct method name (mn) 58 | content = send( mn, content ) # call filter e.g. include_helper_hack( content ) 59 | end 60 | 61 | # step 2) convert light-weight markup to hypertext 62 | content = Markdown.new( content ).to_html 63 | 64 | 65 | ## todo: add Markdown.lib_options inspect/dump to banner 66 | 67 | banner =< 72 | EOS 73 | 74 | out = File.new( File.join( outpath, outname ), "w+" ) 75 | #### out << banner 76 | out << content 77 | out.flush 78 | out.close 79 | 80 | ## pop/restore working folder/dir 81 | unless newcwd == oldcwd 82 | logger.debug "oldcwd=>#{oldcwd}<, newcwd=>#{newcwd}<" 83 | Dir.chdir( oldcwd ) 84 | end 85 | 86 | end # method create_doc 87 | 88 | 89 | 90 | end # class Gen 91 | end # module Markdown 92 | -------------------------------------------------------------------------------- /markdown/sandbox/rest.text: -------------------------------------------------------------------------------- 1 | 2 | Web Services REST-Style: Universal Identifiers, Formats & Protocols 3 | =================================================================== 4 | 5 | Agenda 6 | 7 | - What's REST? 8 | - Universal Identifiers, Formats & Protocols 9 | - The Holy REST Trinity - Noun, Verbs, Types 10 | - REST Design Principles 11 | - Architecture Astronaut REST Speak 12 | 13 | 14 | What's REST? 15 | ============ 16 | 17 | Representational State Transfer (REST) - Meaningless Acronym? Wordplay? 18 | 19 | rest - n. - peace, ease, or refreshment resulting from the insight that the web works 20 | 21 | No matter what vendors tell you - no need to "Light Up the Web" - relax - built on an **open architecture using universal identifiers, formats & protocols and _evolving_ open standards** - no need to reinvent the wheel and sign-up for single-vendor offerings. 22 | 23 | ### Broad Definition 24 | 25 | - Best Practices for Designing Web Services for a Unified Human and Programable Web 26 | 27 | ### Narrow Definition 28 | 29 | - Alternative to BigCo Web Services (SOAP, WS-STAR) and RPC-Style Web Services (XML-RPC) 30 | 31 | ### Resource, Representation, State, Transfer 32 | 33 | - (Stateless) Resource Representation -> Open Format + Identifier e.g. HTML+URI 34 | - Transfer Rules (Protocol) e.g. HTTP 35 | 36 | 37 | Universal Identifiers, Formats & Protocols - The Holy Trinity 38 | ============================================================= 39 | 40 | - Identifiers -> URLs (Uniform Resource Locator), URIs (Uniform Resource Identifier) 41 | - Formats -> HTML (HyperText Markup Language), XML (Extensible Markup Language) 42 | - Protocols -> HTTP (HyperText Transfer Protocol), AtomPub (Atom Publishing Protocol) 43 | 44 | 45 | The Holy REST Trinity - Noun, Verbs, Types 46 | ========================================== 47 | 48 | REST-Speak - Internet-Speak - Plain Old English 49 | 50 | - Verbs -> Protocols -> Communication & Data Exchange Rules 51 | - Nouns -> Identifiers -> Names, Addresses 52 | - Types -> Formats -> Documents, Feeds, Photos, Videos, Music, etc. 53 | 54 | Examples: 55 | - Verbs -> HTTP GET, POST, PUT, DELETE 56 | - Nouns -> `flickr.com/photos/tag/vancouver`, `deli.cio.us/vanajax/tag/libraries`, etcetera 57 | - Types -> HTML, RSS, PNG, etcetera 58 | 59 | 60 | REST Design Principles - What's REST? 61 | ===================================== 62 | 63 | - Idenifiers Matter - Choose Great Names 64 | - Open Formats Matter - Avoid Vendor Lock-In 65 | - Protocols Matter - Learn more about HTTP and Use Best Practices 66 | - Use HTTP GET for Read-Only/Side-Effect-Free Requests 67 | - Use HTTP Accept Headers for Format Selection 68 | - Use Full HTTP Method Vocabulary (GET, POST, PUT, DELETE) 69 | 70 | More: 71 | - No Web without Linking and No Linking without Identifiers! 72 | - (Stateless) Resource Representation -> Open Format + Identifier e.g. HTML+URI 73 | 74 | 75 | Architecture Astronaut REST Speak 76 | ================================= 77 | 78 | - REST-y 79 | - REST-ful 80 | 81 | Or: 82 | - Resource-Oriented Architecure (ROA) 83 | - Web-Oriented Architecure (WOA) 84 | 85 | Or: 86 | - REST-RPC-Hybrid (Three Web Service Architectures): 87 | - 1) REST 88 | - 2) REST-RPC Hybrid 89 | - 3) RPC (Remote Procedure Call) 90 | -------------------------------------------------------------------------------- /markdown/sandbox/test.text: -------------------------------------------------------------------------------- 1 | Headers 2 | ------- 3 | 4 | # Heading 1 5 | 6 | ## Heading 2 7 | 8 | ### Heading 3 9 | 10 | #### Heading 4 11 | 12 | ##### Heading 5 13 | 14 | ###### Heading 6 15 | 16 | Heading 1 17 | ========= 18 | 19 | Heading 2 20 | --------- 21 | 22 | 23 | 24 | 25 | Paragraphs 26 | ---------- 27 | 28 | 29 | The first paragraph. 30 | 31 | Another paragraph. 32 | 33 | This is a paragraph 34 | which contains a hard line break. 35 | 36 | 37 | 38 | 39 | Blockquotes 40 | ----------- 41 | 42 | 43 | > A sample blockquote. 44 | > 45 | > >Nested blockquotes are 46 | > >also possible. 47 | > 48 | > ## Headers work too 49 | > This is the outer quote again. 50 | 51 | 52 | 53 | Code Blocks 54 | ----------- 55 | 56 | This is a sample code block. 57 | 58 | # The Greeter class 59 | class Greeter 60 | def initialize(name) 61 | @name = name.capitalize 62 | end 63 | 64 | def salute 65 | puts "Hello #{@name}!" 66 | end 67 | end 68 | 69 | # Create a new object 70 | g = Greeter.new("world") 71 | 72 | # Output "Hello World!" 73 | g.salute 74 | 75 | 76 | This is a sample fenced code block. 77 | 78 | ~~~ 79 | # The Greeter class 80 | class Greeter 81 | def initialize(name) 82 | @name = name.capitalize 83 | end 84 | 85 | def salute 86 | puts "Hello #{@name}!" 87 | end 88 | end 89 | 90 | # Create a new object 91 | g = Greeter.new("world") 92 | 93 | # Output "Hello World!" 94 | g.salute 95 | ~~~ 96 | 97 | This is a sample fenced code block. 98 | 99 | ``` 100 | # The Greeter class 101 | class Greeter 102 | def initialize(name) 103 | @name = name.capitalize 104 | end 105 | 106 | def salute 107 | puts "Hello #{@name}!" 108 | end 109 | end 110 | 111 | # Create a new object 112 | g = Greeter.new("world") 113 | 114 | # Output "Hello World!" 115 | g.salute 116 | ``` 117 | 118 | 119 | 120 | Horizontal Rules 121 | ---------------- 122 | 123 | * * * 124 | 125 | --- 126 | 127 | _ _ _ _ 128 | 129 | --------------- 130 | 131 | 132 | 133 | Lists 134 | ----- 135 | 136 | 1. This is a list item 137 | 2. And another item 138 | 2. And the third one 139 | with additional text 140 | 141 | 142 | 1. This is a list item 143 | 144 | > with a blockquote 145 | 146 | # And a header 147 | 148 | 2. Followed by another item 149 | 150 | 151 | 152 | Nested lists: 153 | 154 | 1. Item one 155 | 1. sub item one 156 | 2. sub item two 157 | 3. sub item three 158 | 2. Item two 159 | 160 | 161 | 162 | Tables 163 | ------ 164 | 165 | | A simple | table | 166 | | with multiple | lines| 167 | 168 | 169 | | Header1 | Header2 | Header3 | 170 | |:--------|:-------:|--------:| 171 | | cell1 | cell2 | cell3 | 172 | | cell4 | cell5 | cell6 | 173 | |---- 174 | | cell1 | cell2 | cell3 | 175 | | cell4 | cell5 | cell6 | 176 | 177 | 178 | HTML Elements 179 | ------------- 180 | 181 |
182 | This is wrapped in a para. 183 |
184 | 185 |

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 `_to_html` gets used 127 | (for example, the default converter for `kramdown` is `kramdown_to_html`). 128 | 129 | Example: 130 | 131 | pandoc-ruby: 132 | converter: pandoc-ruby-to-s5 133 | 134 | 135 | ## Install 136 | 137 | Just install the gem: 138 | 139 | $ gem install markdown 140 | 141 | 142 | 143 | ## Real World Usage 144 | 145 | The [`slideshow`](http://slideshow-s9.github.io) (also known as Slide Show (S9)) gem 146 | that lets you create slide shows 147 | and author slides in plain text using a wiki-style markup language that's easy-to-write and easy-to-read. 148 | 149 | 150 | ## Alternatives 151 | 152 | * [`multi_markdown`](https://github.com/postmodern/multi_markdown) gem by Hal Brodigan (aka postmodern) 153 | * [`markdown_meta`](https://github.com/headius/markdown_meta) gem by Charles Oliver Nutter (aka headius) 154 | 155 | 156 | ## License 157 | 158 | The `markdown` scripts are dedicated to the public domain. 159 | Use it as you please with no restrictions whatsoever. 160 | 161 | 162 | ## Questions? Comments? 163 | 164 | Send them along to the 165 | [Free Web Slide Show Alternatives (S5, S6, S9, Slidy And Friends) Forum/Mailing List](http://groups.google.com/group/webslideshow). 166 | Thanks! 167 | -------------------------------------------------------------------------------- /markdown.note/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 += '