[DRE-commits] [ruby-org] 51/303: Added support for exporting comments inside code blocks.

Jérémy Bobbio lunar at alioth.debian.org
Fri Aug 9 17:33:26 UTC 2013


This is an automated email from the git hooks/post-receive script.

lunar pushed a commit to branch master
in repository ruby-org.

commit 49ed71fb7fd7b72324c16f48f453a575a7a731af
Author: Brian Dewey <bdewey at gmail.com>
Date:   Tue Dec 29 01:22:06 2009 -0800

    Added support for exporting comments inside code blocks.
---
 History.txt                                  |    3 ++-
 lib/org-ruby/html_output_buffer.rb           |    8 ++++++-
 lib/org-ruby/line.rb                         |   15 ++++++++-----
 spec/html_examples/code-comment.html         |   19 ++++++++++++++++
 spec/html_examples/code-comment.org          |   22 +++++++++++++++++++
 spec/html_examples/metadata-comment.org-fail |   30 ++++++++++++++++++++++++++
 6 files changed, 90 insertions(+), 7 deletions(-)

diff --git a/History.txt b/History.txt
index 472461c..de20948 100644
--- a/History.txt
+++ b/History.txt
@@ -1,6 +1,7 @@
 == 0.4.1 / 2009-12-29
 
-* HTML is now escaped by default.
+* HTML is now escaped by default
+* org-mode comments will show up in a code block.
 
 == 0.4.0 / 2009-12-28
 
diff --git a/lib/org-ruby/html_output_buffer.rb b/lib/org-ruby/html_output_buffer.rb
index c5bf4cc..1caca78 100644
--- a/lib/org-ruby/html_output_buffer.rb
+++ b/lib/org-ruby/html_output_buffer.rb
@@ -32,6 +32,7 @@ module Orgmode
     def push_mode(mode)
       if ModeTag[mode] then
         output_indentation
+        @logger.debug "<#{ModeTag[mode]}>\n" 
         @output << "<#{ModeTag[mode]}>\n" 
         # Entering a new mode obliterates the title decoration
         @title_decoration = ""
@@ -43,19 +44,24 @@ module Orgmode
       m = super(mode)
       if ModeTag[m] then
         output_indentation
+        @logger.debug "</#{ModeTag[m]}>\n"
         @output << "</#{ModeTag[m]}>\n"
       end
     end
 
     def flush!
-      @logger.debug "FLUSH ==========> #{@output_type}"
       escape_buffer!
       if current_mode == :code then
         # Whitespace is significant in :code mode. Always output the buffer
         # and do not do any additional translation.
+        # 
+        # FIXME 2009-12-29 bdewey: It looks like I'll always get an extraneous
+        # newline at the start of code blocks. Find a way to fix this.
+        @logger.debug "FLUSH CODE ==========> #{@buffer.inspect}"
         @output << @buffer << "\n"
       else
         if (@buffer.length > 0) then
+          @logger.debug "FLUSH      ==========> #{@output_type}"
           output_indentation
           @output << "<#{HtmlBlockTag[@output_type]}#{@title_decoration}>" \
             << inline_formatting(@buffer) \
diff --git a/lib/org-ruby/line.rb b/lib/org-ruby/line.rb
index a96b4e8..e39da47 100644
--- a/lib/org-ruby/line.rb
+++ b/lib/org-ruby/line.rb
@@ -135,14 +135,19 @@ module Orgmode
         case line.paragraph_type
         when :metadata, :table_separator, :blank
 
-          # IGNORE
+          output_buffer << line.line if output_buffer.preserve_whitespace?          
 
         when :comment
           
-          output_buffer.push_mode(:blockquote) if line.begin_block? and line.block_type == "QUOTE"
-          output_buffer.push_mode(:code) if line.begin_block? and line.block_type == "EXAMPLE"
-          output_buffer.pop_mode(:blockquote) if line.end_block? and line.block_type == "QUOTE"
-          output_buffer.pop_mode(:code) if line.end_block? and line.block_type == "EXAMPLE"
+          if line.begin_block?
+            output_buffer.push_mode(:blockquote) if line.block_type == "QUOTE"
+            output_buffer.push_mode(:code) if line.block_type == "EXAMPLE"
+          elsif line.end_block?
+            output_buffer.pop_mode(:blockquote) if line.block_type == "QUOTE"
+            output_buffer.pop_mode(:code) if line.block_type == "EXAMPLE"
+          else
+            output_buffer << line.line if output_buffer.preserve_whitespace?
+          end
 
         when :table_row
 
