diff --git a/Gemfile b/Gemfile index 74c6541..dc0928e 100644 --- a/Gemfile +++ b/Gemfile @@ -7,11 +7,3 @@ group :development, :test do gem 'rspec', '>= 3' gem 'tilt' end - -group :coderay do - gem 'coderay' -end - -group :pygments do - gem 'pygments.rb' -end diff --git a/lib/org-ruby/headline.rb b/lib/org-ruby/headline.rb index c4761b6..6152063 100644 --- a/lib/org-ruby/headline.rb +++ b/lib/org-ruby/headline.rb @@ -45,14 +45,15 @@ class Headline < Line # This matches a headline marked as COMMENT CommentHeadlineRegexp = /^COMMENT\s+/ - def initialize(line, parser = nil, offset=0) + def initialize(line, parser = nil, offset = 0) super(line, parser) @body_lines = [] @tags = [] @export_state = :exclude @property_drawer = { } if (@line =~ LineRegexp) then - @level = $&.strip.length + offset + new_offset = (parser && parser.title?) ? offset + 1 : offset + @level = $&.strip.length + new_offset @headline_text = $'.strip if (@headline_text =~ TagsRegexp) then @tags = $&.split(/:/) # split tag text on semicolon @@ -88,6 +89,11 @@ def paragraph_type :"heading#{@level}" end + def headline_level + title_offset = (parser && parser.title?) ? 1 : 0 + level - title_offset + end + ###################################################################### private diff --git a/lib/org-ruby/highlighter.rb b/lib/org-ruby/highlighter.rb new file mode 100644 index 0000000..91fe0d4 --- /dev/null +++ b/lib/org-ruby/highlighter.rb @@ -0,0 +1,61 @@ +module Orgmode + # Highlight code + module Highlighter + def self.highlight(code, lang) + highlighter = guess_highlighter + highlighter.highlight(code, lang) + end + + def self.guess_highlighter + return RougeHighliter if gem_present?('rouge') + return PygmentsHighliter if gem_present?('pygments.rb') + return CodeRayHighliter if gem_present?('coderay') + + DefaultHighliter + end + + def self.gem_present?(gem) + Gem::Specification.find_all_by_name(gem).any? + end + + # Default highliter does nothing to code + class DefaultHighliter + def self.highlight(buffer, _lang) + buffer + end + end + + # Pygments wrapper + class PygmentsHighliter + def self.highlight(buffer, lang) + require 'pygments' + if Pygments::Lexer.find_by_alias(lang) + Pygments.highlight(buffer, lexer: lang) + else + Pygments.highlight(buffer, lexer: 'text') + end + end + end + + # CodeRay wrapper + class CodeRayHighliter + def self.highlight(buffer, lang) + require 'coderay' + CodeRay.scan(buffer, lang).html(wrap: nil, css: :style) + rescue ArgumentError => _e + CodeRay.scan(buffer, 'text').html(wrap: nil, css: :style) + end + end + + # Rouge wrapper + class RougeHighliter + def self.highlight(buffer, lang) + require 'rouge' + formatter = Rouge::Formatters::HTMLLegacy.new + lexer = Rouge::Lexer.find_fancy(lang, buffer) || + Rouge::Lexers::PlainText + formatter.format(lexer.lex(buffer.strip)) + end + end + end +end diff --git a/lib/org-ruby/html_output_buffer.rb b/lib/org-ruby/html_output_buffer.rb index 180bd80..42d98df 100644 --- a/lib/org-ruby/html_output_buffer.rb +++ b/lib/org-ruby/html_output_buffer.rb @@ -1,7 +1,7 @@ -module Orgmode +require_relative './highlighter.rb' +module Orgmode class HtmlOutputBuffer < OutputBuffer - HtmlBlockTag = { :paragraph => "p", :ordered_list => "ol", @@ -30,159 +30,132 @@ class HtmlOutputBuffer < OutputBuffer def initialize(output, opts = {}) super(output) - @buffer_tag = "HTML" @options = opts @new_paragraph = :start @footnotes = {} @unclosed_tags = [] - @logger.debug "HTML export options: #{@options.inspect}" - @custom_blocktags = {} if @options[:markup_file] - - unless @options[:skip_syntax_highlight] - begin - require 'pygments' - rescue LoadError - # Pygments is not supported so we try instead with CodeRay - begin - require 'coderay' - rescue LoadError - # No code syntax highlighting - end - end - end - if @options[:markup_file] - do_custom_markup - end + # move from output_buffer + @code_block_indent = nil + + do_custom_markup + end + + def buffer_tag + 'HTML' end # Output buffer is entering a new mode. Use this opportunity to # write out one of the block tags in the HtmlBlockTag constant to # put this information in the HTML stream. def push_mode(mode, indent, properties={}) - @logger.debug "Properties: #{properties}" super(mode, indent, properties) - if HtmlBlockTag[mode] - unless ((mode_is_table?(mode) and skip_tables?) or - (mode == :src and !@options[:skip_syntax_highlight] and defined? Pygments)) - css_class = case - when (mode == :src and @block_lang.empty?) - " class=\"src\"" - when (mode == :src and not @block_lang.empty?) - " class=\"src\" lang=\"#{@block_lang}\"" - when (mode == :example || mode == :inline_example) - " class=\"example\"" - when mode == :center - " style=\"text-align: center\"" - when @options[:decorate_title] - " class=\"title\"" - end - add_paragraph unless @new_paragraph == :start - @new_paragraph = true - - @logger.debug "#{mode}: <#{HtmlBlockTag[mode]}#{css_class}>" - # Check to see if we need to restart numbering from a - # previous interrupted li - if mode_is_ol?(mode) && properties.key?(HtmlBlockTag[:list_item]) - @output << "<#{HtmlBlockTag[mode]} start=#{properties[HtmlBlockTag[:list_item]]}#{css_class}>" - else - @output << "<#{HtmlBlockTag[mode]}#{css_class}>" - end - # Entering a new mode obliterates the title decoration - @options[:decorate_title] = nil - end + return unless html_tags.include?(mode) + return if skip_css?(mode) + css_class = get_css_attr(mode) + push_indentation(@new_paragraph != :start) + + html_tag = HtmlBlockTag[mode] + # Check to see if we need to restart numbering from a + # previous interrupted li + if restart_numbering?(mode, properties) + list_item_tag = HtmlBlockTag[:list_item] + start = properties[list_item_tag] + @output << "<#{html_tag} start=#{start}#{css_class}>" + else + @output << "<#{html_tag}#{css_class}>" end + # Entering a new mode obliterates the title decoration + @options[:decorate_title] = nil + end + + def restart_numbering?(mode, properties) + mode_is_ol?(mode) && properties.key?(HtmlBlockTag[:list_item]) + end + + def table?(mode) + %i[table table_row table_separator table_header].include?(mode) + end + + def src?(mode) + %i[src].include?(mode) + end + + def skip_syntax_highlight? + !options[:skip_syntax_highlight] + end + + def push_indentation(condition) + indent = " " * indentation_level + condition && @output.concat("\n", indent) + @new_paragraph = true + end + + def html_tags + HtmlBlockTag.keys + end + + def skip_css?(mode) + (table?(mode) && skip_tables?) || + (src?(mode) && skip_syntax_highlight?) end # We are leaving a mode. Close any tags that were opened when # entering this mode. def pop_mode(mode = nil) m = super(mode) - if HtmlBlockTag[m] - unless ((mode_is_table?(m) and skip_tables?) or - (m == :src and !@options[:skip_syntax_highlight] and defined? Pygments)) - add_paragraph if @new_paragraph - @new_paragraph = true - @logger.debug "" - @output << "" - end - end - @list_indent_stack.pop + return list_indent_stack.pop unless html_tags.include?(m) + return list_indent_stack.pop if skip_css?(m) + push_indentation(@new_paragraph) + @output.concat("") + list_indent_stack.pop + end + + def highlight(code, lang) + Highlighter.highlight(code, lang) end def flush! return false if @buffer.empty? - case - when preserve_whitespace? - strip_code_block! if mode_is_code? current_mode + return @buffer = "" if (mode_is_table?(current_mode) && skip_tables?) - # NOTE: CodeRay and Pygments already escape the html once, so - # no need to escapeHTML - case - when (current_mode == :src and @options[:skip_syntax_highlight]) - @buffer = escapeHTML @buffer - when (current_mode == :src and defined? Pygments) - lang = normalize_lang @block_lang - @output << "\n" unless @new_paragraph == :start - @new_paragraph = true + if preserve_whitespace? + strip_code_block! if mode_is_code? current_mode - begin - @buffer = Pygments.highlight(@buffer, :lexer => lang) - rescue - # Not supported lexer from Pygments, we fallback on using the text lexer - @buffer = Pygments.highlight(@buffer, :lexer => 'text') - end - when (current_mode == :src and defined? CodeRay) - lang = normalize_lang @block_lang - - # CodeRay might throw a warning when unsupported lang is set, - # then fallback to using the text lexer - silence_warnings do - begin - @buffer = CodeRay.scan(@buffer, lang).html(:wrap => nil, :css => :style) - rescue ArgumentError - @buffer = CodeRay.scan(@buffer, 'text').html(:wrap => nil, :css => :style) - end - end - when (current_mode == :html or current_mode == :raw_text) - @buffer.gsub!(/\A\n/, "") if @new_paragraph == :start - @new_paragraph = true + if (current_mode == :src) + highlight_html_buffer else - # *NOTE* Don't use escape_string! through its sensitivity to @@html:@@ forms - @buffer = escapeHTML @buffer + if (current_mode == :html || current_mode == :raw_text) + remove_new_lines_in_buffer(@new_paragraph == :start) + else + @buffer = escapeHTML @buffer + end end # Whitespace is significant in :code mode. Always output the # buffer and do not do any additional translation. - @logger.debug "FLUSH CODE ==========> #{@buffer.inspect}" @output << @buffer - - when (mode_is_table? current_mode and skip_tables?) - @logger.debug "SKIP ==========> #{current_mode}" - else @buffer.lstrip! @new_paragraph = nil - @logger.debug "FLUSH ==========> #{current_mode}" - - case current_mode - when :definition_term + if (current_mode == :definition_term) d = @buffer.split(/\A(.*[ \t]+|)::(|[ \t]+.*?)$/, 4) - d[1] = d[1].strip - unless d[1].empty? - @output << inline_formatting(d[1]) - else + + definition = d[1].strip + if definition.empty? @output << "???" + else + @output << inline_formatting(definition) end - indent = @list_indent_stack.last + indent = list_indent_stack.last pop_mode @new_paragraph = :start push_mode(:definition_descr, indent) - @output << inline_formatting(d[2].strip + d[3]) + @output.concat inline_formatting(d[2].strip + d[3]) @new_paragraph = nil + elsif (current_mode == :horizontal_rule) - when :horizontal_rule add_paragraph unless @new_paragraph == :start @new_paragraph = true @output << "
" @@ -194,25 +167,66 @@ def flush! @buffer = "" end - def add_line_attributes headline - if @options[:export_heading_number] then + # Flush! helping methods + def highlight_html_buffer + if skip_syntax_hightlight? + @buffer = escapeHTML @buffer + else + lang = normalize_lang @block_lang + @buffer = highlight(@buffer, lang) + end + end + + def skip_syntax_hightlight? + current_mode == :src && options[:skip_syntax_highlight] + end + + def remove_new_lines_in_buffer(condition) + return unless %i[html raw_text].include?(current_mode) + + condition && @buffer.gsub!(/\A\n/, "") + @new_paragraph = true + end + #flush helpers ends here. + + + def add_line_attributes(headline) + if @options[:export_heading_number] level = headline.level - heading_number = get_next_headline_number(level) + headline_level = headline.headline_level + heading_number = get_next_headline_number(headline_level) @output << "#{heading_number} " end - if @options[:export_todo] and headline.keyword then + if @options[:export_todo] and headline.keyword keyword = headline.keyword @output << "#{keyword} " end end + def html_buffer_code_block_indent(line) + if mode_is_code?(current_mode) && !(line.block_type) + # Determines the amount of whitespaces to be stripped at the + # beginning of each line in code block. + if line.paragraph_type != :blank + if @code_block_indent + @code_block_indent = [@code_block_indent, line.indent].min + else + @code_block_indent = line.indent + end + end + end + end + + + # Only footnotes defined in the footnote (i.e., [fn:0:this is the footnote definition]) + # will be automatically + # added to a separate Footnotes section at the end of the document. All footnotes that are + # defined separately from their references will be rendered where they appear in the original + # Org document. def output_footnotes! - # Only footnotes defined in the footnote (i.e., [fn:0:this is the footnote definition]) will be automatically - # added to a separate Footnotes section at the end of the document. All footnotes that are defined separately - # from their references will be rendered where they appear in the original Org document. - return false unless @options[:export_footnotes] and not @footnotes.empty? + return false if !options[:export_footnotes] || @footnotes.empty? - @output << "\n
\n

