diff --git a/lib/org-ruby/output_buffer.rb b/lib/org-ruby/output_buffer.rb index 90a0aae..3179cd5 100644 --- a/lib/org-ruby/output_buffer.rb +++ b/lib/org-ruby/output_buffer.rb @@ -137,7 +137,7 @@ def preserve_whitespace? 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 diff --git a/lib/org-ruby/parser.rb b/lib/org-ruby/parser.rb index a57fd9e..192b855 100644 --- a/lib/org-ruby/parser.rb +++ b/lib/org-ruby/parser.rb @@ -129,7 +129,7 @@ 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? # Ensure we have full paths 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..b599d49 100644 --- a/spec/html_code_syntax_highlight_examples/advanced-code-pygments.html +++ b/spec/html_code_syntax_highlight_examples/advanced-code-pygments.html @@ -18,29 +18,29 @@
And this:
# 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
- end
+def match_all(str)
+ str.scan(@org_emphasis_regexp) do |match|
+ yield $2, $3
+ end
end
Now let’s test case-insensitive code blocks.
# 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
- end
+def match_all(str)
+ str.scan(@org_emphasis_regexp) do |match|
+ yield $2, $3
+ end
end
(def fib-seq
- (concat
- [0 1]
- ((fn rfib [a b]
- (lazy-cons (+ a b) (rfib b (+ a b)))) 0 1)))
-
-user> (take 20 fib-seq)
-(0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181)
+ (concat
+ [0 1]
+ ((fn rfib [a b]
+ (lazy-cons (+ a b) (rfib b (+ a b)))) 0 1)))
+
+user> (take 20 fib-seq)
+(0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181)
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
@@ -52,27 +52,27 @@ 3 It should be possible
best things in the world!
{
-:one => 1,
-:two => 2
+:one => 1,
+:two => 2
}
-(defproject helloworld "0.1"
-:dependencies [[org.clojure/clojure
- "1.1.0-master-SNAPSHOT"]
- [org.clojure/clojure-contrib
- "1.0-SNAPSHOT"]]
-:main helloworld)
+(defproject helloworld "0.1"
+:dependencies [[org.clojure/clojure
+ "1.1.0-master-SNAPSHOT"]
+ [org.clojure/clojure-contrib
+ "1.0-SNAPSHOT"]]
+:main helloworld)
4 Code syntax highlight with Pygments
4.1 No language selected
<script>alert('hello world')</script>
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;
+* {
+ /* apply a natural box layout model to all elements */
+ box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ -webkit-box-sizing: border-box;
}
4.3 HTML example
@@ -86,10 +86,10 @@ 4.3 HTML example
</html>
4.4 Ruby example
-class Post << ActiveRecord::Base
- def print_title
- puts "#{self.title}"
- end
+class Post << ActiveRecord::Base
+ def print_title
+ puts "#{self.title}"
+ end
end
4.5 Python example
@@ -99,21 +99,21 @@ 4.5 Python example
m.background = Map.Color('steelblue')
4.6 Javascript example
-exports = this;
+exports = this;
(function($){
-var Posts = {};
+var Posts = {};
-Posts.index = function(){
+Posts.index = function(){
// TODO
};
})(jQuery);
4.7 JSON example
-{ name: "Waldemar"
-, surname: "Quevedo"
+{ name: "Waldemar"
+, surname: "Quevedo"
}
4.8 PHP example
@@ -122,9 +122,9 @@ 4.8 PHP example
var_dump(some_var);
4.9 Elisp example
-(defun hello()
- (interactive)
- (message "hello"))
+(defun hello()
+ (interactive)
+ (message "hello"))
4.10 Not supported language example
!+!+++!++!++!++!+
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..b060784 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
@@ -4,35 +4,35 @@ Support for :exports options from code blocks
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
+#+begin_src ruby :results output :exports both
puts "Hello world"
-#+end_src
+#+end_src
-#+RESULTS:
+#+RESULTS:
: Hello world
One thing about the #+RESULTS: code blocks, is that they exist in several forms:
- As an accumulated group of inline examples:
-
#+begin_src python :results output :exports both
+#+begin_src python :results output :exports both
print "like"
print "this"
print "etc..."
-#+end_src
+#+end_src
-#+RESULTS:
+#+RESULTS:
: like
: this
: etc...
- As an example code block.
-
#+begin_src ruby :results output :exports both
+#+begin_src ruby :results output :exports both
10.times {|n| puts n }
-#+end_src
+#+end_src
-#+RESULTS:
-#+begin_example
+#+RESULTS:
+#+begin_example
0
1
2
@@ -43,19 +43,19 @@ About the #+RESULTS: block
7
8
9
-#+end_example
+#+end_example
- Also, in case
:results output code is used, the results would
be a src block of the same language as the original one.
-#+begin_src ruby :results output code
+#+begin_src ruby :results output code
counter = 0
10.times { puts "puts '#{counter += 1}'" } # Displayed in first code block
puts counter # Displayed in second code block
-#+end_src
+#+end_src
-#+RESULTS:
-#+begin_src ruby
+#+RESULTS:
+#+begin_src ruby
puts '1'
puts '2'
puts '3'
@@ -67,9 +67,9 @@ About the #+RESULTS: block
puts '9'
puts '10'
10
-#+end_src
+#+end_src
-#+RESULTS:
+#+RESULTS:
: 10
@@ -78,26 +78,26 @@ 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.
-(message "hello world")
+(message "hello world")
The following is a code block written in Python
and its result should not be exported.
for i in range(0,12):
- print "import this"
+ print "import this"
:exports code
Only the code would be in the output,
the same as when no option is set.
-var message = "Hello world!";
+var message = "Hello world!";
console.log(message);
And as block example too:
-var message = "Hello world!";
-for (var i = 0; i< 10; i++) {
- console.log(message);
+var message = "Hello world!";
+for (var i = 0; i< 10; i++) {
+ console.log(message);
}
@@ -109,13 +109,13 @@
:exports none
:exports both
-Math::PI + 1
+Math::PI + 1
4.14159265358979
Should behave the same when within a block example.
-hello = <<HELLO
+hello = <<HELLO
The following is a text
that will contain at least 10 lines or more
so that when C-c C-c is pressed
diff --git a/spec/html_code_syntax_highlight_examples/code-pygments.html b/spec/html_code_syntax_highlight_examples/code-pygments.html
index 35b87d5..2a1e917 100644
--- a/spec/html_code_syntax_highlight_examples/code-pygments.html
+++ b/spec/html_code_syntax_highlight_examples/code-pygments.html
@@ -1,13 +1,13 @@
Simple Code Syntax highlighting test
-class Pygments
- class << self
- def colorize
- # Do colorizing stuff here
- heredoc = <<EOF
+class Pygments
+ class << self
+ def colorize
+ # Do colorizing stuff here
+ heredoc = <<EOF
Some text yay!!!
EOF
- end
- end
+ end
+ end
end
Now using EXAMPLE blocks instead:
@@ -24,10 +24,10 @@ Simple Code Syntax highlighting test
end
end
-class Piano
- def play_note(note)
- # TODO
- end
+class Piano
+ def play_note(note)
+ # TODO
+ end
end
When including a file as an src code file
diff --git a/spec/html_code_syntax_highlight_examples/prepended-comma-pygments.html b/spec/html_code_syntax_highlight_examples/prepended-comma-pygments.html
index 21c0473..4a51a27 100644
--- a/spec/html_code_syntax_highlight_examples/prepended-comma-pygments.html
+++ b/spec/html_code_syntax_highlight_examples/prepended-comma-pygments.html
@@ -4,36 +4,36 @@ Removing the prepended comma from Org mode src blocks
this prepended comma should be removed before parsing.
(Fixes https://github.com/bdewey/org-ruby/issues/50)
Here the prepended comma will be removed.
-* Hello
-** Goodbye
- *** Not a headline, but prepended comma still removed.
-* I am a headline
+* Hello
+** Goodbye
+ *** Not a headline, but prepended comma still removed.
+* I am a headline
Here the prepended comma is should not be removed.
{
- "one": 1
-, "two": 2
-, "three": 3
-, "four": 4
+ "one": 1
+, "two": 2
+, "three": 3
+, "four": 4
}
Here the prepended comma is also removed
Emacs Org mode implementation also removes it.
-text = <<TEXT
+text = <<TEXT
#+TITLE: Prepended comma world
* Hello world
More text here
TEXT
Here the prepended comma will be remove for the Hello world headline
-, ,* Hi
-,
-, ,* This will be appended a comma
-* Hello world
+, ,* Hi
+,
+, ,* This will be appended a comma
+* Hello world
,
Here the prepended comma will be removed
-#+TITLE: "Hello world"
+#+TITLE: "Hello world"
This will be rendered as normal
,,,,,,,,,,,,,,,,,*Hello world
diff --git a/spec/html_code_syntax_highlight_examples/src-code-list-pygments.html b/spec/html_code_syntax_highlight_examples/src-code-list-pygments.html
index 9aecede..e9102ee 100644
--- a/spec/html_code_syntax_highlight_examples/src-code-list-pygments.html
+++ b/spec/html_code_syntax_highlight_examples/src-code-list-pygments.html
@@ -1,20 +1,20 @@
begin src in lists should work
- Foo
-
class Hello
- def say
- puts 'cheers'
- end
+class Hello
+ def say
+ puts 'cheers'
+ end
end
- Bar
-
puts "This should not get lumped into the above line Example"
+puts "This should not get lumped into the above line Example"
A paragraph should go here.
- A sublist goes here with another example
-
echo "Hello"
+echo "Hello"
And this is a paragraph