[DRE-commits] [ruby-org] 93/303: Implemented #+BEGIN/END_CENTER to center text (works with textile and HTML)
Jérémy Bobbio
lunar at alioth.debian.org
Fri Aug 9 17:33:34 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 8deb95eb597b1ce62078dfe45d1a83ec204c3468
Author: Rüdiger Sonderfeld <ruediger at c-plusplus.de>
Date: Thu Jul 21 02:09:21 2011 +0200
Implemented #+BEGIN/END_CENTER to center text (works with textile and HTML)
---
lib/org-ruby/html_output_buffer.rb | 4 +++-
lib/org-ruby/output_buffer.rb | 2 +-
lib/org-ruby/parser.rb | 2 ++
lib/org-ruby/textile_output_buffer.rb | 2 ++
spec/html_examples/center.html | 6 ++++++
spec/html_examples/center.org | 7 +++++++
spec/textile_examples/center.org | 7 +++++++
spec/textile_examples/center.textile | 6 ++++++
8 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/lib/org-ruby/html_output_buffer.rb b/lib/org-ruby/html_output_buffer.rb
index 665f904..4a7c39f 100644
--- a/lib/org-ruby/html_output_buffer.rb
+++ b/lib/org-ruby/html_output_buffer.rb
@@ -28,7 +28,8 @@ module Orgmode
:blockquote => "blockquote",
:example => "pre",
:src => "pre",
- :inline_example => "pre"
+ :inline_example => "pre",
+ :center => "div"
}
attr_reader :options
@@ -53,6 +54,7 @@ module Orgmode
css_class = ""
css_class = " class=\"src\"" if mode == :src
css_class = " class=\"example\"" if (mode == :example || mode == :inline_example)
+ css_class = " style=\"text-align: center\"" if mode == :center
@logger.debug "#{mode}: <#{ModeTag[mode]}#{css_class}>\n"
@output << "<#{ModeTag[mode]}#{css_class}>\n" unless mode == :table and skip_tables?
# Entering a new mode obliterates the title decoration
diff --git a/lib/org-ruby/output_buffer.rb b/lib/org-ruby/output_buffer.rb
index e1a68c8..a0d472f 100644
--- a/lib/org-ruby/output_buffer.rb
+++ b/lib/org-ruby/output_buffer.rb
@@ -54,7 +54,7 @@ module Orgmode
push_mode(:normal)
end
- Modes = [:normal, :ordered_list, :unordered_list, :definition_list, :blockquote, :src, :example, :table, :inline_example]
+ Modes = [:normal, :ordered_list, :unordered_list, :definition_list, :blockquote, :src, :example, :table, :inline_example, :center]
def current_mode
@mode_stack.last
diff --git a/lib/org-ruby/parser.rb b/lib/org-ruby/parser.rb
index d8afb8b..27f8b7a 100644
--- a/lib/org-ruby/parser.rb
+++ b/lib/org-ruby/parser.rb
@@ -224,12 +224,14 @@ module Orgmode
output_buffer.push_mode(:blockquote) if line.block_type.casecmp("QUOTE") == 0
output_buffer.push_mode(:src) if line.block_type.casecmp("SRC") == 0
output_buffer.push_mode(:example) if line.block_type.casecmp("EXAMPLE") == 0
+ output_buffer.push_mode(:center) if line.block_type.casecmp("CENTER") == 0
when :end_block
output_buffer.pop_mode(:blockquote) if line.block_type.casecmp("QUOTE") == 0
output_buffer.pop_mode(:src) if line.block_type.casecmp("SRC") == 0
output_buffer.pop_mode(:example) if line.block_type.casecmp("EXAMPLE") == 0
+ output_buffer.pop_mode(:center) if line.block_type.casecmp("CENTER") == 0
when :table_row, :table_header
diff --git a/lib/org-ruby/textile_output_buffer.rb b/lib/org-ruby/textile_output_buffer.rb
index a794f49..2ab0eba 100644
--- a/lib/org-ruby/textile_output_buffer.rb
+++ b/lib/org-ruby/textile_output_buffer.rb
@@ -12,11 +12,13 @@ module Orgmode
def push_mode(mode)
super(mode)
@output << "bc.. " if mode_is_code(mode)
+ @output << "\np=. " if mode == :center
end
def pop_mode(mode = nil)
m = super(mode)
@add_paragraph = (mode_is_code(m))
+ @output << "\n" if mode == :center
m
end
diff --git a/spec/html_examples/center.html b/spec/html_examples/center.html
new file mode 100644
index 0000000..a3dfa22
--- /dev/null
+++ b/spec/html_examples/center.html
@@ -0,0 +1,6 @@
+<p class="title">Fou</p>
+<p>not center</p>
+<div style="text-align: center">
+ <p>center</p>
+</div>
+<p>not center, again</p>
diff --git a/spec/html_examples/center.org b/spec/html_examples/center.org
new file mode 100644
index 0000000..8358062
--- /dev/null
+++ b/spec/html_examples/center.org
@@ -0,0 +1,7 @@
+#+TITLE: Fou
+
+not center
+#+BEGIN_CENTER
+center
+#+END_CENTER
+not center, again
diff --git a/spec/textile_examples/center.org b/spec/textile_examples/center.org
new file mode 100644
index 0000000..8358062
--- /dev/null
+++ b/spec/textile_examples/center.org
@@ -0,0 +1,7 @@
+#+TITLE: Fou
+
+not center
+#+BEGIN_CENTER
+center
+#+END_CENTER
+not center, again
diff --git a/spec/textile_examples/center.textile b/spec/textile_examples/center.textile
new file mode 100644
index 0000000..e8b7d83
--- /dev/null
+++ b/spec/textile_examples/center.textile
@@ -0,0 +1,6 @@
+
+not center
+
+p=. center
+
+not center, again
--
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