Footnotes:

\n
\n" + @output.concat footnotes_header @footnotes.each do |name, (defi, content)| @buffer = defi @output << "
#{name}" \ @@ -221,21 +235,67 @@ def output_footnotes! << "

\n" end - @output << "
\n
" + @output.concat "\n" + + true + end - return true + def footnotes_header + footnotes_title = options[:footnotes_title] || "Footnotes:" + "\n
\n

#{footnotes_title}

\n
\n" end # Test if we're in an output mode in which whitespace is significant. def preserve_whitespace? - super or current_mode == :html + super || current_mode == :html + end + + protected + + def do_custom_markup + file = options[:markup_file] + return unless file + return no_custom_markup_file_exists unless File.exists?(file) + + @custom_blocktags = load_custom_markup(file) + @custom_blocktags.empty? && no_valid_markup_found || + set_custom_markup + end + + def load_custom_markup(file) + require 'yaml' + if (self.class.to_s == 'Orgmode::MarkdownOutputBuffer') + filter = '^MarkdownMap$' + else + filter = '^HtmlBlockTag$|^Tags$' + end + @custom_blocktags = YAML.load_file(@options[:markup_file]).select {|k| k.to_s.match(filter) } end + + ###################################################################### private + def get_css_attr(mode) + case + when (mode == :src and block_lang.empty?) + " class=\"src\"" + when (mode == :src and not block_lang.empty?) + " class=\"src\" lang=\"#{block_lang}\"" + when (mode == :example || mode == :inline_example) + " class=\"example\"" + when mode == :center + " style=\"text-align: center\"" + when @options[:decorate_title] + " class=\"title\"" + when @options[:ltr] + " dir=\"auto\"" + end + end + def skip_tables? - @options[:skip_tables] + options[:skip_tables] end def mode_is_table?(mode) @@ -261,18 +321,17 @@ def escape_string! str str.gsub! /@@html:(<[^<>\n]*>)@@/, "\\1" end - def quote_tags str + def quote_tags(str) str.gsub /(<[^<>\n]*>)/, "@@html:\\1@@" end def buffer_indentation - indent = " " * @list_indent_stack.length - @buffer << indent + " " * list_indent_stack.length end def add_paragraph - indent = " " * (@list_indent_stack.length - 1) - @output << "\n" << indent + indent = " " * (list_indent_stack.length - 1) + @output.concat "\n#{indent}" end Tags = { @@ -287,12 +346,12 @@ def add_paragraph # Applies inline formatting rules to a string. def inline_formatting(str) - @re_help.rewrite_emphasis str do |marker, s| - if marker == "=" or marker == "~" - s = escapeHTML s - "<#{Tags[marker][:open]}>#{s}" + @re_help.rewrite_emphasis(str) do |marker, text| + if marker == "=" || marker == "~" + escaped_text = escapeHTML(text) + "<#{Tags[marker][:open]}>#{escaped_text}" else - quote_tags("<#{Tags[marker][:open]}>") + s + + quote_tags("<#{Tags[marker][:open]}>") + text + quote_tags("") end end @@ -403,6 +462,8 @@ def strip_code_block! end end + private + # The CGI::escapeHTML function backported from the Ruby standard library # as of commit fd2fc885b43283aa3d76820b2dfa9de19a77012f # @@ -417,14 +478,14 @@ def strip_code_block! '&' => '&', '"' => '"', '<' => '<', - '>' => '>', - } + '>' => '>' + }.freeze + # Escape special characters in HTML, namely &\"<> # escapeHTML('Usage: foo "bar" ') # # => "Usage: foo "bar" <baz>" - private def escapeHTML(string) - string.gsub(/['&\"<>]/, TABLE_FOR_ESCAPE_HTML__) + string.gsub(/['&"<>]/, TABLE_FOR_ESCAPE_HTML__) end - end # class HtmlOutputBuffer -end # module Orgmode + end +end diff --git a/lib/org-ruby/line.rb b/lib/org-ruby/line.rb index 9fc5b5b..e7fd32b 100644 --- a/lib/org-ruby/line.rb +++ b/lib/org-ruby/line.rb @@ -232,22 +232,14 @@ def block_header_arguments # TODO: COMMENT block should be considered here def block_should_be_exported? export_state = block_header_arguments[':exports'] - case - when ['both', 'code', nil, ''].include?(export_state) - true - when ['none', 'results'].include?(export_state) - false - end + ['both', 'code', nil, ''].include?(export_state) || + !['none', 'results'].include?(export_state) end def results_block_should_be_exported? export_state = block_header_arguments[':exports'] - case - when ['results', 'both'].include?(export_state) - true - when ['code', 'none', nil, ''].include?(export_state) - false - end + ['results', 'both'].include?(export_state) || + !['code', 'none', nil, ''].include?(export_state) end InlineExampleRegexp = /^\s*:\s/ diff --git a/lib/org-ruby/output_buffer.rb b/lib/org-ruby/output_buffer.rb index 90a0aae..3f6e35d 100644 --- a/lib/org-ruby/output_buffer.rb +++ b/lib/org-ruby/output_buffer.rb @@ -1,18 +1,16 @@ require 'logger' module Orgmode - # The OutputBuffer is used to accumulate multiple lines of orgmode # text, and then emit them to the output all in one go. The class # will do the final textile substitution for inline formatting and # add a newline character prior emitting the output. class OutputBuffer - # This is the overall output buffer - attr_reader :output + attr_reader :output, :mode_stack, :list_indent_stack # This is the current type of output being accumulated. - attr_accessor :output_type + attr_accessor :output_type, :headline_number_stack # Creates a new OutputBuffer object that is bound to an output object. # The output will get flushed to =output=. @@ -30,39 +28,28 @@ def initialize(output) @output_type = :start @list_indent_stack = [] @mode_stack = [] - @code_block_indent = nil - - @logger = Logger.new(STDERR) - if ENV['DEBUG'] or $DEBUG - @logger.level = Logger::DEBUG - else - @logger.level = Logger::WARN - end + # regexp module @re_help = RegexpHelper.new + @logger = Logger.new(STDERR) + @logger.level = Logger::INFO end def current_mode - @mode_stack.last + mode_stack.last end - - def push_mode(mode, indent, properties={}) - @mode_stack.push(mode) - @list_indent_stack.push(indent) + def push_mode(mode, indent, _properties = {}) + mode_stack.push(mode) + # Here seem that inherit buffers do their magic. + list_indent_stack.push(indent) end - def pop_mode(mode = nil) - m = @mode_stack.pop - @logger.warn "Modes don't match. Expected to pop #{mode}, but popped #{m}" if mode && mode != m - m + def pop_mode(_mode = nil) + mode_stack.pop end def insert(line) - # Prepares the output buffer to receive content from a line. - # As a side effect, this may flush the current accumulated text. - @logger.debug "Looking at #{line.paragraph_type}|#{line.assigned_paragraph_type}(#{current_mode}) : #{line.to_s}" - # We try to get the lang from #+BEGIN_SRC blocks @block_lang = line.block_lang if line.begin_block? unless should_accumulate_output?(line) @@ -70,60 +57,66 @@ def insert(line) maintain_mode_stack(line) end + @buffer.concat(line_get_content(line)) + html_buffer_code_block_indent(line) + @output_type = line.assigned_paragraph_type || line.paragraph_type + end + # Insert line Helpers + + # This is a line method + def line_get_content(line) # Adds the current line to the output buffer case - when line.assigned_paragraph_type == :comment + when skip_buffer(line) # Don't add to buffer + '' when line.title? - @buffer << line.output_text - when line.raw_text? - @buffer << "\n" << line.output_text if line.raw_text_tag == @buffer_tag - when preserve_whitespace? - @buffer << "\n" << line.output_text unless line.block_type + line.output_text + when line.raw_text? && line.raw_text_tag != buffer_tag + '' + when line.raw_text? && line.raw_text_tag == buffer_tag + "\n#{line.output_text}" + when preserve_whitespace? && line.block_type + '' + when preserve_whitespace? && !line.block_type + "\n#{line.output_text}" when line.assigned_paragraph_type == :code # If the line is contained within a code block but we should # not preserve whitespaces, then we do nothing. - when (line.kind_of? Headline) - add_line_attributes line - @buffer << "\n" << line.output_text.strip - when ([:definition_term, :list_item, :table_row, :table_header, - :horizontal_rule].include? line.paragraph_type) - @buffer << "\n" << line.output_text.strip + '' + when line.is_a?(Headline) + add_line_attributes(line) + "\n#{line.output_text.strip}" + + when %i[definition_term list_item table_row table_header + horizontal_rule].include?(line.paragraph_type) + "\n#{line.output_text.strip}" when line.paragraph_type == :paragraph - @buffer << "\n" - buffer_indentation - @buffer << line.output_text.strip + "\n""#{buffer_indentation}#{line.output_text.strip}" + else '' end + end - if mode_is_code? current_mode and not line.block_type - # Determines the amount of whitespaces to be stripped at the - # beginning of each line in code block. - if line.paragraph_type != :blank - if @code_block_indent - @code_block_indent = [@code_block_indent, line.indent].min - else - @code_block_indent = line.indent - end - end - end + def skip_buffer(line) + line.assigned_paragraph_type == :comment + end - @output_type = line.assigned_paragraph_type || line.paragraph_type + def html_buffer_code_block_indent(line) + # this is implemented in html output buffer only end + # Insert helpers end here. # Gets the next headline number for a given level. The intent is # this function is called sequentially for each headline that # needs to get numbered. It does standard outline numbering. def get_next_headline_number(level) raise "Headline level not valid: #{level}" if level <= 0 - while level > @headline_number_stack.length do - @headline_number_stack.push 0 - end - while level < @headline_number_stack.length do - @headline_number_stack.pop - end - raise "Oops, shouldn't happen" unless level == @headline_number_stack.length - @headline_number_stack[@headline_number_stack.length - 1] += 1 - @headline_number_stack.join(".") + + @headline_number_stack.push(0) while level > @headline_number_stack.length + @headline_number_stack.pop while level < @headline_number_stack.length + + @headline_number_stack[level - 1] += 1 + @headline_number_stack.join('.') end # Gets the current list indent level. @@ -133,11 +126,11 @@ def list_indent_level # Test if we're in an output mode in which whitespace is significant. def preserve_whitespace? - [:example, :inline_example, :raw_text, :src].include? current_mode + %i[example inline_example raw_text src].include? current_mode end def do_custom_markup - if File.exists? @options[:markup_file] + if File.exist?(@options[:markup_file]) load_custom_markup if @custom_blocktags.empty? no_valid_markup_found @@ -151,74 +144,87 @@ def do_custom_markup def load_custom_markup require 'yaml' - self.class.to_s == 'Orgmode::MarkdownOutputBuffer' ? filter = '^MarkdownMap$' : filter = '^HtmlBlockTag$|^Tags$' - @custom_blocktags = YAML.load_file(@options[:markup_file]).select {|k| k.to_s.match(filter) } + filter = if self.class.to_s == 'Orgmode::MarkdownOutputBuffer' + '^MarkdownMap$' + else + '^HtmlBlockTag$|^Tags$' + end + @custom_blocktags = YAML.load_file(@options[:markup_file]).select do |k| + k.to_s.match(filter) + end end def set_custom_markup - @custom_blocktags.keys.each do |k| - @custom_blocktags[k].each {|key,v| self.class.const_get(k.to_s)[key] = v if self.class.const_get(k.to_s).key? key} + @custom_blocktags.each_key do |k| + @custom_blocktags[k].each do |key, v| + self.class.const_get(k.to_s)[key] = v if self.class.const_get(k.to_s).key?(key) + end end end def no_valid_markup_found - self.class.to_s == 'Orgmode::MarkdownOutputBuffer' ? tags = 'MarkdownMap' : tags = 'HtmlBlockTag or Tags' - @logger.debug "Setting Custom Markup failed. No #{tags} key where found in: #{@options[:markup_file]}." - @logger.debug "Continuing export with default markup." + self.class.to_s == 'Orgmode::MarkdownOutputBuffer' ? 'MarkdownMap' : 'HtmlBlockTag or Tags' end def no_custom_markup_file_exists - @logger.debug "Setting Custom Markup failed. No such file exists: #{@options[:markup_file]}." - @logger.debug "Continuing export with default tags." + nil + end + + protected + + attr_reader :block_lang + + def indentation_level + list_indent_stack.length - 1 + end + + # Implemented only in HtmlOutputBuffer + def buffer_tag + # raise NoImplementedError 'implemnt this in your output buffer' + nil end - ###################################################################### private def mode_is_heading?(mode) - [:heading1, :heading2, :heading3, - :heading4, :heading5, :heading6].include? mode + %i[heading1 heading2 heading3 heading4 heading5 heading6].include?(mode) end def mode_is_block?(mode) - [:quote, :center, :example, :src].include? mode + %i[quote center example src].include?(mode) end def mode_is_code?(mode) - [:example, :src].include? mode + %i[example src].include?(mode) end def boundary_of_block?(line) # Boundary of inline example - return true if ((line.paragraph_type == :inline_example) ^ - (@output_type == :inline_example)) - # Boundary of begin...end block - return true if mode_is_block? @output_type + ((line.paragraph_type == :inline_example) ^ (@output_type == :inline_example)) || + # Boundary of begin...end block + mode_is_block?(@output_type) end def maintain_mode_stack(line) # Always close the following lines - pop_mode if (mode_is_heading? current_mode or - current_mode == :paragraph or - current_mode == :horizontal_rule or - current_mode == :inline_example or + pop_mode if (mode_is_heading?(current_mode) || + current_mode == :paragraph || + current_mode == :horizontal_rule || + current_mode == :inline_example || current_mode == :raw_text) # End-block line closes every mode within block - if line.end_block? and @mode_stack.include? line.paragraph_type + if line.end_block? && @mode_stack.include?(line.paragraph_type) pop_mode until current_mode == line.paragraph_type end - if ((not line.paragraph_type == :blank) or - @output_type == :blank) + if line.paragraph_type != :blank || @output_type == :blank # Close previous tags on demand. Two blank lines close all tags. - while ((not @list_indent_stack.empty?) and - @list_indent_stack.last >= line.indent and - # Don't allow an arbitrary line to close block - (not mode_is_block? current_mode)) + while !@list_indent_stack.empty? && @list_indent_stack.last >= line.indent && + # Don't allow an arbitrary line to close block + !mode_is_block?(current_mode) # Item can't close its major mode - if (@list_indent_stack.last == line.indent and - line.major_mode == current_mode) + if @list_indent_stack.last == line.indent && line.major_mode == current_mode break else pop_mode @@ -227,14 +233,14 @@ def maintain_mode_stack(line) end # Special case: Only end-block line closes block - pop_mode if line.end_block? and line.paragraph_type == current_mode + pop_mode if line.end_block? && line.paragraph_type == current_mode - unless line.paragraph_type == :blank or line.assigned_paragraph_type == :comment - if (@list_indent_stack.empty? or - @list_indent_stack.last <= line.indent or - mode_is_block? current_mode) + unless line.paragraph_type == :blank || line.assigned_paragraph_type == :comment + if (@list_indent_stack.empty? || + @list_indent_stack.last <= line.indent || + mode_is_block?(current_mode)) # Opens the major mode of line if it exists - if @list_indent_stack.last != line.indent or mode_is_block? current_mode + if @list_indent_stack.last != line.indent || mode_is_block?(current_mode) push_mode(line.major_mode, line.indent, line.properties) if line.major_mode end # Opens tag that precedes text immediately @@ -244,32 +250,32 @@ def maintain_mode_stack(line) end end - def add_line_attributes headline + def add_line_attributes(headline) # Implemented by specific output buffers end def output_footnotes! - return false + false end # Tests if the current line should be accumulated in the current # output buffer. - def should_accumulate_output? line + def should_accumulate_output?(line) # Special case: Assign mode if not yet done. return false unless current_mode # Special case: Handles accumulating block content and example lines if mode_is_code? current_mode - return true unless (line.end_block? and + return true unless (line.end_block? && line.paragraph_type == current_mode) end return false if boundary_of_block? line return true if current_mode == :inline_example # Special case: Don't accumulate the following lines. - return false if (mode_is_heading? @output_type or - @output_type == :comment or - @output_type == :horizontal_rule or + return false if (mode_is_heading?(@output_type) || + @output_type == :comment || + @output_type == :horizontal_rule || @output_type == :raw_text) # Special case: Blank line at least splits paragraphs @@ -278,7 +284,7 @@ def should_accumulate_output? line if line.paragraph_type == :paragraph # Paragraph gets accumulated only if its indent level is # greater than the indent level of the previous mode. - if @mode_stack[-2] and not mode_is_block? @mode_stack[-2] + if @mode_stack[-2] && !mode_is_block?(@mode_stack[-2]) return false if line.indent <= @list_indent_stack[-2] end # Special case: Multiple "paragraphs" get accumulated. @@ -288,8 +294,10 @@ def should_accumulate_output? line false end - def buffer_indentation; false; end + def buffer_indentation + '' + end + def flush!; false; end - def output_footnotes!; false; end - end # class OutputBuffer -end # module Orgmode + end +end diff --git a/lib/org-ruby/parser.rb b/lib/org-ruby/parser.rb index a57fd9e..f9dc256 100644 --- a/lib/org-ruby/parser.rb +++ b/lib/org-ruby/parser.rb @@ -44,6 +44,7 @@ def export_select_tags # that subtree will not get exported. def export_exclude_tags return Array.new unless @in_buffer_settings["EXPORT_EXCLUDE_TAGS"] + @in_buffer_settings["EXPORT_EXCLUDE_TAGS"].split end @@ -79,28 +80,33 @@ def use_sub_superscripts? @options["^"] != "nil" end + # Support for left to right when buffer or parser option. + def left_to_right? + @options["ltr"] == 't' || @parser_options[:ltr] + end + + def initialize_lines(lines) + return lines if lines.is_a? Array + return lines.split("\n") if lines.is_a? String + + raise "Unsupported type for +lines+: #{lines.class}" + end + # I can construct a parser object either with an array of lines # or with a single string that I will split along \n boundaries. - def initialize(lines, parser_options={ }) - if lines.is_a? Array then - @lines = lines - elsif lines.is_a? String then - @lines = lines.split("\n") - else - raise "Unsupported type for +lines+: #{lines.class}" - end - + def initialize(lines, parser_options = {}) + @lines = initialize_lines lines @custom_keywords = [] - @headlines = Array.new + @headlines = [] @current_headline = nil @header_lines = [] - @in_buffer_settings = { } - @options = { } - @link_abbrevs = { } + @in_buffer_settings = {} + @options = {} + @link_abbrevs = {} @parser_options = parser_options # - # Include file feature disabled by default since + # Include file feature disabled by default since # it would be dangerous in some environments # # http://orgmode.org/manual/Include-files.html @@ -116,8 +122,8 @@ def initialize(lines, parser_options={ }) # e.g. Orgmode::Parser.new(org_text, { :allow_include_files => false }) # if @parser_options[:allow_include_files].nil? - if ENV['ORG_RUBY_ENABLE_INCLUDE_FILES'] == 'true' \ - or not ENV['ORG_RUBY_INCLUDE_ROOT'].nil? + if (ENV['ORG_RUBY_ENABLE_INCLUDE_FILES'] == 'true') \ + || !ENV['ORG_RUBY_INCLUDE_ROOT'].nil? @parser_options[:allow_include_files] = true end end @@ -129,17 +135,15 @@ def initialize(lines, parser_options={ }) # Check include file availability and permissions def check_include_file(file_path) - can_be_included = File.exists? file_path + can_be_included = File.exist? file_path - if not ENV['ORG_RUBY_INCLUDE_ROOT'].nil? + unless ENV['ORG_RUBY_INCLUDE_ROOT'].nil? # Ensure we have full paths root_path = File.expand_path ENV['ORG_RUBY_INCLUDE_ROOT'] file_path = File.expand_path file_path # Check if file is in the defined root path and really exists - if file_path.slice(0, root_path.length) != root_path - can_be_included = false - end + can_be_included = false if file_path.slice(0, root_path.length) != root_path end can_be_included @@ -153,10 +157,11 @@ def parse_lines(lines) line = Line.new text, self if @parser_options[:allow_include_files] - if line.include_file? and not line.include_file_path.nil? - next if not check_include_file line.include_file_path + if line.include_file? && !line.include_file_path.nil? + next unless check_include_file line.include_file_path + include_data = get_include_data line - include_lines = Orgmode::Parser.new(include_data, @parser_options).lines + include_lines = initialize_lines include_data parse_lines include_lines end end @@ -167,20 +172,20 @@ def parse_lines(lines) @link_abbrevs[link_abbrev_data[0]] = link_abbrev_data[1] end - mode = :normal if line.end_block? and [line.paragraph_type, :comment].include?(mode) - mode = :normal if line.property_drawer_end_block? and mode == :property_drawer + mode = :normal if line.end_block? && [line.paragraph_type, :comment].include?(mode) + mode = :normal if line.property_drawer_end_block? && (mode == :property_drawer) case mode when :normal, :quote, :center if Headline.headline? line.to_s line = Headline.new line.to_s, self, @parser_options[:offset] elsif line.table_separator? - if previous_line and previous_line.paragraph_type == :table_row and !table_header_set + if previous_line && (previous_line.paragraph_type == :table_row) && !table_header_set previous_line.assigned_paragraph_type = :table_header table_header_set = true end end - table_header_set = false if !line.table? + table_header_set = false unless line.table? when :example, :html, :src if previous_line @@ -211,15 +216,11 @@ def parse_lines(lines) # We treat the results code block differently since the exporting can be omitted if line.begin_block? - if line.results_block_should_be_exported? - @next_results_block_should_be_exported = true - else - @next_results_block_should_be_exported = false - end + @next_results_block_should_be_exported = line.results_block_should_be_exported? end end - if mode == :property_drawer and @current_headline + if (mode == :property_drawer) && @current_headline @current_headline.property_drawer[line.property_drawer_item.first] = line.property_drawer_item.last end @@ -245,14 +246,14 @@ def get_include_data(line) # Get options include_file_lines = line.include_file_options[1].gsub('"', '').split('-') include_file_lines[0] = include_file_lines[0].empty? ? 1 : include_file_lines[0].to_i - include_file_lines[1] = include_file_lines[1].to_i if !include_file_lines[1].nil? + include_file_lines[1] = include_file_lines[1].to_i unless include_file_lines[1].nil? # Extract request lines. Note that the second index is excluded, according to the doc line_index = 1 include_data = [] - File.open(line.include_file_path, "r") do |fd| + File.open(line.include_file_path, 'r') do |fd| while line_data = fd.gets - if (line_index >= include_file_lines[0] and (include_file_lines[1].nil? or line_index < include_file_lines[1])) + if (line_index >= include_file_lines[0]) && (include_file_lines[1].nil? || (line_index < include_file_lines[1])) include_data << line_data.chomp end line_index += 1 @@ -261,14 +262,14 @@ def get_include_data(line) when 'src', 'example', 'quote' # Prepare tags - begin_tag = '#+BEGIN_%s' % [line.include_file_options[0].upcase] - if line.include_file_options[0] == 'src' and !line.include_file_options[1].nil? + begin_tag = format('#+BEGIN_%s', line.include_file_options[0].upcase) + if (line.include_file_options[0] == 'src') && !line.include_file_options[1].nil? begin_tag += ' ' + line.include_file_options[1] end - end_tag = '#+END_%s' % [line.include_file_options[0].upcase] + end_tag = format('#+END_%s', line.include_file_options[0].upcase) # Get lines. Will be transformed into an array at processing - include_data = "%s\n%s\n%s" % [begin_tag, IO.read(line.include_file_path), end_tag] + include_data = format("%s\n%s\n%s", begin_tag, IO.read(line.include_file_path), end_tag) else include_data = [] @@ -286,22 +287,22 @@ def set_name_for_code_block(previous_line, line) def set_mode_for_results_block_contents(previous_line, line) if previous_line.start_of_results_code_block? \ - or previous_line.assigned_paragraph_type == :comment - unless @next_results_block_should_be_exported or line.paragraph_type == :blank + || (previous_line.assigned_paragraph_type == :comment) + unless @next_results_block_should_be_exported || (line.paragraph_type == :blank) line.assigned_paragraph_type = :comment end end end # Creates a new parser from the data in a given file - def self.load(fname, opts = {}) + def self.load(fname, _opts = {}) lines = IO.readlines(fname) - return self.new(lines, opts = {}) + new(lines, opts = {}) end # Saves the loaded orgmode file as a textile file. def to_textile - output = "" + output = '' output_buffer = TextileOutputBuffer.new(output) translate(@header_lines, output_buffer) @@ -315,14 +316,15 @@ def to_textile def to_markdown mark_trees_for_export export_options = { - :markup_file => @parser_options[:markup_file] + markup_file: @parser_options[:markup_file] } - output = "" + output = '' output_buffer = MarkdownOutputBuffer.new(output, export_options) translate(@header_lines, output_buffer) @headlines.each do |headline| next if headline.export_state == :exclude + case headline.export_state when :exclude # NOTHING @@ -339,32 +341,34 @@ def to_markdown def to_html mark_trees_for_export export_options = { - :decorate_title => @in_buffer_settings["TITLE"], - :export_heading_number => export_heading_number?, - :export_todo => export_todo?, - :use_sub_superscripts => use_sub_superscripts?, - :export_footnotes => export_footnotes?, - :link_abbrevs => @link_abbrevs, - :skip_syntax_highlight => @parser_options[:skip_syntax_highlight], - :markup_file => @parser_options[:markup_file] + decorate_title: in_buffer_settings['TITLE'], + export_heading_number: export_heading_number?, + export_todo: export_todo?, + use_sub_superscripts: use_sub_superscripts?, + export_footnotes: export_footnotes?, + link_abbrevs: @link_abbrevs, + skip_syntax_highlight: @parser_options[:skip_syntax_highlight], + markup_file: @parser_options[:markup_file], + footnotes_title: @parser_options[:footnotes_title], + ltr: left_to_right? } - export_options[:skip_tables] = true if not export_tables? - output = "" + export_options[:skip_tables] = true unless export_tables? + output = '' output_buffer = HtmlOutputBuffer.new(output, export_options) - if @in_buffer_settings["TITLE"] - + if title? # If we're given a new title, then just create a new line # for that title. - title = Line.new(@in_buffer_settings["TITLE"], self, :title) - translate([title], output_buffer) + title_line = Line.new(title, self, :title) + translate([title_line], output_buffer) end translate(@header_lines, output_buffer) unless skip_header_lines? # If we've output anything at all, remove the :decorate_title option. - export_options.delete(:decorate_title) if (output.length > 0) + export_options.delete(:decorate_title) if output.length > 0 @headlines.each do |headline| next if headline.export_state == :exclude + case headline.export_state when :exclude # NOTHING @@ -377,11 +381,20 @@ def to_html output << "\n" return output if @parser_options[:skip_rubypants_pass] - - rp = RubyPants.new(output) + + rp = RubyPants.new(output) rp.to_html end + # Hack note (another) + def title? + !in_buffer_settings['TITLE'].nil? + end + def title + in_buffer_settings['TITLE'] + end + #ends hack + ###################################################################### private @@ -408,18 +421,19 @@ def mark_trees_for_export # First pass: See if any headlines are explicitly selected @headlines.each do |headline| - ancestor_stack.pop while not ancestor_stack.empty? and headline.level <= ancestor_stack.last.level - if inherit_export_level and headline.level > inherit_export_level + ancestor_stack.pop while !ancestor_stack.empty? && + (headline.level <= ancestor_stack.last.level) + if inherit_export_level && (headline.level > inherit_export_level) headline.export_state = :all else inherit_export_level = nil headline.tags.each do |tag| - if (select.include? tag) then - marked_any = true - headline.export_state = :all - ancestor_stack.each { |a| a.export_state = :headline_only unless a.export_state == :all } - inherit_export_level = headline.level - end + next unless select.include? tag + + marked_any = true + headline.export_state = :all + ancestor_stack.each { |a| a.export_state = :headline_only unless a.export_state == :all } + inherit_export_level = headline.level end end ancestor_stack.push headline @@ -430,12 +444,12 @@ def mark_trees_for_export # Second pass. Look for things that should be excluded, and get rid of them. @headlines.each do |headline| - if inherit_export_level and headline.level > inherit_export_level + if inherit_export_level && (headline.level > inherit_export_level) headline.export_state = :exclude else inherit_export_level = nil headline.tags.each do |tag| - if (exclude.include? tag) then + if exclude.include? tag headline.export_state = :exclude inherit_export_level = headline.level end @@ -450,7 +464,7 @@ def mark_trees_for_export # Stores an in-buffer setting. def store_in_buffer_setting(key, value) - if key == "OPTIONS" + if key == 'OPTIONS' # Options are stored in a hash. Special-case. value.scan(/([^ ]*):((((\(.*\))))|([^ ])*)/) do |o, v| @@ -459,13 +473,14 @@ def store_in_buffer_setting(key, value) elsif key =~ /^(TODO|SEQ_TODO|TYP_TODO)$/ # Handle todo keywords specially. value.split.each do |keyword| - keyword.gsub!(/\(.*\)/, "") # Get rid of any parenthetical notes + keyword.gsub!(/\(.*\)/, '') # Get rid of any parenthetical notes keyword = Regexp.escape(keyword) - next if keyword == "\\|" # Special character in the todo format, not really a keyword + next if keyword == '\\|' # Special character in the todo format, not really a keyword + @custom_keywords << keyword end else - @in_buffer_settings[key] = value + in_buffer_settings[key] = value end end end # class Parser diff --git a/lib/org-ruby/regexp_helper.rb b/lib/org-ruby/regexp_helper.rb index 9606338..a5abaf7 100644 --- a/lib/org-ruby/regexp_helper.rb +++ b/lib/org-ruby/regexp_helper.rb @@ -40,33 +40,18 @@ class RegexpHelper # non-shy groups here, and don't allow newline here. # newline The maximum number of newlines allowed in an emphasis exp. - attr_reader :org_image_file_regexp - def initialize # Set up the emphasis regular expression. - @pre_emphasis = ' \t\(\'"\{' - @post_emphasis = '- \t\.,:!\?;\'"\)\}\\\\' - @border_forbidden = ' \t\r\n' - @body_regexp = '.*?' - @max_newlines = 1 - @body_regexp = "#{@body_regexp}" + - "(?:\\n#{@body_regexp}){0,#{@max_newlines}}" if @max_newlines > 0 - @markers = '\*\/_=~\+' @code_snippet_stack = [] @logger = Logger.new(STDERR) @logger.level = Logger::WARN - build_org_emphasis_regexp - build_org_link_regexp - @org_subp_regexp = /([_^])\{(.*?)\}/ - @org_footnote_regexp = /\[fn:(.+?)(:(.*))?\]/ - @org_footnote_def_regexp = /^\[fn:(.+?)(:(.*))?\]( (.+))?/ end # Finds all emphasis matches in a string. # Supply a block that will get the marker and body as parameters. def match_all(str) - str.scan(@org_emphasis_regexp) do |match| - yield $2, $3 + str.scan(org_emphasis_regexp) do |_match| + yield Regexp.last_match[2], Regexp.last_match[3] end end @@ -91,43 +76,42 @@ def match_all(str) # replace "*bold*", "/italic/", and "=code=", # respectively. (Clearly this sample string will use HTML-like # syntax, assuming +map+ is defined appropriately.) - def rewrite_emphasis str + def rewrite_emphasis(str) # escape the percent signs for safe restoring code snippets str.gsub!(/%/, "%%") format_str = "%s" - str.gsub! @org_emphasis_regexp do |match| - pre = $1 + str.gsub!(org_emphasis_regexp) do |_match| + pre = Regexp.last_match(1) # preserve the code snippet from further formatting - if $2 == "=" or $2 == "~" - inner = yield $2, $3 + inner = yield Regexp.last_match(2), Regexp.last_match(3) + if %w[= ~].include?(Regexp.last_match(2)) # code is not formatted, so turn to single percent signs inner.gsub!(/%%/, "%") @code_snippet_stack.push inner "#{pre}#{format_str}" else - inner = yield $2, $3 "#{pre}#{inner}" end end end # rewrite subscript and superscript (_{foo} and ^{bar}) - def rewrite_subp str # :yields: type ("_" for subscript and "^" for superscript), text - str.gsub! @org_subp_regexp do |match| - yield $1, $2 + def rewrite_subp(str) + str.gsub!(org_subp_regexp) do |_match| + yield Regexp.last_match(1), Regexp.last_match(2) end end # rewrite footnotes - def rewrite_footnote str # :yields: name, definition or nil - str.gsub! @org_footnote_regexp do |match| - yield $1, $3 + def rewrite_footnote(str) + str.gsub!(org_footnote_regexp) do |_match| + yield Regexp.last_match(1), Regexp.last_match(3) end end - def rewrite_footnote_definition str - str.gsub! @org_footnote_def_regexp do |match| - yield $1, $5 + def rewrite_footnote_definition(str) + str.gsub!(org_footnote_def_regexp) do |_match| + yield Regexp.last_match(1), Regexp.last_match(5) end end @@ -156,43 +140,76 @@ def rewrite_footnote_definition str # +http://www.hotmail.com+. In both cases, the block returns an # HTML-style link, and that is how things will get recorded in # +result+. - def rewrite_links str # :yields: link, text - str.gsub! @org_link_regexp do |match| - yield $1, $3 + def rewrite_links(str) + str.gsub!(org_link_regexp) do |_match| + yield Regexp.last_match['url'], Regexp.last_match['friendly_text'] end - str.gsub! @org_angle_link_text_regexp do |match| - yield $1, nil + str.gsub!(org_angle_link_text_regexp) do |_match| + yield Regexp.last_match(1), nil end str # for testing end - def restore_code_snippets str + def restore_code_snippets(str) str = str % @code_snippet_stack @code_snippet_stack = [] str end + def org_emphasis_regexp + Regexp.new("(#{pre_emphasis_regexp})" \ + "(#{markers_regexp})" \ + "(#{border_forbidden}|" \ + "#{border_forbidden}#{body_regexp}" \ + "#{border_forbidden})\\2" \ + "(?=#{post_emphasis})") + end + + def org_link_regexp + /\[\[(?[^\[\]]+)\](\[(?[^\[\]]+)\])?\]/x + end + + def org_image_file_regexp + /\.(gif|jpe?g|p(?:bm|gm|n[gm]|pm)|svgz?|tiff?|x[bp]m)/i + end + private - def build_org_emphasis_regexp - @org_emphasis_regexp = Regexp.new("([#{@pre_emphasis}]|^)" + - "([#{@markers}])(?!\\2)" + - "([^#{@border_forbidden}]|" + - "[^#{@border_forbidden}]#{@body_regexp}" + - "[^#{@border_forbidden}])\\2" + - "(?=[#{@post_emphasis}]|$)") - @logger.debug "Just created regexp: #{@org_emphasis_regexp}" - end - - def build_org_link_regexp - @org_link_regexp = /\[\[ - ([^\]\[]+) # This is the URL - \](\[ - ([^\]\[]+) # This is the friendly text - \])?\]/x - @org_angle_link_text_regexp = /<(\w+:[^\]\s<>]+)>/ - @org_image_file_regexp = /\.(gif|jpe?g|p(?:bm|gm|n[gm]|pm)|svgz?|tiff?|x[bp]m)/i - end - end # class Emphasis -end # module Orgmode + def pre_emphasis_regexp + '^|\s|[\(\'"\{\[]' + end + + def markers_regexp + '[\*\/_=~\+]' + end + + def border_forbidden + '\S' + end + + def post_emphasis + '\s|[-,\.;:!\?\'"\)\}\]]|$' + end + + def body_regexp + '.*?(?:\\n.*?){0,1}' + end + + def org_subp_regexp + /([_^])\{(.*?)\}/ + end + + def org_footnote_regexp + /\[fn:(.+?)(:(.*))?\]/ + end + + def org_footnote_def_regexp + /^\[fn:(.+?)(:(.*))?\]( (.+))?/ + end + + def org_angle_link_text_regexp + /<(\w+:[^\]\s<>]+)>/ + end + end +end diff --git a/spec/html_code_syntax_highlight_examples/advanced-code-coderay.html b/spec/html_code_syntax_highlight_examples/advanced-code-coderay.html index f99dc7e..77689ff 100644 --- a/spec/html_code_syntax_highlight_examples/advanced-code-coderay.html +++ b/spec/html_code_syntax_highlight_examples/advanced-code-coderay.html @@ -1,6 +1,6 @@

advanced-code-coderay.org

Turns out there’s more way to do code than just BEGIN_EXAMPLE.

-

1 Inline examples

+

1 Inline examples

This should work:

   fixed width? how does this work?   
@@ -14,7 +14,7 @@ 

1 Inline examples

....

Two ASCII blobs.

-

2 BEGIN_SRC

+

2 BEGIN_SRC

And this:

 # Finds all emphasis matches in a string.
@@ -49,7 +49,7 @@ 

2 BEGIN_SRC

 echo 'Defaults env_keeps="http_proxy https_proxy ftp_proxy"' | sudo tee -a /etc/sudoers
 
-

3 It should be possible to write a colon at the beginning of an example

+

3 It should be possible to write a colon at the beginning of an example

I really love to write about :symbols. They sure are the @@ -69,12 +69,12 @@

3 It should be possible "1.0-SNAPSHOT"]] :main helloworld)