diff --git a/spec/html_examples/code-comment.html b/spec/html_examples/code-comment.html
new file mode 100644
index 0000000..e934998
--- /dev/null
+++ b/spec/html_examples/code-comment.html
@@ -0,0 +1,19 @@
+<h1 class="title">Code Comment</h1>
+<p>I need to be able to export things that look like org-mode comments inside of code blocks, like this:</p>
+<pre>
+
+#+TITLE:     orgmode_parser.org
+#+AUTHOR:    
+#+EMAIL:     brian at BRIAN-DESK
+#+DATE:      2009-12-29 Tue
+#+DESCRIPTION: 
+#+KEYWORDS: 
+#+LANGUAGE:  en
+#+OPTIONS:   H:3 num:t toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+#+OPTIONS:   TeX:t LaTeX:nil skip:nil d:nil todo:t pri:nil tags:not-in-toc
+#+INFOJS_OPT: view:nil toc:nil ltoc:t mouse:underline buttons:0 path:http://orgmode.org/org-info.js
+#+EXPORT_SELECT_TAGS: export
+#+EXPORT_EXCLUDE_TAGS: noexport
+#+LINK_UP:   
+#+LINK_HOME: 
+</pre>
diff --git a/spec/html_examples/code-comment.org b/spec/html_examples/code-comment.org
new file mode 100644
index 0000000..6eb5a3c
--- /dev/null
+++ b/spec/html_examples/code-comment.org
@@ -0,0 +1,22 @@
+* Code Comment
+
+I need to be able to export things that look like org-mode comments
+inside of code blocks, like this:
+
+   #+BEGIN_EXAMPLE
+#+TITLE:     orgmode_parser.org
+#+AUTHOR:    
+#+EMAIL:     brian at BRIAN-DESK
+#+DATE:      2009-12-29 Tue
+#+DESCRIPTION: 
+#+KEYWORDS: 
+#+LANGUAGE:  en
+#+OPTIONS:   H:3 num:t toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+#+OPTIONS:   TeX:t LaTeX:nil skip:nil d:nil todo:t pri:nil tags:not-in-toc
+#+INFOJS_OPT: view:nil toc:nil ltoc:t mouse:underline buttons:0 path:http://orgmode.org/org-info.js
+#+EXPORT_SELECT_TAGS: export
+#+EXPORT_EXCLUDE_TAGS: noexport
+#+LINK_UP:   
+#+LINK_HOME: 
+   #+END_EXAMPLE
+
diff --git a/spec/html_examples/metadata-comment.org-fail b/spec/html_examples/metadata-comment.org-fail
new file mode 100644
index 0000000..36d24ef
--- /dev/null
+++ b/spec/html_examples/metadata-comment.org-fail
@@ -0,0 +1,30 @@
+* Metadata, etc.
+
+I normally filter out things that look like metadata. Can't do it any
+more. I need to see all of the following:
+
+#+BEGIN_EXAMPLE
+* DONE Handle inline formatting
+  CLOSED: [2009-12-26 Sat 21:41]
+  :PROPERTIES:
+  :ARCHIVE_TIME: 2009-12-26 Sat 22:16
+  :ARCHIVE_FILE: ~/brians-brain/content/projects/orgmode_parser.org
+  :ARCHIVE_OLPATH: <%= @page.title %>/Future Development
+  :ARCHIVE_CATEGORY: orgmode_parser
+  :ARCHIVE_TODO: DONE
+  :END:
+
+  I still need to handle:
+
+  - [ ] =Inline code=
+
+  How does the =emacs= HTML parser handle *inline* formatting? Ah,
+  it looks like it defines everything in =org-emphasis-alist= (line
+  2855 of =org.el=).
+
+  And then look at =org-emphasis-regexp-components=, line 2828 of
+  =org.el=. It looks like they just use a crazy regexp for inline
+  formatting. Which is good, because it means I can copy!
+
+
+#+END_EXAMPLE

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-org.git



More information about the Pkg-ruby-extras-commits mailing list