Permalink
Browse files

Got rid of the extraneous newline at the start of code blocks.

  • Loading branch information...
1 parent 33bcfaf commit f90170113f4e74872af04966261f3d5c327b7f79 @bdewey committed Dec 29, 2009
View
@@ -1,5 +1,6 @@
== X.X.X / 2009-12-29
+* Got rid of the extraneous newline at the start of code blocks.
* Everything now shows up in code blocks, even org-mode metadata.
* Fixed bugs:
* Regressed smart double quotes with HTML escaping. Added a test
@@ -50,7 +50,7 @@ def pop_mode(mode = nil)
def flush!
escape_buffer!
- if current_mode == :code then
+ if @buffer_mode == :code then
# Whitespace is significant in :code mode. Always output the buffer
# and do not do any additional translation.
#
@@ -69,6 +69,7 @@ def flush!
end
end
@buffer = ""
+ @buffer_mode = nil
end
######################################################################
@@ -8,9 +8,14 @@ module Orgmode
# add a newline character prior emitting the output.
class OutputBuffer
- # This is the temporary buffer that we accumulate into.
+ # This is the accumulation buffer. It's a holding pen so
+ # consecutive lines of the right type can get stuck together
+ # without intervening newlines.
attr_reader :buffer
+ # This is the output mode of the accumulation buffer.
+ attr_reader :buffer_mode
+
# This is the overall output buffer
attr_reader :output
@@ -22,17 +27,22 @@ class OutputBuffer
def initialize(output)
@output = output
@buffer = ""
+ @buffer_mode = nil
@output_type = :start
@list_indent_stack = []
@paragraph_modifier = nil
@cancel_modifier = false
@mode_stack = []
- push_mode(:normal)
@logger = Logger.new(STDERR)
- @logger.level = Logger::WARN
+ if ENV['DEBUG']
+ @logger.level = Logger::DEBUG
+ else
+ @logger.level = Logger::WARN
+ end
@re_help = RegexpHelper.new
+ push_mode(:normal)
end
Modes = [:normal, :ordered_list, :unordered_list, :blockquote, :code, :table]
@@ -83,6 +93,11 @@ def exit_table?
# Accumulate the string @str@.
def << (str)
+ if @buffer_mode && @buffer_mode != current_mode then
+ raise "Accumulation buffer is mixing modes: @buffer_mode == #{@buffer_mode}, current_mode == #{current_mode}"
+ else
+ @buffer_mode = current_mode
+ end
@buffer << str
end
@@ -60,6 +60,7 @@ def flush!
@output << inline_formatting(@buffer) << "\n"
end
@buffer = ""
+ @buffer_mode = nil
end
@@ -2,7 +2,6 @@ <h1 class="title">Block Code</h1>
<p>I need to get block code examples working. In <code>orgmode</code>, they look like this:</p>
<pre>
-
def initialize(output)
@output = output
@buffer = ""
@@ -19,7 +18,6 @@ <h1 class="title">Block Code</h1>
<p>Putting in another paragraph for good measure.</p>
<p>Code should also get cancelled by a list, thus:</p>
<pre>
-
This is my code!
Another line!
@@ -1,7 +1,6 @@
<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@BRIAN-DESK
@@ -1,5 +1,4 @@
<pre>
-
&lt;li&gt;[ ] &amp;#8220;smart quotes&amp;#8221;&lt;/li&gt;
&lt;li&gt;[ ] I think I need this for &amp;#8216;single quotes&amp;#8217; too. Don&amp;#8217;t I?&lt;/li&gt;
&lt;li&gt;[ ] Em dashes would be great &amp;#8212; wouldn&amp;#8217;t they?&lt;/li&gt;
@@ -1,7 +1,6 @@
<h1 class="title">Metadata, etc.</h1>
<p>I normally filter out things that look like metadata. Can&#8217;t do it any more. I need to see all of the following:</p>
<pre>
-
* DONE Handle inline formatting
CLOSED: [2009-12-26 Sat 21:41]
:PROPERTIES:

0 comments on commit f901701

Please sign in to comment.