-

4 Code syntax highlight with Coderay

-

4.1 No language selected

+

4 Code syntax highlight with Coderay

+

4.1 No language selected

 Nothing to see here
 
-

4.2 CSS example

+

4.2 CSS example

 * {
  /* apply a natural box layout model to all elements */
@@ -83,7 +83,7 @@ 

4.2 CSS example

-webkit-box-sizing: border-box; }
-

4.3 HTML example

+

4.3 HTML example

 <html>
   <head>
@@ -94,7 +94,7 @@ 

4.3 HTML example

</body> </html>
-

4.4 Ruby example

+

4.4 Ruby example

 class Post << ActiveRecord::Base
   def print_title
@@ -102,14 +102,14 @@ 

4.4 Ruby example

end end
-

4.5 Python example

+

4.5 Python example

 import mapnik
 
 m = mapnik.Map(600, 800)
 m.background = Map.Color('steelblue')
 
-

4.6 Javascript example

+

4.6 Javascript example

 exports = this;
 
@@ -123,25 +123,25 @@ 

4.6 Javascript example< })(jQuery);

-

4.7 JSON example

+

4.7 JSON example

 { name: "Waldemar"
 , surname: "Quevedo"
 }
 
-

4.8 PHP example

+

4.8 PHP example

 echo "Hello";
 phpinfo();
 var_dump(some_var);
 
