code
stringlengths
1
1.73M
language
stringclasses
1 value
require 'test/unit' class TC_PdfParse < Test::Unit::TestCase def setup @data = %w{ tests/dataset/empty.pdf tests/dataset/calc.pdf tests/dataset/crypto.pdf } @dict = StringScanner.new "<</N 2 0 R/x1 null/Pi 3.14 /a <<>>>>" @bytestring = String...
Ruby
require 'test/unit/testsuite' require 'tc_pdfparse.rb' require 'tc_streams.rb' require 'tc_pdfencrypt.rb' require 'tc_pdfsig.rb' require 'tc_pdfattach.rb' require 'tc_pages.rb' require 'tc_actions.rb' require 'tc_annotations.rb' require 'tc_pdfnew.rb' begin require 'origami' rescue LoadError ORIGAMIDIR = "#{File.d...
Ruby
require 'test/unit' require 'stringio' class TC_Annotations< Test::Unit::TestCase def setup @target = PDF.new @page = Page.new @action = Action::JavaScript.new "app.alert(null);" @output = StringIO.new end # def teardown # end def test_annotations circle = A...
Ruby
require 'test/unit' require 'stringio' class TC_PdfAttach < Test::Unit::TestCase def setup @target = PDF.new @attachment = "tests/dataset/test.dummycrt" @output = StringIO.new end # def teardown # end def test_attachfile assert_nothing_raised do fspec = @target.a...
Ruby
require 'test/unit' require 'stringio' class TC_PdfNew < Test::Unit::TestCase def setup @output = StringIO.new end # def teardown # end def test_pdf_struct pdf = PDF.new null = Null.new assert_nothing_raised do pdf << null end assert_nothing_raise...
Ruby
require 'test/unit' require 'stringio' class TC_Pages < Test::Unit::TestCase def setup @target = PDF.new @output = StringIO.new end # def teardown # end def test_appendpage p1, p2, p3 = Page.new, Page.new, Page.new assert_nothing_raised do @target.append_page p1...
Ruby
require 'test/unit' require 'stringio' class TC_PdfSig < Test::Unit::TestCase def setup @target = PDF.read("tests/dataset/calc.pdf", :ignore_errors => false, :verbosity => Parser::VERBOSE_QUIET) @output = StringIO.new @cert = OpenSSL::X509::Certificate.new(File.open("tests/dataset/test.dummy...
Ruby
=begin = File origami.rb = Info Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in the hop...
Ruby
# encoding: UTF-8 require 'rubygems' require 'rake/rdoctask' require 'rake/testtask' require 'rake/gempackagetask' spec = Gem::Specification.new do |s| s.name = "origami" s.version = "1.0.0" s.author = "Guillaume Delugré" s.email = "guillaume at security-labs dot org" s.homepage = "http:...
Ruby
=begin = File trailer.rb = Info Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in the hop...
Ruby
=begin = File numeric.rb = Info Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in the hop...
Ruby
module Origami module Obfuscator WHITECHARS = [ " ", "\t", "\r", "\n", "\0" ] OBJECTS = [ Array, Boolean, Dictionary, Integer, Name, Null, Stream, String, Real, Reference ] MAX_INT = 0xFFFFFFFF PRINTABLE = ("!".."9").to_a + (':'..'Z').to_a + ('['..'z').to_a + ('{'..'~').to_a FILTERS = [ :FlateD...
Ruby
=begin = File pdf.rb = Info Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in the hope th...
Ruby
=begin = File outline.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License...
Ruby
=begin = File dictionary.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume DelugrÈ <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public Lice...
Ruby
=begin = File string.rb = Info Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in the hope...
Ruby
=begin = File encryption.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume DelugrÈ <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public Lice...
Ruby
=begin = File parser.rb = Info Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in the hope...
Ruby
=begin = File graphics/state.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public ...
Ruby
=begin = File graphics/colors.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public...
Ruby
=begin = File graphics/xobject.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Publi...
Ruby
=begin = File graphics/patterns.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Publ...
Ruby
=begin = File graphics/path.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public L...
Ruby
=begin = File graphics/text.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public L...
Ruby
=begin = File graphics/instruction.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General P...
Ruby
=begin = File reference.rb = Info Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in the h...
Ruby
=begin = File name.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as...
Ruby
=begin = File webcapture.rb = Info Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in the ...
Ruby
=begin = File metadata.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public Licens...
Ruby
=begin = File signature.rb = Info Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in the h...
Ruby
=begin = File export.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume DelugrÈ <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License ...
Ruby
=begin = File array.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume DelugrÈ <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License a...
Ruby
=begin = File filters/jpx.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public Lic...
Ruby
=begin = File filters/lzw.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public Lic...
Ruby
=begin = File filters/dct.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public Lic...
Ruby
=begin = File filters/crypt.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public L...
Ruby
=begin = File filters/runlength.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Publ...
Ruby
=begin = File filters/predictors.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Pub...
Ruby
=begin = File filters/flate.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public L...
Ruby
=begin = File filters/jbig2.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public L...
Ruby
=begin = File filters/ascii.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public L...
Ruby
=begin = File filters/ccitt.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public L...
Ruby
=begin = File file.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as...
Ruby
=begin = File boolean.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume DelugrÈ <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License...
Ruby
=begin = File stream.rb = Info Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in the hope...
Ruby
=begin = File parsers/pdf.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public Lic...
Ruby
=begin = File parsers/linear.rb = Info Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in ...
Ruby
=begin = File parsers/ppklite.rb = Info Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in...
Ruby
=begin = File parsers/fdf.rb = Info Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in the...
Ruby
=begin = File page.rb = Info Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in the hope t...
Ruby
=begin = File xreftable.rb = Info Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in the h...
Ruby
=begin = File object.rb = Info Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in the hope...
Ruby
require 'sinatra/activerecord/rake' require './main'
Ruby
source :gemcutter gem 'sinatra', :require => 'sinatra/base' gem 'thin', '~> 1.3' gem 'pg' gem 'sinatra-activerecord' gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client' group :development do gem 'rake' gem 'sqlite3-ruby' end
Ruby
class CreateUsers < ActiveRecord::Migration def up create_table :users do |t| t.string :profile_id t.string :email t.string :refresh_token end add_index :users, :profile_id end def down drop_table :users end end
Ruby
# Copyright (C) 2012 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Ruby
require 'sinatra.rb' # Sinatra defines #set at the top level as a way to set application configuration set :run, false set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development) require './main' run Sinatra::Application
Ruby
# # This temporary test driver tracks progress on getting HTML5lib working # on Ruby 1.9. Prereqs of Hoe, Hpricot, and UniversalDetector will be # required to complete this. # # Once all the tests pass, this file should be deleted # require 'test/test_cli' # requires UniversalDetector # require 'test/test_encoding'...
Ruby
require 'rake' require 'hoe' require 'lib/html5/version' Hoe.new("html5", HTML5::VERSION) do |p| p.name = "html5" p.description = p.paragraphs_of('README', 2..5).join("\n\n") p.summary = "HTML5 parser/tokenizer." p.author = ['Ryan King'] # TODO: add more names p.email = 'ryan@theryanking.com' p.url ...
Ruby
require 'html5/html5parser' require 'html5/version' module HTML5 def self.parse(stream, options={}) HTMLParser.parse(stream, options) end def self.parse_fragment(stream, options={}) HTMLParser.parse_fragment(stream, options) end end
Ruby
# Warning: this module is experimental and subject to change and even removal # at any time. # # For background/rationale, see: # * http://www.intertwingly.net/blog/2007/01/08/Xhtml5lib # * http://tinyurl.com/ylfj8k (and follow-ups) # # References: # * http://googlereader.blogspot.com/2005/12/xml-errors-in-feeds....
Ruby
require 'stringio' require 'html5/constants' module HTML5 # Provides a unicode stream of characters to the HTMLTokenizer. # This class takes care of character encoding and removing or replacing # incorrect byte-sequences and also provides column and line tracking. class HTMLInputStream attr_accessor :q...
Ruby
require 'html5/constants' module HTML5 class HTMLSerializer def self.serialize(stream, options = {}) new(options).serialize(stream, options[:encoding]) end def escape(string) string.gsub("&", "&amp;").gsub("<", "&lt;").gsub(">", "&gt;") end def initialize(options={}) @quote...
Ruby
require 'html5/serializer/htmlserializer' module HTML5 class XHTMLSerializer < HTMLSerializer DEFAULTS = { :quote_attr_values => true, :minimize_boolean_attributes => false, :use_trailing_solidus => true, :escape_lt_in_attrs => true, :omit_optional_tags ...
Ruby
$:.unshift File.dirname(__FILE__), 'lib' require 'html5' require 'ostruct' require 'optparse' module HTML5::CLI def self.parse_opts argv options = OpenStruct.new options.profile = false options.time = false options.output = :html options.treebuilder = 'simpletree' ...
Ruby
module HTML5 class EOF < Exception; end def self._(str); str end CONTENT_MODEL_FLAGS = [ :PCDATA, :RCDATA, :CDATA, :PLAINTEXT ] SCOPING_ELEMENTS = %w[ applet button caption html marquee object table td th ] FORMATTING_ELEME...
Ruby
require 'cgi' require 'html5/tokenizer' require 'set' module HTML5 # This module provides sanitization of XHTML+MathML+SVG # and of inline style attributes. # # It can be either at the Tokenizer stage: # # HTMLParser.parse(html, :tokenizer => HTMLSanitizer) # # or, if you already have a parse tree (in this exam...
Ruby
module HTML5 VERSION = '0.10.1' end
Ruby
require 'html5/treewalkers/base' module HTML5 module TreeWalkers class << self def [](name) case name.to_s.downcase when 'simpletree' require 'html5/treewalkers/simpletree' SimpleTree::TreeWalker when 'rexml' require 'html5/treewalkers/rexml' ...
Ruby
module HTML5 module TreeBuilders class << self def [](name) case name.to_s.downcase when 'simpletree' then require 'html5/treebuilders/simpletree' SimpleTree::TreeBuilder when 'rexml' then require 'html5/treebuilders/rexml' REXML::TreeBuilder ...
Ruby
require 'html5/treebuilders/base' require 'rubygems' require 'hpricot' require 'forwardable' module HTML5 module TreeBuilders module Hpricot class Node < Base::Node extend Forwardable def_delegators :@hpricot, :name attr_accessor :hpricot def initialize(name) s...
Ruby
require 'html5/treebuilders/base' require 'rexml/document' require 'forwardable' module HTML5 module TreeBuilders module REXML class Node < Base::Node extend Forwardable def_delegators :@rxobj, :name, :attributes attr_accessor :rxobj def initialize name super nam...
Ruby
require 'html5/constants' #XXX - TODO; make the default interface more ElementTree-like rather than DOM-like module HTML5 # The scope markers are inserted when entering buttons, object elements, # marquees, table cells, and table captions, and are used to prevent formatting # from "leaking" into tables, button...
Ruby
require 'html5/treebuilders/base' module HTML5 module TreeBuilders module SimpleTree class Node < Base::Node # Node representing an item in the tree. # name - The tag name associated with the node attr_accessor :name # The value of the current node (applies to text nodes a...
Ruby
module HTML5 module Sniffer # 4.7.4 def html_or_feed str s = str[0, 512] # steps 1, 2 pos = 0 while pos < s.length case s[pos] when ?\t, ?\ , ?\n, ?\r # 0x09, 0x20, 0x0A, 0x0D == tab, space, LF, CR pos += 1 when ?< # 0x3C pos += 1 if s[pos..pos+2] == "!--" # [0...
Ruby
require 'html5/serializer/htmlserializer' require 'html5/serializer/xhtmlserializer'
Ruby
require 'html5/constants' require 'html5/tokenizer' require 'html5/treebuilders/rexml' Dir.glob(File.join(File.dirname(__FILE__), 'html5parser', '*_phase.rb')).each do |path| require 'html5/html5parser/' + File.basename(path) end module HTML5 # Error in parsed document class ParseError < Exception; end class...
Ruby
require 'html5/constants' require 'html5/inputstream' module HTML5 # This class takes care of tokenizing HTML. # # * @current_token # Holds the token that is currently being processed. # # * @state # Holds a reference to the method to be invoked... XXX # # * @states # Holds a mapping between...
Ruby
require 'html5/html5parser/phase' module HTML5 class AfterBodyPhase < Phase handle_end 'html' def processComment(data) # This is needed because data is to be appended to the <html> element # here and not to whatever is currently open. @tree.insert_comment(data, @tree.open_elements.first) ...
Ruby
require 'html5/html5parser/phase' module HTML5 class InSelectPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-select handle_start 'html', 'option', 'optgroup', 'select' handle_start 'input' handle_end 'option', 'optgroup', 'select', %w( caption table tbody tfoot thead tr td th ...
Ruby
require 'html5/html5parser/phase' module HTML5 class AfterHeadPhase < Phase handle_start 'html', 'body', 'frameset', %w( base link meta script style title ) => 'FromHead' handle_end %w( body html br ) => 'BodyHtmlBr' def process_eof anything_else @parser.phase.process_eof end def p...
Ruby
require 'html5/html5parser/phase' module HTML5 class InSelectInTablePhase < Phase handle_start %w(caption table tbody tfoot thead tr td th) => 'Table' handle_end %w(caption table tbody tfoot thead tr td th) => 'Table' def processCharacters(data) @parser.phases[:inSelect].processCharacters(data) end ...
Ruby
require 'html5/html5parser/phase' module HTML5 class AfterAfterFramesetPhase < Phase handle_start 'html', 'noframes' def processComment(data) @tree.insert_comment(data) end def processDoctype data @parser.phases[:inBody].processDoctype(data) end def processSpaceCha...
Ruby
require 'html5/html5parser/phase' module HTML5 class InHeadPhase < Phase handle_start 'html', 'head', 'title', 'style', 'script', 'noscript' handle_start %w( base link meta) handle_end 'head' handle_end %w( html body br ) => 'ImplyAfterHead' handle_end %w( title style script noscript ) def...
Ruby
require 'html5/html5parser/phase' module HTML5 class InForeignContentPhase < Phase def processCharacters(data) @tree.insertText(data) end def startTagOther(name, attributes, self_closing) if !%w[mglyph malignmark].include?(name) && %w[mi mo mn ms mtext].include?(@tree.open_elements.last.nam...
Ruby
require 'html5/html5parser/phase' module HTML5 class AfterFramesetPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#after3 handle_start 'html', 'noframes' handle_end 'html' def processCharacters(data) parse_error("unexpected-char-after-frameset") end def startTagNo...
Ruby
require 'html5/html5parser/phase' module HTML5 class InColumnGroupPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-column handle_start 'html', 'col' handle_end 'colgroup', 'col' def ignoreEndTagColgroup @tree.open_elements[-1].name == 'html' end def processChar...
Ruby
require 'html5/html5parser/phase' module HTML5 class InitialPhase < Phase # This phase deals with error handling as well which is currently not # covered in the specification. The error handling is typically known as # "quirks mode". It is expected that a future version of HTML5 will define this. d...
Ruby
require 'html5/html5parser/phase' module HTML5 class AfterAfterBodyPhase < Phase handle_start 'html' def processComment(data) @tree.insert_comment(data) end def processDoctype data @parser.phases[:inBody].processDoctype(data) end def processSpaceCharacters data ...
Ruby
require 'html5/html5parser/phase' module HTML5 class BeforeHeadPhase < Phase handle_start 'html', 'head' handle_end %w( head br ) => 'ImplyHead' def process_eof startTagHead('head', {}) @parser.phase.process_eof end def processSpaceCharacters(data) end def processCharacte...
Ruby
require 'html5/html5parser/phase' module HTML5 class InCellPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-cell handle_start 'html', %w( caption col colgroup tbody td tfoot th thead tr ) => 'TableOther' handle_end %w( td th ) => 'TableCell', %w( body caption col colgroup html ) =...
Ruby
module HTML5 # Base class for helper objects that implement each phase of processing. # # Handler methods should be in the following order (they can be omitted): # # * EOF # * Comment # * Doctype # * SpaceCharacters # * Characters # * StartTag # - startTag* methods # * EndTag ...
Ruby
require 'html5/html5parser/phase' module HTML5 class InRowPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-row handle_start 'html', %w( td th ) => 'TableCell', %w( caption col colgroup tbody tfoot thead tr ) => 'TableOther' handle_end 'tr', 'table', %w( tbody tfoot thead ) => 'Tab...
Ruby
require 'html5/html5parser/phase' module HTML5 class InTableBodyPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-table0 handle_start 'html', 'tr', %w( td th ) => 'TableCell', %w( caption col colgroup tbody tfoot thead ) => 'TableOther' handle_end 'table', %w( tbody tfoot thead ) =...
Ruby
require 'html5/html5parser/phase' module HTML5 class InTablePhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-table handle_start 'html', 'caption', 'colgroup', 'col', 'table' handle_start %w( tbody tfoot thead ) => 'RowGroup', %w( td th tr ) => 'ImplyTbody' handle_start %w(sty...
Ruby
require 'html5/html5parser/phase' module HTML5 class InBodyPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-body handle_start 'html' handle_start %w(base link meta script style title) => 'ProcessInHead' handle_start 'body', 'form', 'plaintext', 'a', 'button', 'xmp', 'table', '...
Ruby
require 'html5/html5parser/phase' module HTML5 class InFramesetPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-frameset handle_start 'html', 'frameset', 'frame', 'noframes' handle_end 'frameset', 'noframes' def processCharacters(data) parse_error("unexpected-char-in-fr...
Ruby
require 'html5/html5parser/phase' module HTML5 class InCaptionPhase < Phase # http://www.whatwg.org/specs/web-apps/current-work/#in-caption handle_start 'html', %w(caption col colgroup tbody td tfoot th thead tr) => 'TableElement' handle_end 'caption', 'table', %w(body col colgroup html tbody td tfoot...
Ruby
require 'html5/html5parser/phase' module HTML5 class BeforeHtmlPhase < Phase def process_eof insert_html_element @parser.phase.process_eof end def processComment(data) @tree.insert_comment(data, @tree.document) end def processSpaceCharacters(data) end def processChar...
Ruby
require 'html5/treewalkers/base' require 'rexml/document' module HTML5 module TreeWalkers module Hpricot class TreeWalker < HTML5::TreeWalkers::NonRecursiveTreeWalker def node_details(node) case node when ::Hpricot::Elem if node.name.empty? [:DOCUMENT_...
Ruby