Skip to content

Commit

Permalink
Bug fix: textile syntax code wasn't converting ampersands back. Also …
Browse files Browse the repository at this point in the history
…disabled Textile ALL CAPS option.
  • Loading branch information
fnando committed Aug 14, 2009
1 parent 779af71 commit 2b39d8c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.3.7
0.3.8
4 changes: 2 additions & 2 deletions kitabu.gemspec
Expand Up @@ -2,11 +2,11 @@

Gem::Specification.new do |s|
s.name = %q{kitabu}
s.version = "0.3.7"
s.version = "0.3.8"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Nando Vieira"]
s.date = %q{2009-08-13}
s.date = %q{2009-08-14}
s.default_executable = %q{kitabu}
s.description = %q{A framework for creating e-books from Markdown/Textile text markup using Ruby.
Using the Prince PDF generator, you'll be able to get high quality PDFs.
Expand Down
2 changes: 1 addition & 1 deletion lib/kitabu.rb
Expand Up @@ -19,5 +19,5 @@
end

module Kitabu
VERSION = "0.3.7"
VERSION = "0.3.8"
end
5 changes: 3 additions & 2 deletions lib/kitabu/base.rb
Expand Up @@ -113,6 +113,7 @@ def generate_html
begin
if markup_file =~ /\.textile$/
markup = BlackCloth.new(markup_contents)
markup.no_span_caps = true
else
markup = markdown_processor_class.new(markup_contents)
end
Expand All @@ -129,7 +130,7 @@ def generate_html
# textile
parsed_contents.gsub!(/@syntax:([0-9]+)/m) do |m|
syntax, code = markup.syntax_blocks[$1.to_i]
Kitabu::Markup.syntax(code, syntax)
Kitabu::Markup.syntax(code, syntax, :textile)
end
else
# markdown
Expand Down Expand Up @@ -164,7 +165,7 @@ def generate_html
})
end

Kitabu::Markup.syntax(code, syntax)
Kitabu::Markup.syntax(code, syntax, :markdown)
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/kitabu/blackcloth.rb
Expand Up @@ -82,6 +82,7 @@ def textile_syntax(tag, attrs, cite, content)
:from_line => from_line,
:to_line => to_line
})

@@syntax_blocks << [syntax, content]
position = @@syntax_blocks.size - 1
%(@syntax:#{position})
Expand Down Expand Up @@ -169,7 +170,7 @@ def to_html( *rules )
retrieve text

text.gsub!( /<\/?notextile>/, '' )
text.gsub!( /x%x%/, '&#38;' )
text.gsub!( /x%x%/sm, '&#38;' )
clean_html text if filter_html
text.strip!
text
Expand Down
6 changes: 5 additions & 1 deletion lib/kitabu/markup.rb
Expand Up @@ -46,14 +46,18 @@ def content_for(options)
code
end

def syntax(code, syntax='plain_text')
def syntax(code, syntax, processor)
# get chosen theme
theme = Kitabu::Base.config['theme']
theme = Kitabu::Base.default_theme unless Kitabu::Base.theme?(theme)

syntax = "plain_text" if syntax.to_s =~ /^\s*$/

# get syntax
syntax = Kitabu::Base.default_syntax unless Kitabu::Base.syntax?(syntax)

code.gsub!(/x%x%/sm, "&") if processor == :textile

code = Uv.parse(code, "xhtml", syntax, false, theme)
code.gsub!(/<pre class="(.*?)"/sim, %(<pre class="\\1 #{syntax}"))
code.gsub!(/<pre>/sim, %(<pre class="#{syntax} #{theme}"))
Expand Down

0 comments on commit 2b39d8c

Please sign in to comment.