-

4.9 Elisp example

+

4.9 Elisp example

 (defun hello()
   (interactive)
   (message "hello"))
 
-

4.10 Not supported language example

+

4.10 Not supported language example

 !+!+++!++!++!++!+
 
diff --git a/spec/html_code_syntax_highlight_examples/advanced-code-no-color.html b/spec/html_code_syntax_highlight_examples/advanced-code-no-color.html index 2f04744..7c054e5 100644 --- a/spec/html_code_syntax_highlight_examples/advanced-code-no-color.html +++ b/spec/html_code_syntax_highlight_examples/advanced-code-no-color.html @@ -1,6 +1,6 @@

advanced-code.org

Turns out there’s more way to do code than just BEGIN_EXAMPLE.

-

1 Inline examples

+

1 Inline examples

This should work:

   fixed width? how does this work?   
@@ -14,7 +14,7 @@ 

1 Inline examples

....

Two ASCII blobs.

-

2 BEGIN_SRC

+

2 BEGIN_SRC

And this:

 # Finds all emphasis matches in a string.
@@ -49,7 +49,7 @@ 

2 BEGIN_SRC

 echo 'Defaults env_keeps="http_proxy https_proxy ftp_proxy"' | sudo tee -a /etc/sudoers
 
-

3 It should be possible to write a colon at the beginning of an example

