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 "#{HtmlBlockTag[m]}>"
- @output << "#{HtmlBlockTag[m]}>"
- 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("#{HtmlBlockTag[m]}>")
+ 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: Turns out there’s more way to do code than just BEGIN_EXAMPLE. This should work: Two ASCII blobs. And this: I really love to write about
:symbols. They sure are the
@@ -69,12 +69,12 @@ Turns out there’s more way to do code than just BEGIN_EXAMPLE. This should work: Two ASCII blobs. And this: 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 @@
Turns out there’s more way to do code than just BEGIN_EXAMPLE. This should work: Two ASCII blobs. And this: Even if no language is set, it is still wrapped in code tags but class is empty. I really love to write about
:symbols. They sure are the
@@ -63,19 +63,19 @@ According to the Org mode docs, it is possible to customize whether
the code block will be exported or not. Using Org Babel features, it is possible to set 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.
Only the code would be in the output,
the same as when no option is set.
This omits both the resulting block,
and the code block itself. This should work as well when using an example block.
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. According to the Org mode docs, it is possible to customize whether
the code block will be exported or not. Using Org Babel features, it is possible to set 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.
Only the code would be in the output,
the same as when no option is set.
This omits both the resulting block,
and the code block itself. This should work as well when using an example block.
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. 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
According to the Org mode docs, it is possible to customize whether
the code block will be exported or not. Using Org Babel features, it is possible to set 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.
Only the code would be in the output,
the same as when no option is set.
This omits both the resulting block,
and the code block itself. This should work as well when using an example block.
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. 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.) don’t be fooled by the initial substring above! 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.) don’t be fooled by the initial substring above! 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.) don’t be fooled by the initial substring above! Text The following examples show how org-ruby behave
when handling some cases of definition lists.
(Many thanks to vonavi for his contributions here) The following cases will not be considered as definition lists
but just regular lists. ??? will be shown in this case Fix issue #48 bold italic « They α should β be γ
able δ to η exist θ in ε
the same line √ ». ⌊ — — — — — — ⌋ To work they have to be separated, like ♥ ♥, not like ♥\hearts. In case nothing matches, the string is returned as is. \for \example \this \wont \break What happens when you exceed the number of headline levels to export? This bit of body should get exported. This bit of body gets exported. 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 @@
"
@@ -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 << "\nFootnotes:
\n#{footnotes_title}
\nadvanced-code-coderay.org
1 Inline examples
+1 Inline examples
fixed width? how does this work?
@@ -14,7 +14,7 @@
1 Inline examples
....
2 BEGIN_SRC
+2 BEGIN_SRC
# 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
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
1 Inline examples
+1 Inline examples
fixed width? how does this work?
@@ -14,7 +14,7 @@
1 Inline examples
....
2 BEGIN_SRC
+2 BEGIN_SRC
# 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
advanced-code.org
1 Inline examples
+1 Inline examples
fixed width? how does this work?
@@ -14,7 +14,7 @@
1 Inline examples
....
2 BEGIN_SRC
+2 BEGIN_SRC
# 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
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
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
!+!+++!++!++!++!+
Support for :exports options from code blocks
About the
+#+RESULTS:
blockAbout the
#+RESULTS:
block:results output
to a code block and render the results within a #+RESULTS:
code block:
@@ -78,7 +78,7 @@
-About the
#+RESULTS:
blockDefault options
+Default options
Default options
:exports code
+:exports code
@@ -110,13 +110,13 @@
:exports code
:exports none
+:exports none
: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
Support for :exports options from code blocks
About the
+#+RESULTS:
blockAbout the
#+RESULTS:
block:results output
to a code block and render the results within a #+RESULTS:
code block:
@@ -78,7 +78,7 @@
-About the
#+RESULTS:
blockDefault options
+Default options
Default options
:exports code
+:exports code
@@ -110,13 +110,13 @@
:exports code
:exports none
+:exports none
: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
:exports results
any string
any string
-When results are graphics…
+When results are graphics…
#+RESULTS
directive.When results are graphics…
-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
About the
+#+RESULTS:
blockAbout the
#+RESULTS:
block: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:
blockDefault options
+Default options
Default options
:exports code
+:exports code
var message = "Hello world!";
@@ -102,13 +102,13 @@
:exports code
:exports none
+:exports none
: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
custom-todo.org
TODO Sample
+TODO Sample
-
I gave up.
huh?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
custom-todo.org
TODO Sample
+TODO Sample
-
I gave up.
huh?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
custom-typ-todo.org
TODO Sample
+TODO Sample
-
I gave up.
huh?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
Hallo
Asterisk can be used for lists
+Asterisk can be used for lists
-Corner cases of definition lists
+Corner cases of definition lists
Definition List Items
+Definition List Items
-
@@ -63,7 +63,7 @@
Definition List Items
Not Definition List Items
+Not Definition List Items
@@ -75,7 +75,7 @@
-Not Definition List Items
Definition List Item without Definition
+Definition List Item without Definition
-Definition List Item without Definition
Definition List with markup inline
+Definition List with markup inline
Inline Formatting test for emphasis
+~/.bash
and C-'
Simple feature test
ENTITIES
<Even in headlines! funner & funner!>
+<Even in headlines! funner & funner!>
<Even in headlines! funner & funner!>
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
\Diamond
, results in: ⋄\loz
, results in: ◊Some special cases
+Some special cases
export-headline-levels.org
1 Headline 1
-1.1 Headline 2
+1 Headline 1
+1.1 Headline 2
1.1.1 Headline 3
+1.1.1 Headline 3
1.1.1.1 Headline 4 (include)
+1.1.1.1 Headline 4 (include)
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.
This one should not get exported!!
-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 @@Testing that I can export keywords.
-What happens when you exceed the number of headline levels to export?
-This bit of body gets exported.
-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 @@ +
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
+ 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 @@The following included file will be centered:
This is similar to the center block:
-Before
After
#+INCLUDE: "./spec/html_examples/only-list.org"-
One | Two | Three |
---|---|---|
#+INCLUDE: “./spec/html_examples/only-list.org” | Five | Six |
Seven | Eight | Nine |
Advanced Lists
org-ruby
supports the following list features of org-mode
:
Note the list ends just some more text. Make sure both list blocks are closed.
-This list will end with the end-of-file. Make sure all blocks are closed.
Here comes a multi-part list.
BLOCKCOMMENT
Testing that the next part is ignored
And now back to normal!
-<li>[ ] “smart quotes”</li> <li>[ ] I think I need this for ‘single quotes’ too. Don’t I?</li> <li>[ ] Em dashes would be great — wouldn’t they?</li> <li>[ ] I hope to develop an en dash sometime in 2010 – 2011.</li>-
The following included file will be centered:
Inline Images
@@ -108,7 +108,7 @@Sample relative link to .svgz:
This is similar to the center block:
-Before @@ -136,11 +136,11 @@
Within a blockquote
After
#+INCLUDE: "./spec/html_examples/only-list.org"-
One | Two | Three |
---|---|---|
#+INCLUDE: “./spec/html_examples/only-list.org” | Five | Six |
Seven | Eight | Nine |
- This file has only a list - Note it will end with nothing other than a list item. - the world wants to know: Will org-ruby write the closing ul tag?-
- This file has only a list
diff --git a/spec/html_examples/left-to-right-with-dir.html b/spec/html_examples/left-to-right-with-dir.html new file mode 100644 index 0000000..bd43f54 --- /dev/null +++ b/spec/html_examples/left-to-right-with-dir.html @@ -0,0 +1,6 @@ +عنوان
+فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى
+عنوان فرعي
+فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية
+عنوان وكلمة أنجليزية english معه
+فقرة تحتوي على كلمات أنجليزية (english words) فيها من ما يجعلها لا تظهر بشكل صحيح not correct rendering
diff --git a/spec/html_examples/left-to-right-with-dir.org b/spec/html_examples/left-to-right-with-dir.org new file mode 100644 index 0000000..6763424 --- /dev/null +++ b/spec/html_examples/left-to-right-with-dir.org @@ -0,0 +1,10 @@ +#+OPTIONS: ltr:t + +* عنوان +فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى + +** عنوان فرعي +فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية + +* عنوان وكلمة أنجليزية english معه +فقرة تحتوي على كلمات أنجليزية (english words) فيها من ما يجعلها لا تظهر بشكل صحيح not correct rendering diff --git a/spec/html_examples/left-to-right.html b/spec/html_examples/left-to-right.html new file mode 100644 index 0000000..6a803ea --- /dev/null +++ b/spec/html_examples/left-to-right.html @@ -0,0 +1,6 @@ +عنوان
+فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى
+عنوان فرعي
+فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية
+عنوان وكلمة أنجليزية english معه
+فقرة تحتوي على كلمات أنجليزية (english words) فيها من ما يجعلها لا تظهر بشكل صحيح not correct rendering
diff --git a/spec/html_examples/left-to-right.org b/spec/html_examples/left-to-right.org new file mode 100644 index 0000000..2174feb --- /dev/null +++ b/spec/html_examples/left-to-right.org @@ -0,0 +1,8 @@ +* عنوان +فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى فقرة أولى + +** عنوان فرعي +فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية فقرة ثانية + +* عنوان وكلمة أنجليزية english معه +فقرة تحتوي على كلمات أنجليزية (english words) فيها من ما يجعلها لا تظهر بشكل صحيح not correct rendering diff --git a/spec/html_examples/link-features.html b/spec/html_examples/link-features.html index 81ef845..30b0854 100644 --- a/spec/html_examples/link-features.html +++ b/spec/html_examples/link-features.html @@ -2,28 +2,28 @@link-features.org
Org-mode export supports a lot of link features. I’ve covered “simple” HTML links elsewhere. Now let’s cover links to other org files, other sections within documents, etc.
-Links to other org files
+Links to other org files
This is a link to the
-code-comment.org
file in the same directory. Inemacs
, if you click it, the other file opens. We want the same behavior in the HTML export.Search links
+Search links
This is a search link into code-comment.org.
-Correct handling of .org URIs in HTML markup routine (thanks @rayl!)
+Correct handling of .org URIs in HTML markup routine (thanks @rayl!)
-In these links, .org used to be converted to .html. Not anymore since 0.9.2 version of the gem
+In these links, .org used to be converted to .html. Not anymore since 0.9.2 version of the gem
-Links abbreviations
+Links abbreviations
URLs can be abbreviated by a LINK definition in the org file
This is an abbreviated link example
diff --git a/spec/html_examples/options-parsing.html b/spec/html_examples/options-parsing.html index 448657b..8860022 100644 --- a/spec/html_examples/options-parsing.html +++ b/spec/html_examples/options-parsing.html @@ -1,4 +1,4 @@Options parsing
The options hash should not make the parser throw exceptions upon unrecognized options.
-0.0.1 TODO Hello world
+0.0.1 TODO Hello world
Hi
diff --git a/spec/html_examples/skip-header.html b/spec/html_examples/skip-header.html index bdbc02d..bf44621 100644 --- a/spec/html_examples/skip-header.html +++ b/spec/html_examples/skip-header.html @@ -1,3 +1,3 @@skip-header.org
-1 First heading
+1 First heading
This should be the first text in the output.
diff --git a/spec/markdown_examples/custom-seq-todo.md b/spec/markdown_examples/custom-seq-todo.md index 06c57f6..e908f6b 100644 --- a/spec/markdown_examples/custom-seq-todo.md +++ b/spec/markdown_examples/custom-seq-todo.md @@ -3,18 +3,18 @@ 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.) -# Sample +## Sample * State "CANCELED" from "INPROGRESS" [2009-12-29 Tue 22:26] \\ I gave up. * State "WAITING" from "" [2009-12-29 Tue 22:25] \\ huh? -# this one's in progress -# who am I waiting on? -# Finished this one! -# 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 +## this one's in progress +## who am I waiting on? +## Finished this one! +## 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/markdown_examples/custom-todo.md b/spec/markdown_examples/custom-todo.md index 06c57f6..e908f6b 100644 --- a/spec/markdown_examples/custom-todo.md +++ b/spec/markdown_examples/custom-todo.md @@ -3,18 +3,18 @@ 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.) -# Sample +## Sample * State "CANCELED" from "INPROGRESS" [2009-12-29 Tue 22:26] \\ I gave up. * State "WAITING" from "" [2009-12-29 Tue 22:25] \\ huh? -# this one's in progress -# who am I waiting on? -# Finished this one! -# 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 +## this one's in progress +## who am I waiting on? +## Finished this one! +## 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/markdown_examples/custom-typ-todo.md b/spec/markdown_examples/custom-typ-todo.md index 06c57f6..e908f6b 100644 --- a/spec/markdown_examples/custom-typ-todo.md +++ b/spec/markdown_examples/custom-typ-todo.md @@ -3,18 +3,18 @@ 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.) -# Sample +## Sample * State "CANCELED" from "INPROGRESS" [2009-12-29 Tue 22:26] \\ I gave up. * State "WAITING" from "" [2009-12-29 Tue 22:25] \\ huh? -# this one's in progress -# who am I waiting on? -# Finished this one! -# 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 +## this one's in progress +## who am I waiting on? +## Finished this one! +## 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/markdown_examples/deflist.md b/spec/markdown_examples/deflist.md index 006ce15..4e953f9 100644 --- a/spec/markdown_examples/deflist.md +++ b/spec/markdown_examples/deflist.md @@ -4,19 +4,19 @@ 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](https://github.com/vonavi) for his contributions here) -## Definition List Items +### Definition List Items * Regular list Key :: Value (k1) @@ -45,7 +45,7 @@ Key:: MoreKey :: Value (k2) * Case 3 :: Key :: Value (k3) -## Not Definition List Items +### Not Definition List Items The following cases will not be considered as definition lists but just regular lists. @@ -58,7 +58,7 @@ Value (n4) * Key :: Value (n5) -## Definition List Item without Definition +### Definition List Item without Definition ??? will be shown in this case diff --git a/spec/markdown_examples/entities.md b/spec/markdown_examples/entities.md index b007d72..4134230 100644 --- a/spec/markdown_examples/entities.md +++ b/spec/markdown_examples/entities.md @@ -6,7 +6,7 @@ things... like elipses. Oh -- and dashes. * Question: What does org-mode do for ampersands, like R&R? or <? * Answer: Those get escaped, too. ☺ -#+## « They α should β be γ able δ to η exist θ in ε @@ -24,7 +24,7 @@ Though they appear in center blocks 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 @@ -383,7 +383,7 @@ bundle exec ruby /tmp/print_entities.rb * Writing `\Diamond`, results in: ⋄ * Writing `\loz`, results in: ◊ -# Some special cases +## Some special cases In case nothing matches, the string is returned as is. diff --git a/spec/markdown_examples/export-exclude-only.md b/spec/markdown_examples/export-exclude-only.md index 30a2584..19b0822 100644 --- a/spec/markdown_examples/export-exclude-only.md +++ b/spec/markdown_examples/export-exclude-only.md @@ -1,17 +1,17 @@ What happens when you exceed the number of headline levels to export? -# Headline 1 +## Headline 1 -## Headline 2 +### Headline 2 This bit of body **should** get exported. -### Headline 3 +#### Headline 3 This bit of body gets exported. -#### Headline 4 (include) +##### Headline 4 (include) Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam @@ -29,10 +29,10 @@ 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. -### Another headline 3 +#### Another headline 3 This one **should not** get exported!! -#### Another headline 4 +##### Another headline 4 This also **cannot** get exported!! diff --git a/spec/markdown_examples/export-keywords.md b/spec/markdown_examples/export-keywords.md index b73112a..7bf23ab 100644 --- a/spec/markdown_examples/export-keywords.md +++ b/spec/markdown_examples/export-keywords.md @@ -1,4 +1,4 @@ Testing that I can export keywords. -# This is a todo item. -# this item is done! +## This is a todo item. +## this item is done! diff --git a/spec/markdown_examples/export-tags.md b/spec/markdown_examples/export-tags.md index d8c1b42..d0862f0 100644 --- a/spec/markdown_examples/export-tags.md +++ b/spec/markdown_examples/export-tags.md @@ -1,13 +1,13 @@ What happens when you exceed the number of headline levels to export? -# Headline 1 -## Headline 2 -### Headline 3 +## Headline 1 +### Headline 2 +#### Headline 3 This bit of body gets exported. -#### Headline 4 (include) +##### Headline 4 (include) Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam diff --git a/spec/markdown_examples/footnotes.md b/spec/markdown_examples/footnotes.md index a0e290e..b4ce5ac 100644 --- a/spec/markdown_examples/footnotes.md +++ b/spec/markdown_examples/footnotes.md @@ -1,5 +1,5 @@ -# Footnotes +## Footnotes Using numbers [fn:0] diff --git a/spec/markdown_examples/include-file.md b/spec/markdown_examples/include-file.md index 3ba88ac..1b677d2 100644 --- a/spec/markdown_examples/include-file.md +++ b/spec/markdown_examples/include-file.md @@ -1,29 +1,29 @@ -# Basic tests +## Basic tests -# Within a commented block +## Within a commented block -# Within a center 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 * A list that has an included file directive * Only go to the first level @@ -31,15 +31,15 @@ This is similar to the center block: * 3rd level * 3rd level, though it should be a different list -# Within a table, cannot be included +## Within a table, cannot be included | One | Two | Three | | #+INCLUDE: "./spec/html_examples/only-list.org" | Five | Six | | Seven | Eight | Nine | -# When including a file as an example +## When including a file as an example -# When including a file as an quote +## When including a file as an quote diff --git a/spec/markdown_examples/link-features.md b/spec/markdown_examples/link-features.md index de481e5..667b0b6 100644 --- a/spec/markdown_examples/link-features.md +++ b/spec/markdown_examples/link-features.md @@ -3,7 +3,7 @@ Org-mode export supports a lot of link features. I've covered "simple" HTML links elsewhere. Now let's cover links to other org files, other sections within documents, etc. -# Links to other org files +## Links to other org files This is a link to the `code-comment.org` file in the same directory. In `emacs`, if you click it, the other file opens. We @@ -11,13 +11,13 @@ want the same behavior in the HTML export. [Code Comment](file:code-comment.org) -# Search links +## Search links This is a search link into code-comment.org. [Code Comment](file:code-comment.org::*Code%20Comment) -# Correct handling of .org URIs in HTML markup routine (thanks @rayl!) +## Correct handling of .org URIs in HTML markup routine (thanks @rayl!) * [foo.com website](http://foo.com) @@ -27,13 +27,13 @@ This is a search link into code-comment.org. * [localhost:4567/foo.org](http://localhost:4567/foo.org) -# In these links, .org is converted to .html +## In these links, .org is converted to .html * [file:path.org label](file:path.org) * [file:notes/path.org label](file:notes/path.org) -# Links abbreviations +## Links abbreviations URLs can be abbreviated by a LINK definition in the org file diff --git a/spec/markdown_examples/skip-header.md b/spec/markdown_examples/skip-header.md index 7787fb8..0a3cf41 100644 --- a/spec/markdown_examples/skip-header.md +++ b/spec/markdown_examples/skip-header.md @@ -9,6 +9,6 @@ Even this code snippet shouldn't be there. Like a ninja. You can't see me. ``` -# First heading +## First heading This should be the first text in the output. diff --git a/spec/org-ruby/html_output_buffer_spec.rb b/spec/org-ruby/html_output_buffer_spec.rb new file mode 100644 index 0000000..5ead7e0 --- /dev/null +++ b/spec/org-ruby/html_output_buffer_spec.rb @@ -0,0 +1,106 @@ +require 'spec_helper' +require_relative '../../lib/org-ruby/html_output_buffer' + +module Orgmode + RSpec.describe HtmlOutputBuffer do + let(:output) { "Buffer" } + let(:buffer) { Orgmode::HtmlOutputBuffer.new(output) } + + describe '.new' do + it 'has an output buffer' do + expect(buffer).not_to be_nil + expect(buffer.output).to eq output + end + + it 'has HTML buffer_tag' do + expect(buffer.buffer_tag).to eq 'HTML' + end + + context 'when call with options' do + let(:options) { { option: 'value'} } + let(:buffer) { Orgmode::HtmlOutputBuffer.new(output, options)} + it 'has options' do + expect(buffer.options).to eq options + end + end + end + + describe '#push_mode' do + context 'when mode is a HtmlBlockTag' do + let(:mode) { :paragraph } + let(:indent) { :some_value } + let(:properties) { Hash.new } + + it 'push HtmlBlock to the output buffer' do + buffer.push_mode(mode, indent, properties) + expect(buffer.output).to eq 'Buffer ' + end + + context 'when mode is example' do + let(:mode) { :example } + it 'sets class attributes to example' do + buffer.push_mode(mode, indent) + expect(buffer.output).to eq 'Buffer
' + end + end + + context 'when mode is inline_example' do + let(:mode) { :inline_example } + it 'sets class attributes to example' do + buffer.push_mode(mode, indent) + expect(buffer.output).to eq 'Buffer' + end + end + + context 'when mode is center' do + let(:mode) { :center } + it 'sets style attribute to text-align: center' do + buffer.push_mode(mode, indent) + expect(buffer.output).to eq 'Buffer' + end + end + + context 'when mode is src' do + let(:mode) { :src } + + context 'when Buffer options include skip_syntax_highlight = true' do + let(:buffer) { Orgmode::HtmlOutputBuffer.new(output, { skip_syntax_highlight: true })} + before(:each) do + allow(buffer).to receive(:block_lang).and_return('') + end + + it 'sets class attributes' do + buffer.push_mode(mode, indent) + expect(buffer.output).to eq 'Buffer' + end + + context 'when Buffer block_lang is not empty' do + let(:block_lang) { 'elisp' } + + before(:each) do + allow(buffer).to receive(:block_lang).and_return(block_lang) + end + + it 'set lang attribute' do + buffer.push_mode(mode, indent, properties) + expect(buffer.output).to eq 'Buffer' + end + end + end + end + + context 'when called for second time' do + before(:each) do + buffer.push_mode(mode, indent) + end + + it 'does not add paragprah' do + mode = :src + buffer.push_mode(mode, 'indent') + expect(buffer.output).not_to match(/\Z\n/) + end + end + end + end + end +end diff --git a/spec/org-ruby/output_buffer_spec.rb b/spec/org-ruby/output_buffer_spec.rb new file mode 100644 index 0000000..ea81f29 --- /dev/null +++ b/spec/org-ruby/output_buffer_spec.rb @@ -0,0 +1,38 @@ +require 'spec_helper' + +require_relative '../../lib/org-ruby/output_buffer' +module Orgmode + RSpec.describe OutputBuffer do + let(:output) { 'Output' } + let(:buffer) { Orgmode::OutputBuffer.new(output) } + + describe '.new' do + it 'receives and has an output' do + expect(buffer.output).to eq output + end + end + + describe 'get_next_headline_number' do + let(:level) { 1 } + context 'when @headline_number_stack is empty' do + it 'returns 1' do + headline_number = buffer.get_next_headline_number(level) + expect(headline_number).to eq '1' + end + end + + context 'when @headline_number_stack has numbers' do + let(:level) { 2 } + before(:each) do + buffer.headline_number_stack.push(4) + buffer.headline_number_stack.push(2) + end + + it 'returns 4.3' do + headline_number = buffer.get_next_headline_number(level) + expect(headline_number).to eq '4.3' + end + end + end + end +end diff --git a/spec/parser_spec.rb b/spec/parser_spec.rb index 55aeb20..965ef7b 100644 --- a/spec/parser_spec.rb +++ b/spec/parser_spec.rb @@ -329,6 +329,32 @@ end end + describe "Footnotes title" do + base_dir = File.join(File.dirname(__FILE__), "html_examples") + org_file = File.join(base_dir, "footnotes.org") + html_file = File.join(base_dir, "footnotes_title.html") + it 'accept footnotes_title option' do + expected = IO.read(html_file) + parser = Orgmode::Parser.new(IO.read(org_file), :footnotes_title => "Footnotes Title") + actual = parser.to_html + expect(actual).to be_kind_of(String) + expect(actual).to eq(expected) + end + end + + describe "Left to right support by" do + base_dir = File.join(File.dirname(__FILE__), "html_examples") + org_file = File.join(base_dir, "left-to-right.org") + html_file = File.join(base_dir, "left-to-right-with-dir.html") + + it 'adds dir="auto" as global attribute' do + expected = IO.read(html_file) + parser = Orgmode::Parser.new(IO.read(org_file), :ltr => 't') + actual = parser.to_html + expect(actual).to eq(expected) + end + end + describe "Export to Markdown test cases" do data_directory = File.join(File.dirname(__FILE__), "markdown_examples") org_files = File.expand_path(File.join(data_directory, "*.org" )) @@ -489,4 +515,3 @@ end end end - diff --git a/spec/regexp_helper_spec.rb b/spec/regexp_helper_spec.rb index 694405a..3e43dac 100644 --- a/spec/regexp_helper_spec.rb +++ b/spec/regexp_helper_spec.rb @@ -1,6 +1,24 @@ require 'spec_helper' describe Orgmode::RegexpHelper do + let(:helper) { Orgmode::RegexpHelper.new } + + describe '#org-emphasis-regexp' do + it 'match emphasis expresions' do + expect(helper.org_emphasis_regexp).to match '~code~' + end + example { expect(helper.org_emphasis_regexp).to match '[[a][~a~]]' } + end + + describe '#org-link-regexp' do + it 'match org-links' do + expect(helper.org_link_regexp).to match '[[url][description]]' + end + + example { expect(helper.org_link_regexp).to match '[[url]]' } + example { expect(helper.org_link_regexp).to match '[[a][~a~]]' } + end + it "should recognize simple markup" do e = Orgmode::RegexpHelper.new total = 0 @@ -73,4 +91,4 @@ expect(n).to eql("This string contains a quote using code markup:\"
") end -end # describe Orgmode::RegexpHelper +end diff --git a/spec/textile_examples/footnotes.textile b/spec/textile_examples/footnotes.textile index 73e6cde..aaaffe6 100644 --- a/spec/textile_examples/footnotes.textile +++ b/spec/textile_examples/footnotes.textile @@ -1,5 +1,5 @@ -h1. Footnotes +h2. Footnotes p. Using numbers [0]