diff --git a/.document b/.document new file mode 100644 index 0000000..b3114f5 --- /dev/null +++ b/.document @@ -0,0 +1,3 @@ +- +ChangeLog.* +LICENSE.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ac5b454 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +doc/ +pkg/ diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..660778b --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--colour --format documentation diff --git a/.yardopts b/.yardopts new file mode 100644 index 0000000..880274c --- /dev/null +++ b/.yardopts @@ -0,0 +1 @@ +--markup markdown --title "ffi-upskirt Documentation" --protected diff --git a/ChangeLog.md b/ChangeLog.md new file mode 100644 index 0000000..81e44ca --- /dev/null +++ b/ChangeLog.md @@ -0,0 +1,4 @@ +### 0.1.0 / 2011-05-10 + +* Initial release: + diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..896c424 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,20 @@ +Copyright (c) 2011 Hal Brodigan + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..cf48452 --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +# ffi-upskirt + +* [Source](http://github.com/postmodern/ffi-upskirt) +* [Issues](http://github.com/postmodern/ffi-upskirt/issues) +* [Documentation](http://rubydoc.info/gems/ffi-upskirt/frames) +* [Email](mailto:postmodern.mod3 at gmail.com) + +## Description + +Ruby FFI bindings for the libupskirt markdown library. + +## Examples + + require 'ffi/upskirt' + +## Requirements + +## Install + + $ gem install ffi-upskirt + +## Copyright + +Copyright (c) 2011 Hal Brodigan + +See {file:LICENSE.txt} for details. diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..182a621 --- /dev/null +++ b/Rakefile @@ -0,0 +1,38 @@ +require 'rubygems' +require 'rake' + +begin + gem 'ore-tasks', '~> 0.4' + require 'ore/tasks' + + Ore::Tasks.new +rescue LoadError => e + STDERR.puts e.message + STDERR.puts "Run `gem install ore-tasks` to install 'ore/tasks'." +end + +begin + gem 'rspec', '~> 2.4' + require 'rspec/core/rake_task' + + RSpec::Core::RakeTask.new +rescue LoadError => e + task :spec do + abort "Please run `gem install rspec` to install RSpec." + end +end + +task :test => :spec +task :default => :spec + +begin + gem 'yard', '~> 0.6.0' + require 'yard' + + YARD::Rake::YardocTask.new +rescue LoadError => e + task :yard do + abort "Please run `gem install yard` to install YARD." + end +end +task :doc => :yard diff --git a/ffi-upskirt.gemspec b/ffi-upskirt.gemspec new file mode 100644 index 0000000..32b45f0 --- /dev/null +++ b/ffi-upskirt.gemspec @@ -0,0 +1,15 @@ +# -*- encoding: utf-8 -*- + +begin + Ore::Specification.new do |gemspec| + # custom logic here + end +rescue NameError + begin + require 'ore/specification' + retry + rescue LoadError + STDERR.puts "The '#{__FILE__}' file requires Ore." + STDERR.puts "Run `gem install ore-core` to install Ore." + end +end diff --git a/gemspec.yml b/gemspec.yml new file mode 100644 index 0000000..1c6413d --- /dev/null +++ b/gemspec.yml @@ -0,0 +1,15 @@ +name: ffi-upskirt +summary: FFI bindings for libupskirt +description: + Ruby FFI bindings for the libupskirt markdown library. + +license: MIT +authors: Postmodern +email: postmodern.mod3@gmail.com +homepage: http://github.com/postmodern/ffi-upskirt +has_yard: true + +development_dependencies: + ore-tasks: ~> 0.4 + rspec: ~> 2.4 + yard: ~> 0.6.0 diff --git a/lib/ffi/upskirt.rb b/lib/ffi/upskirt.rb new file mode 100644 index 0000000..eaafd4a --- /dev/null +++ b/lib/ffi/upskirt.rb @@ -0,0 +1,2 @@ +require 'ffi/upskirt/upskirt' +require 'ffi/upskirt/version' diff --git a/lib/ffi/upskirt/buf.rb b/lib/ffi/upskirt/buf.rb new file mode 100644 index 0000000..1cc068e --- /dev/null +++ b/lib/ffi/upskirt/buf.rb @@ -0,0 +1,15 @@ +require 'ffi' + +module FFI + module Upskirt + class Buf < FFI::Struct + + layout :data, :pointer, + :size, :size_t, + :asize, :size_t, + :unit, :size_t, + :ref, :int + + end + end +end diff --git a/lib/ffi/upskirt/renderer.rb b/lib/ffi/upskirt/renderer.rb new file mode 100644 index 0000000..61ec7b4 --- /dev/null +++ b/lib/ffi/upskirt/renderer.rb @@ -0,0 +1,34 @@ +module FFI + module Upskirt + class Renderer < FFI::Struct + + layout :blockcode, :blockcode_callback, + :blockquote, :blockquote_callback, + :blockhtml, :blockhtml_callback, + :header, :header_callback, + :hrule, :hrule_callback, + :list, :list_callback, + :listitem, :listitem_callback, + :paragraph, :paragraph_callback, + :table, :table_callback, + :table_row, :table_row_callback, + :table_cell, :table_cell_callback, + :autolink, :autolink_callback, + :codespan, :codespan_callback, + :double_emphasis, :double_emphasis_callback, + :emphasis, :emphasis_callback, + :image, :image_callback, + :linebreak, :linebreak_callback, + :link, :link_callback, + :raw_html_tag, :raw_html_tag_callback, + :triple_emphasis, :triple_emphasis_callback, + :strikethrough, :strikethrough_callback, + :entity, :entity_callback, + :normal_text, :normal_text_callback, + :doc_header, :doc_header_callback, + :doc_footerm, :doc_footer_callback, + :opaque, :pointer + + end + end +end diff --git a/lib/ffi/upskirt/types.rb b/lib/ffi/upskirt/types.rb new file mode 100644 index 0000000..531741a --- /dev/null +++ b/lib/ffi/upskirt/types.rb @@ -0,0 +1,56 @@ +require 'ffi' + +module FFI + module Upskirt + extend FFI::Library + + enum :markdown_autolink, [ + :not_autolink, + :normal, + :email + ] + + enum :markdown_extensions, [ + :no_intra_emphasis, (1 << 0), + :tables, (1 << 1), + :fenced_code, (1 << 2), + :autolink, (1 << 3), + :strikethrough, (1 << 4), + :lax_html_blocks, (1 << 5), + :space_headers, (1 << 6) + ] + + # block level callbacks - NULL skips the block + callback :blockcode_callback, [:pointer, :pointer, :pointer, :pointer], :void + callback :blockquote_callback, [:pointer, :pointer, :pointer], :void + callback :blockhtml_callback, [:pointer, :pointer, :pointer], :void + callback :header_callback, [:pointer, :pointer, :int, :pointer], :void + callback :hrule_callback, [:pointer, :pointer], :void + callback :list_callback, [:pointer, :pointer, :int, :pointer], :void + callback :listitem_callback, [:pointer, :pointer, :int, :pointer], :void + callback :paragraph_callback, [:pointer, :pointer, :pointer], :void + callback :table_callback, [:pointer, :pointer, :pointer, :pointer], :void + callback :table_row_callback, [:pointer, :pointer, :pointer], :void + callback :table_cell_callback, [:pointer, :pointer, :int, :pointer], :void + + # span level callbacks - NULL or return 0 prints the span verbatim + callback :autolink_callback, [:pointer, :pointer, :markdown_autolink, :pointer], :int + callback :codespan_callback, [:pointer, :pointer, :pointer], :int + callback :double_emphasis_callback, [:pointer, :pointer, :pointer], :int + callback :emphasis_callback, [:pointer, :pointer, :pointer], :int + callback :image_callback, [:pointer, :pointer, :pointer, :pointer, :pointer], :int + callback :linebreak_callback, [:pointer, :pointer], :int + callback :link_callback, [:pointer, :pointer, :pointer, :pointer, :pointer], :int + callback :raw_html_tag_callback, [:pointer, :pointer, :pointer], :int + callback :triple_emphasis_callback, [:pointer, :pointer, :pointer], :int + callback :strikethrough_callback, [:pointer, :pointer, :pointer], :int + + # low level callbacks - NULL copies input directly into the output + callback :entity, [:pointer, :pointer, :pointer], :void + callback :normal_text, [:pointer, :pointer, :pointer], :void + + # header and footer + callback :doc_header, [:pointer, :pointer], :void + callback :doc_footer, [:pointer, :pointer], :void + end +end diff --git a/lib/ffi/upskirt/upskirt.rb b/lib/ffi/upskirt/upskirt.rb new file mode 100644 index 0000000..51cc4f4 --- /dev/null +++ b/lib/ffi/upskirt/upskirt.rb @@ -0,0 +1,40 @@ +require 'ffi/upskirt/types' + +require 'ffi' + +module FFI + module Upskirt + extend FFI::Library + + ffi_lib 'upskirt' + + attach_function :bufcasecmp, [:pointer, :pointer], :int + attach_function :bufcmp, [:pointer, :pointer], :int + attach_function :bufcmps, [:pointer, :pointer], :int + attach_function :bufprefix, [:pointer, :pointer], :int + attach_function :bufdup, [:pointer, :size_t], :pointer + attach_function :bufgrow, [:pointer, :size_t], :int + attach_function :bufnew, [:size_t], :pointer + attach_function :bufnullterm, [:pointer], :void + attach_function :bufprintf, [:pointer, :pointer, :varargs], :void + attach_function :bufput, [:pointer, :pointer, :size_t], :void + attach_function :bufputs, [:pointer, :pointer], :void + attach_function :bufputc, [:pointer, :char], :void + attach_function :bufrelease, [:pointer], :void + attach_function :bufreset, [:pointer], :void + attach_function :bufset, [:pointer, :pointer], :void + attach_function :bufslurp, [:pointer, :size_t], :void + attach_function :buftoi, [:pointer, :size_t, :pointer], :int + + MARKDOWN_LIST_ORDERED = 1 + MARKDOWN_LI_BLOCK = 2 + MARKDOWN_TABLE_ALIGN_L = (1 << 0) + MARKDOWN_TABLE_ALIGN_R = (1 << 1) + MARKDOWN_TABLE_ALIGN_CENTER = ( + MARKDOWN_TABLE_ALIGN_L | MARKDOWN_TABLE_ALIGN_R + ) + + attach_function :is_safe_link, [:pointer, :size_t], :int + attach_function :ups_markdown, [:pointer, :pointer, :pointer, :uint], :void + end +end diff --git a/lib/ffi/upskirt/version.rb b/lib/ffi/upskirt/version.rb new file mode 100644 index 0000000..b9508ea --- /dev/null +++ b/lib/ffi/upskirt/version.rb @@ -0,0 +1,6 @@ +module FFI + module Upskirt + # ffi-upskirt version + VERSION = "0.1.0" + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..63d9570 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,5 @@ +gem 'rspec', '~> 2.4' +require 'rspec' +require 'ffi/upskirt/version' + +include FFI::Upskirt diff --git a/spec/upskirt_spec.rb b/spec/upskirt_spec.rb new file mode 100644 index 0000000..9b3d57a --- /dev/null +++ b/spec/upskirt_spec.rb @@ -0,0 +1,8 @@ +require 'spec_helper' +require 'ffi/upskirt' + +describe FFI::Upskirt do + it "should have a VERSION constant" do + subject.const_get('VERSION').should_not be_empty + end +end