+

3 It should be possible to write a colon at the beginning of an example

I really love to write about :symbols. They sure are the diff --git a/spec/html_code_syntax_highlight_examples/advanced-code-pygments.html b/spec/html_code_syntax_highlight_examples/advanced-code-pygments.html index 418616d..612b10c 100644 --- a/spec/html_code_syntax_highlight_examples/advanced-code-pygments.html +++ b/spec/html_code_syntax_highlight_examples/advanced-code-pygments.html @@ -1,6 +1,6 @@

advanced-code.org

Turns out there’s more way to do code than just BEGIN_EXAMPLE.

-

1 Inline examples

+

1 Inline examples

This should work:

   fixed width? how does this work?   
@@ -14,7 +14,7 @@ 

1 Inline examples

....

Two ASCII blobs.

-

2 BEGIN_SRC

+

2 BEGIN_SRC

And this:

# Finds all emphasis matches in a string.
 # Supply a block that will get the marker and body as parameters.
@@ -45,7 +45,7 @@ 

2 BEGIN_SRC

Even if no language is set, it is still wrapped in code tags but class is empty.

echo 'Defaults env_keeps="http_proxy https_proxy ftp_proxy"' | sudo tee -a /etc/sudoers
 
-

3 It should be possible to write a colon at the beginning of an example

+

3 It should be possible to write a colon at the beginning of an example

I really love to write about :symbols. They sure are the @@ -63,19 +63,19 @@

3 It should be possible "1.0-SNAPSHOT"]] :main helloworld)

-

4 Code syntax highlight with Pygments

-

4.1 No language selected

+

4 Code syntax highlight with Pygments

+

4.1 No language selected

<script>alert('hello world')</script>
 
-

4.2 CSS example

+

4.2 CSS example

* {
  /* apply a natural box layout model to all elements */
- box-sizing: border-box; 
- -moz-box-sizing: border-box; 
- -webkit-box-sizing: border-box; 
+ box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ -webkit-box-sizing: border-box;
 }
 
-

4.3 HTML example

+

4.3 HTML example

<html>
   <head>
     <title>Hello</title>
@@ -85,20 +85,20 @@ 

4.3 HTML example

</body> </html>
-

4.4 Ruby example

+

4.4 Ruby example

class Post << ActiveRecord::Base
   def print_title
     puts "#{self.title}"
   end
 end
 
-

4.5 Python example

+

4.5 Python example

import mapnik
 
 m = mapnik.Map(600, 800)
 m.background = Map.Color('steelblue')
 
-

4.6 Javascript example

+

4.6 Javascript example

exports = this;
 
 (function($){
@@ -111,21 +111,21 @@ 

4.6 Javascript example< })(jQuery);

-

4.7 JSON example

+

4.7 JSON example

{ name: "Waldemar"
 , surname: "Quevedo"
 }
 
-

4.8 PHP example

+

4.8 PHP example

echo "Hello";
 phpinfo();
 var_dump(some_var);
 
-

4.9 Elisp example

+

4.9 Elisp example

(defun hello()
   (interactive)
   (message "hello"))
 
-

4.10 Not supported language example

+

4.10 Not supported language example

!+!+++!++!++!++!+
 
diff --git a/spec/html_code_syntax_highlight_examples/code-block-exports-coderay.html b/spec/html_code_syntax_highlight_examples/code-block-exports-coderay.html index 2be28fc..4077573 100644 --- a/spec/html_code_syntax_highlight_examples/code-block-exports-coderay.html +++ b/spec/html_code_syntax_highlight_examples/code-block-exports-coderay.html @@ -1,7 +1,7 @@

Support for :exports options from code blocks

According to the Org mode docs, it is possible to customize whether the code block will be exported or not.

-

About the #+RESULTS: block

+

About the #+RESULTS: block

Using Org Babel features, it is possible to set :results output to a code block and render the results within a #+RESULTS: code block:

@@ -78,7 +78,7 @@ 

About the #+RESULTS: block

-

Default options

+

Default options

The default is to export only the code blocks.

The following is an code block written in Emacs Lisp and its result should not be exported.

@@ -93,7 +93,7 @@

Default options

-

:exports code

+

:exports code

Only the code would be in the output, the same as when no option is set.

@@ -110,13 +110,13 @@ 

:exports code

-

:exports none

+

:exports none

This omits both the resulting block, and the code block itself.

This should work as well when using an example block.

-

:exports both

+

:exports both

 Math::PI + 1
 
@@ -150,7 +150,7 @@

:exports both

block that was executed. This happens after 10 lines by default. -

:exports results

+

:exports results

This option can’t be completely supported by OrgRuby since we would have to eval the code block using :lang, so Org Babel features would have to be implemented as well.

diff --git a/spec/html_code_syntax_highlight_examples/code-block-exports-no-color.html b/spec/html_code_syntax_highlight_examples/code-block-exports-no-color.html index a2e10e4..27622fc 100644 --- a/spec/html_code_syntax_highlight_examples/code-block-exports-no-color.html +++ b/spec/html_code_syntax_highlight_examples/code-block-exports-no-color.html @@ -1,7 +1,7 @@

Support for :exports options from code blocks

According to the Org mode docs, it is possible to customize whether the code block will be exported or not.

-

About the #+RESULTS: block

+

About the #+RESULTS: block

Using Org Babel features, it is possible to set :results output to a code block and render the results within a #+RESULTS: code block:

@@ -78,7 +78,7 @@ 

About the #+RESULTS: block

-

Default options

+

Default options

The default is to export only the code blocks.

The following is an code block written in Emacs Lisp and its result should not be exported.

@@ -93,7 +93,7 @@

Default options

-

:exports code

+

:exports code

Only the code would be in the output, the same as when no option is set.

@@ -110,13 +110,13 @@ 

:exports code

-

:exports none

+

:exports none

This omits both the resulting block, and the code block itself.

This should work as well when using an example block.

-

:exports both

+

:exports both

 Math::PI + 1
 
@@ -150,7 +150,7 @@

:exports both

block that was executed. This happens after 10 lines by default. -

:exports results

+

:exports results

This option can’t be completely supported by OrgRuby since we would have to eval the code block using :lang, so Org Babel features would have to be implemented as well.

@@ -173,7 +173,7 @@

:exports results

any string any string -

When results are graphics…

+

When results are graphics…

A code block which is evaled within a Org mode buffer using Org babel features will have its results appear within another code block prepended with a #+RESULTS directive.

@@ -203,8 +203,8 @@

When results are graphics…

workflow.png

-

When blocks have a name, the results should be the same

-

exports code

+

When blocks have a name, the results should be the same

+

exports code

 var message = "Hello world!";
 
@@ -218,10 +218,10 @@ 

exports code

-

exports none

+

exports none

-

exports both

+

exports both

 Math::PI + 1
 
@@ -254,7 +254,7 @@

exports both

block that was executed. This happens after 10 lines by default. -

exports results

+

exports results

 3.141592653589793
 
diff --git a/spec/html_code_syntax_highlight_examples/code-block-exports-pygments.html b/spec/html_code_syntax_highlight_examples/code-block-exports-pygments.html index 0d7c101..d490721 100644 --- a/spec/html_code_syntax_highlight_examples/code-block-exports-pygments.html +++ b/spec/html_code_syntax_highlight_examples/code-block-exports-pygments.html @@ -1,7 +1,7 @@

Support for :exports options from code blocks

According to the Org mode docs, it is possible to customize whether the code block will be exported or not.

-

About the #+RESULTS: block

+

About the #+RESULTS: block

Using Org Babel features, it is possible to set :results output to a code block and render the results within a #+RESULTS: code block:

#+begin_src ruby :results output :exports both
@@ -74,7 +74,7 @@ 

About the #+RESULTS: block

-

Default options

+

Default options

The default is to export only the code blocks.

The following is an code block written in Emacs Lisp and its result should not be exported.

@@ -87,7 +87,7 @@

Default options

-

:exports code

+

:exports code

Only the code would be in the output, the same as when no option is set.

var message = "Hello world!";
@@ -102,13 +102,13 @@ 

:exports code

-

:exports none

+

:exports none

This omits both the resulting block, and the code block itself.

This should work as well when using an example block.

-

:exports both

+

:exports both

Math::PI + 1
 
@@ -140,7 +140,7 @@ 

:exports both

block that was executed. This happens after 10 lines by default.
-

:exports results

+

:exports results

This option can’t be completely supported by OrgRuby since we would have to eval the code block using :lang, so Org Babel features would have to be implemented as well.

diff --git a/spec/html_examples/custom-seq-todo.html b/spec/html_examples/custom-seq-todo.html index 1c3ced4..78e6070 100644 --- a/spec/html_examples/custom-seq-todo.html +++ b/spec/html_examples/custom-seq-todo.html @@ -2,18 +2,18 @@

custom-todo.org

I copied this todo sequence from Worg. It shows a lot of power of the built-in todo functionality. Now, let’s make sure all of these are recognized (and therefore NOT exported.)

-

TODO Sample

+

TODO Sample

-

INPROGRESS this one’s in progress

-

WAITING who am I waiting on?

-

DONE Finished this one!

-

CANCELED I gave up here.

-

DONT be fooled by just a random word in all caps.

-

todo <== this word doesn’t match because the case doesn’t match.

-

TODOX

+

INPROGRESS this one’s in progress

+

WAITING who am I waiting on?

+

DONE Finished this one!

+

CANCELED I gave up here.

+

DONT be fooled by just a random word in all caps.

+

todo <== this word doesn’t match because the case doesn’t match.

+

TODOX

don’t be fooled by the initial substring above!

diff --git a/spec/html_examples/custom-todo.html b/spec/html_examples/custom-todo.html index 1c3ced4..78e6070 100644 --- a/spec/html_examples/custom-todo.html +++ b/spec/html_examples/custom-todo.html @@ -2,18 +2,18 @@

custom-todo.org

I copied this todo sequence from Worg. It shows a lot of power of the built-in todo functionality. Now, let’s make sure all of these are recognized (and therefore NOT exported.)

-

TODO Sample

+

TODO Sample

-

INPROGRESS this one’s in progress

-

WAITING who am I waiting on?

-

DONE Finished this one!

-

CANCELED I gave up here.

-

DONT be fooled by just a random word in all caps.

-

todo <== this word doesn’t match because the case doesn’t match.

-

TODOX

+

INPROGRESS this one’s in progress

+

WAITING who am I waiting on?

+

DONE Finished this one!

+

CANCELED I gave up here.

+

DONT be fooled by just a random word in all caps.

+

todo <== this word doesn’t match because the case doesn’t match.

+

TODOX

don’t be fooled by the initial substring above!

diff --git a/spec/html_examples/custom-typ-todo.html b/spec/html_examples/custom-typ-todo.html index cf6d202..4b401b1 100644 --- a/spec/html_examples/custom-typ-todo.html +++ b/spec/html_examples/custom-typ-todo.html @@ -2,18 +2,18 @@

custom-typ-todo.org

I copied this todo sequence from Worg. It shows a lot of power of the built-in todo functionality. Now, let’s make sure all of these are recognized (and therefore NOT exported.)

-

TODO Sample

+

TODO Sample

-

INPROGRESS this one’s in progress

-

WAITING who am I waiting on?

-

DONE Finished this one!

-

CANCELED I gave up here.

-

DONT be fooled by just a random word in all caps.

-

todo <== this word doesn’t match because the case doesn’t match.

-

TODOX

+

INPROGRESS this one’s in progress

+

WAITING who am I waiting on?

+

DONE Finished this one!

+

CANCELED I gave up here.

+

DONT be fooled by just a random word in all caps.

+

todo <== this word doesn’t match because the case doesn’t match.

+

TODOX

don’t be fooled by the initial substring above!

diff --git a/spec/html_examples/deflist.html b/spec/html_examples/deflist.html index 2749b4b..880ed9d 100644 --- a/spec/html_examples/deflist.html +++ b/spec/html_examples/deflist.html @@ -4,17 +4,17 @@

Hallo

b
world

Text

-

Asterisk can be used for lists

+

Asterisk can be used for lists

One
The first number.
Two
The second number.
Three
The second number.
-

Corner cases of definition lists

+

Corner cases of definition lists

The following examples show how org-ruby behave when handling some cases of definition lists. (Many thanks to vonavi for his contributions here)

-

Definition List Items

+

Definition List Items

-

Not Definition List Items

+

Not Definition List Items

The following cases will not be considered as definition lists but just regular lists.

-

Definition List Item without Definition

+

Definition List Item without Definition

??? will be shown in this case

-

Definition List with markup inline

+

Definition List with markup inline

Description
bold
Description
italic
diff --git a/spec/html_examples/emphasis.html b/spec/html_examples/emphasis.html index f837428..a4bc464 100644 --- a/spec/html_examples/emphasis.html +++ b/spec/html_examples/emphasis.html @@ -1,4 +1,5 @@

Inline Formatting test for emphasis

+

Fix issue #48 ~/.bash and C-'

Simple feature test

bold

italic

diff --git a/spec/html_examples/emphasis.org b/spec/html_examples/emphasis.org index 5e06815..1421d71 100644 --- a/spec/html_examples/emphasis.org +++ b/spec/html_examples/emphasis.org @@ -1,4 +1,5 @@ * Inline Formatting test for emphasis +Fix issue [[https://github.com/wallyqs/org-ruby/issues/48][#48]] ~~/.bash~ and ~C-'~ ** Simple feature test *bold* @@ -9,7 +10,7 @@ ~verbatim~ -_underline_ +_underline_ +strikethrough+ @@ -231,112 +232,112 @@ end all.each {|e| puts e} #+end_example -*Starting the line here +*Starting the line here *and continuing here to close** -*Starting the line here +*Starting the line here /and continuing here to close/* -*Starting the line here +*Starting the line here =and continuing here to close=* -*Starting the line here +*Starting the line here ~and continuing here to close~* -*Starting the line here +*Starting the line here _and continuing here to close_* -*Starting the line here +*Starting the line here +and continuing here to close+* -/Starting the line here +/Starting the line here *and continuing here to close*/ -/Starting the line here +/Starting the line here /and continuing here to close// -/Starting the line here +/Starting the line here =and continuing here to close=/ -/Starting the line here +/Starting the line here ~and continuing here to close~/ -/Starting the line here +/Starting the line here _and continuing here to close_/ -/Starting the line here +/Starting the line here +and continuing here to close+/ -=Starting the line here +=Starting the line here *and continuing here to close*= -=Starting the line here +=Starting the line here /and continuing here to close/= -=Starting the line here +=Starting the line here =and continuing here to close== -=Starting the line here +=Starting the line here ~and continuing here to close~= -=Starting the line here +=Starting the line here _and continuing here to close_= -=Starting the line here +=Starting the line here +and continuing here to close+= -~Starting the line here +~Starting the line here *and continuing here to close*~ -~Starting the line here +~Starting the line here /and continuing here to close/~ -~Starting the line here +~Starting the line here =and continuing here to close=~ -~Starting the line here +~Starting the line here ~and continuing here to close~~ -~Starting the line here +~Starting the line here _and continuing here to close_~ -~Starting the line here +~Starting the line here +and continuing here to close+~ -_Starting the line here +_Starting the line here *and continuing here to close*_ -_Starting the line here +_Starting the line here /and continuing here to close/_ -_Starting the line here +_Starting the line here =and continuing here to close=_ -_Starting the line here +_Starting the line here ~and continuing here to close~_ -_Starting the line here +_Starting the line here _and continuing here to close__ -_Starting the line here +_Starting the line here +and continuing here to close+_ -+Starting the line here ++Starting the line here *and continuing here to close*+ -+Starting the line here ++Starting the line here /and continuing here to close/+ -+Starting the line here ++Starting the line here =and continuing here to close=+ -+Starting the line here ++Starting the line here ~and continuing here to close~+ -+Starting the line here ++Starting the line here _and continuing here to close_+ -+Starting the line here ++Starting the line here +and continuing here to close++ ** Multiline support test :: two lines @@ -353,147 +354,147 @@ end all.each {|e| puts e} #+end_example -*Starting the line here +*Starting the line here *and continuing here to close** -*Starting the line here +*Starting the line here /and continuing here to close/* -*Starting the line here +*Starting the line here =and continuing here to close=* -*Starting the line here +*Starting the line here ~and continuing here to close~* -*Starting the line here +*Starting the line here _and continuing here to close_* -*Starting the line here +*Starting the line here +and continuing here to close+* -/Starting the line here +/Starting the line here *and continuing here to close*/ -/Starting the line here +/Starting the line here /and continuing here to close// -/Starting the line here +/Starting the line here =and continuing here to close=/ -/Starting the line here +/Starting the line here ~and continuing here to close~/ -/Starting the line here +/Starting the line here _and continuing here to close_/ -/Starting the line here +/Starting the line here +and continuing here to close+/ -=Starting the line here +=Starting the line here *and continuing here to close*= -=Starting the line here +=Starting the line here /and continuing here to close/= -=Starting the line here +=Starting the line here =and continuing here to close== -=Starting the line here +=Starting the line here ~and continuing here to close~= -=Starting the line here +=Starting the line here _and continuing here to close_= -=Starting the line here +=Starting the line here +and continuing here to close+= -~Starting the line here +~Starting the line here *and continuing here to close*~ -~Starting the line here +~Starting the line here /and continuing here to close/~ -~Starting the line here +~Starting the line here =and continuing here to close=~ -~Starting the line here +~Starting the line here ~and continuing here to close~~ -~Starting the line here +~Starting the line here _and continuing here to close_~ -~Starting the line here +~Starting the line here +and continuing here to close+~ -_Starting the line here +_Starting the line here *and continuing here to close*_ -_Starting the line here +_Starting the line here /and continuing here to close/_ -_Starting the line here +_Starting the line here =and continuing here to close=_ -_Starting the line here +_Starting the line here ~and continuing here to close~_ -_Starting the line here +_Starting the line here _and continuing here to close__ -_Starting the line here +_Starting the line here +and continuing here to close+_ -+Starting the line here ++Starting the line here *and continuing here to close*+ -+Starting the line here ++Starting the line here /and continuing here to close/+ -+Starting the line here ++Starting the line here =and continuing here to close=+ -+Starting the line here ++Starting the line here ~and continuing here to close~+ -+Starting the line here ++Starting the line here _and continuing here to close_+ -+Starting the line here ++Starting the line here +and continuing here to close++ @@ -507,7 +508,7 @@ to close++ ~verbatim~ *bold* ~verbatim~ -_underline_ *bold* _underline_ +_underline_ *bold* _underline_ +strikethrough+ *bold* +strikethrough+ @@ -531,7 +532,7 @@ _underline_ *bold* _underline_ ~verbatim~ /italic/ ~verbatim~ -_underline_ /italic/ _underline_ +_underline_ /italic/ _underline_ +strikethrough+ /italic/ +strikethrough+ @@ -555,7 +556,7 @@ _underline_ /italic/ _underline_ ~verbatim~ =code= ~verbatim~ -_underline_ =code= _underline_ +_underline_ =code= _underline_ +strikethrough+ =code= +strikethrough+ @@ -579,7 +580,7 @@ _underline_ =code= _underline_ ~verbatim~ ~verbatim~ ~verbatim~ -_underline_ ~verbatim~ _underline_ +_underline_ ~verbatim~ _underline_ +strikethrough+ ~verbatim~ +strikethrough+ @@ -603,7 +604,7 @@ _underline_ ~verbatim~ _underline_ ~verbatim~ _underline_ ~verbatim~ -_underline_ _underline_ _underline_ +_underline_ _underline_ _underline_ +strikethrough+ _underline_ +strikethrough+ @@ -627,7 +628,7 @@ _underline_ _underline_ _underline_ ~verbatim~ +strikethrough+ ~verbatim~ -_underline_ +strikethrough+ _underline_ +_underline_ +strikethrough+ _underline_ +strikethrough+ +strikethrough+ +strikethrough+ @@ -651,7 +652,7 @@ _underline_ +strikethrough+ _underline_ ~verbatim~ [[http://www.bing.com]] ~verbatim~ -_underline_ [[http://www.bing.com]] _underline_ +_underline_ [[http://www.bing.com]] _underline_ +strikethrough+ [[http://www.bing.com]] +strikethrough+ @@ -675,7 +676,7 @@ _underline_ [[http://www.bing.com]] _underline_ ~verbatim~ [[http://www.google.com]] ~verbatim~ -_underline_ [[http://www.google.com]] _underline_ +_underline_ [[http://www.google.com]] _underline_ +strikethrough+ [[http://www.google.com]] +strikethrough+ @@ -699,7 +700,7 @@ _underline_ [[http://www.google.com]] _underline_ ~verbatim~ [[http://www.xkcd.com][helpful text link]] ~verbatim~ -_underline_ [[http://www.xkcd.com][helpful text link]] _underline_ +_underline_ [[http://www.xkcd.com][helpful text link]] _underline_ +strikethrough+ [[http://www.xkcd.com][helpful text link]] +strikethrough+ @@ -723,7 +724,7 @@ _underline_ [[http://www.xkcd.com][helpful text link]] _underline_ ~verbatim~ [[http://farm7.static.flickr.com/6078/6084185195_552aa270b2.jpg]] ~verbatim~ -_underline_ [[http://farm7.static.flickr.com/6078/6084185195_552aa270b2.jpg]] _underline_ +_underline_ [[http://farm7.static.flickr.com/6078/6084185195_552aa270b2.jpg]] _underline_ +strikethrough+ [[http://farm7.static.flickr.com/6078/6084185195_552aa270b2.jpg]] +strikethrough+ @@ -747,7 +748,7 @@ _underline_ [[http://farm7.static.flickr.com/6078/6084185195_552aa270b2.jpg]] _ ~verbatim~ [[http://www.xkcd.com][http://imgs.xkcd.com/comics/t_cells.png]] ~verbatim~ -_underline_ [[http://www.xkcd.com][http://imgs.xkcd.com/comics/t_cells.png]] _underline_ +_underline_ [[http://www.xkcd.com][http://imgs.xkcd.com/comics/t_cells.png]] _underline_ +strikethrough+ [[http://www.xkcd.com][http://imgs.xkcd.com/comics/t_cells.png]] +strikethrough+ @@ -771,7 +772,7 @@ _underline_ [[http://www.xkcd.com][http://imgs.xkcd.com/comics/t_cells.png]] _u ~verbatim~ ~verbatim~ -_underline_ _underline_ +_underline_ _underline_ +strikethrough+ +strikethrough+ @@ -801,4 +802,3 @@ _underline_ _underline_ | *bold* [[http://farm7.static.flickr.com/6078/6084185195_552aa270b2.jpg]] | /italic/ [[http://farm7.static.flickr.com/6078/6084185195_552aa270b2.jpg]] | =code= [[http://farm7.static.flickr.com/6078/6084185195_552aa270b2.jpg]] | ~verbatim~ [[http://farm7.static.flickr.com/6078/6084185195_552aa270b2.jpg]] | _underline_ [[http://farm7.static.flickr.com/6078/6084185195_552aa270b2.jpg]] | +strikethrough+ [[http://farm7.static.flickr.com/6078/6084185195_552aa270b2.jpg]] | [[http://www.bing.com]] [[http://farm7.static.flickr.com/6078/6084185195_552aa270b2.jpg]] | [[http://www.google.com]] [[http://farm7.static.flickr.com/6078/6084185195_552aa270b2.jpg]] | [[http://www.xkcd.com][helpful text link]] [[http://farm7.static.flickr.com/6078/6084185195_552aa270b2.jpg]] | [[http://farm7.static.flickr.com/6078/6084185195_552aa270b2.jpg]] [[http://farm7.static.flickr.com/6078/6084185195_552aa270b2.jpg]] | [[http://www.xkcd.com][http://imgs.xkcd.com/comics/t_cells.png]] [[http://farm7.static.flickr.com/6078/6084185195_552aa270b2.jpg]] | [[http://farm7.static.flickr.com/6078/6084185195_552aa270b2.jpg]] | | *bold* [[http://www.xkcd.com][http://imgs.xkcd.com/comics/t_cells.png]] | /italic/ [[http://www.xkcd.com][http://imgs.xkcd.com/comics/t_cells.png]] | =code= [[http://www.xkcd.com][http://imgs.xkcd.com/comics/t_cells.png]] | ~verbatim~ [[http://www.xkcd.com][http://imgs.xkcd.com/comics/t_cells.png]] | _underline_ [[http://www.xkcd.com][http://imgs.xkcd.com/comics/t_cells.png]] | +strikethrough+ [[http://www.xkcd.com][http://imgs.xkcd.com/comics/t_cells.png]] | [[http://www.bing.com]] [[http://www.xkcd.com][http://imgs.xkcd.com/comics/t_cells.png]] | [[http://www.google.com]] [[http://www.xkcd.com][http://imgs.xkcd.com/comics/t_cells.png]] | [[http://www.xkcd.com][helpful text link]] [[http://www.xkcd.com][http://imgs.xkcd.com/comics/t_cells.png]] | [[http://farm7.static.flickr.com/6078/6084185195_552aa270b2.jpg]] [[http://www.xkcd.com][http://imgs.xkcd.com/comics/t_cells.png]] | [[http://www.xkcd.com][http://imgs.xkcd.com/comics/t_cells.png]] [[http://www.xkcd.com][http://imgs.xkcd.com/comics/t_cells.png]] | [[http://www.xkcd.com][http://imgs.xkcd.com/comics/t_cells.png]] | | *bold* | /italic/ | =code= | ~verbatim~ | _underline_ | +strikethrough+ | [[http://www.bing.com]] | [[http://www.google.com]] | [[http://www.xkcd.com][helpful text link]] | [[http://farm7.static.flickr.com/6078/6084185195_552aa270b2.jpg]] | [[http://www.xkcd.com][http://imgs.xkcd.com/comics/t_cells.png]] | | - diff --git a/spec/html_examples/entities.html b/spec/html_examples/entities.html index 60696d7..7c38cbf 100644 --- a/spec/html_examples/entities.html +++ b/spec/html_examples/entities.html @@ -6,7 +6,7 @@

ENTITIES

  • Question: What does org-mode do for ampersands, like R&R? or &lt;?
  • Answer: Those get escaped, too. ☺
  • -

    <Even in headlines! funner & funner!>

    +

    <Even in headlines! funner & funner!>

    « They α should β be γ able δ to η exist θ in ε the same line √ ».

    @@ -19,7 +19,7 @@

    <Even in headlines! funner & funner!>

    ⌊ — — — — — — ⌋

    To work they have to be separated, like ♥ ♥, not like ♥\hearts.

    -

    List of entities supported

    +

    List of entities supported

     # Script to generate the list of currently supported entities
     require 'org-ruby'
    @@ -376,6 +376,6 @@ 

    List of entities supported

  • Writing \Diamond, results in: ⋄
  • Writing \loz, results in: ◊
  • -

    Some special cases

    +

    Some special cases

    In case nothing matches, the string is returned as is.

    \for \example \this \wont \break

    diff --git a/spec/html_examples/export-exclude-only.html b/spec/html_examples/export-exclude-only.html index 6807eb1..d55d5dc 100644 --- a/spec/html_examples/export-exclude-only.html +++ b/spec/html_examples/export-exclude-only.html @@ -1,11 +1,11 @@

    export-headline-levels.org

    What happens when you exceed the number of headline levels to export?

    -

    1 Headline 1

    -

    1.1 Headline 2

    +

    1 Headline 1

    +

    1.1 Headline 2

    This bit of body should get exported.

    -

    1.1.1 Headline 3

    +

    1.1.1 Headline 3

    This bit of body gets exported.

    -

    1.1.1.1 Headline 4 (include)

    +
    1.1.1.1 Headline 4 (include)

    Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo @@ -21,7 +21,7 @@

    1.1.1.1 Headline 4 (inc voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

    -

    1.1.2 Another headline 3

    +

    1.1.2 Another headline 3

    This one should not get exported!!

    -

    1.1.2.1 Another headline 4

    +
    1.1.2.1 Another headline 4

    This also cannot get exported!!

    diff --git a/spec/html_examples/export-keywords.html b/spec/html_examples/export-keywords.html index 894bd6f..2ec3ad3 100644 --- a/spec/html_examples/export-keywords.html +++ b/spec/html_examples/export-keywords.html @@ -1,4 +1,4 @@

    export-keywords.org

    Testing that I can export keywords.

    -

    1 TODO This is a todo item.

    -

    2 DONE this item is done!

    +

    1 TODO This is a todo item.

    +

    2 DONE this item is done!

    diff --git a/spec/html_examples/export-tags.html b/spec/html_examples/export-tags.html index d183c73..3ffa20e 100644 --- a/spec/html_examples/export-tags.html +++ b/spec/html_examples/export-tags.html @@ -1,10 +1,10 @@

    export-headline-levels.org

    What happens when you exceed the number of headline levels to export?

    -

    1 Headline 1

    -

    1.1 Headline 2

    -

    1.1.1 Headline 3

    +

    1 Headline 1

    +

    1.1 Headline 2

    +

    1.1.1 Headline 3

    This bit of body gets exported.

    -

    1.1.1.1 Headline 4 (include)

    +
    1.1.1.1 Headline 4 (include)

    Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo diff --git a/spec/html_examples/footnotes_title.html b/spec/html_examples/footnotes_title.html new file mode 100644 index 0000000..bd563b7 --- /dev/null +++ b/spec/html_examples/footnotes_title.html @@ -0,0 +1,111 @@ +

    Footnotes

    +

    Using letters and not defined in the footnote abc

    +

    Defined in the footnote itself with markup 0

    +

    Some example paragraph 1, with text at the end.

    +

    Some example paragraph 2, with text at the end.

    +

    Some example paragraph 3, with text at the end.

    +

    Some example paragraph 4, with text at the end.

    +

    Some example paragraph 5, with text at the end.

    +

    Some example paragraph 6, with text at the end.

    +

    Some example paragraph 7, with text at the end.

    +

    Some example paragraph 8, with text at the end.

    +

    Some example paragraph 9, with text at the end.

    +

    Some example paragraph 10, with text at the end.

    +

    Some example paragraph 11, with text at the end.

    +

    Some example paragraph 12, with text at the end.

    +

    Some example paragraph 13, with text at the end.

    +

    Some example paragraph 14, with text at the end.

    +

    Some example paragraph 15, with text at the end.

    +

    Some example paragraph 16, with text at the end.

    +

    Some example paragraph 17, with text at the end.

    +

    Some example paragraph 18, with text at the end.

    +

    Some example paragraph 19, with text at the end.

    +

    Some example paragraph 20, with text at the end.

    +

    Some example paragraph 21, with text at the end.

    +

    Some example paragraph 22, with text at the end.

    +

    Some example paragraph 23, with text at the end.

    +

    Some example paragraph 24, with text at the end.

    +

    Some example paragraph 25, with text at the end.

    +

    Some example paragraph 26, with text at the end.

    +

    Some example paragraph 27, with text at the end.

    +

    Some example paragraph 28, with text at the end.

    +

    Some example paragraph 29, with text at the end.

    +

    Some example paragraph 30, with text at the end.

    +

    Some example paragraph 31, with text at the end.

    +

    Some example paragraph 32, with text at the end.

    +

    Some example paragraph 33, with text at the end.

    +

    Some example paragraph 34, with text at the end.

    +

    Some example paragraph 35, with text at the end.

    +

    Some example paragraph 36, with text at the end.

    +

    Some example paragraph 37, with text at the end.

    +

    Some example paragraph 38, with text at the end.

    +

    Some example paragraph 39, with text at the end.

    +

    Some example paragraph 40, with text at the end.

    +

    Some example paragraph 41, with text at the end.

    +

    Some example paragraph 42, with text at the end.

    +

    Some example paragraph 43, with text at the end.

    +

    Some example paragraph 44, with text at the end.

    +

    Some example paragraph 45, with text at the end.

    +

    Some example paragraph 46, with text at the end.

    +

    Some example paragraph 47, with text at the end.

    +

    Some example paragraph 48, with text at the end.

    +

    Some example paragraph 49, with text at the end.

    +

    Some example paragraph 50, with text at the end.

    +

    1 And some example footnote

    +

    2 And some example footnote

    +

    3 And some example footnote

    +

    4 And some example footnote

    +

    5 And some example footnote

    +

    6 And some example footnote

    +

    7 And some example footnote

    +

    8 And some example footnote

    +

    9 And some example footnote

    +

    10 And some example footnote

    +

    11 And some example footnote

    +

    12 And some example footnote

    +

    13 And some example footnote

    +

    14 And some example footnote

    +

    15 And some example footnote

    +

    16 And some example footnote

    +

    17 And some example footnote

    +

    18 And some example footnote

    +

    19 And some example footnote

    +

    20 And some example footnote

    +

    21 And some example footnote

    +

    22 And some example footnote

    +

    23 And some example footnote

    +

    24 And some example footnote

    +

    25 And some example footnote

    +

    26 And some example footnote

    +

    27 And some example footnote

    +

    28 And some example footnote

    +

    29 And some example footnote

    +

    30 And some example footnote

    +

    31 And some example footnote

    +

    32 And some example footnote

    +

    33 And some example footnote

    +

    34 And some example footnote

    +

    35 And some example footnote

    +

    36 And some example footnote

    +

    37 And some example footnote

    +

    38 And some example footnote

    +

    39 And some example footnote

    +

    40 And some example footnote

    +

    41 And some example footnote

    +

    42 And some example footnote

    +

    43 And some example footnote

    +

    44 And some example footnote

    +

    45 And some example footnote

    +

    46 And some example footnote

    +

    47 And some example footnote

    +

    48 And some example footnote

    +

    49 And some example footnote

    +

    50 And some example footnote

    +

    Using letters and defined in the footnote abc

    +
    +

    Footnotes Title

    +
    +
    0

    blub

    +
    abc

    definition of abc

    +
    +
    diff --git a/spec/html_examples/include-file-disabled.html b/spec/html_examples/include-file-disabled.html index ad71e68..e3dd07a 100644 --- a/spec/html_examples/include-file-disabled.html +++ b/spec/html_examples/include-file-disabled.html @@ -1,21 +1,21 @@

    Example of including a file

    -

    Basic tests

    -

    Within a commented block

    -

    Within a center block

    +

    Basic tests

    +

    Within a commented block

    +

    Within a center block

    The following included file will be centered:

    -

    Within a blockquote

    +

    Within a blockquote

    This is similar to the center block:

    Before

    After

    -

    Within an example block, it should not be possible to include a file.

    +

    Within an example block, it should not be possible to include a file.

     #+INCLUDE: "./spec/html_examples/only-list.org"
     
    -

    Within a list

    +

    Within a list