Michael Franzl
2012-Jan-23 11:16 UTC
[webgen-users] Current Webgen not compatible with newest Kramdown
I''m writing a Rails application that uses the Webgen API to generate static websites. Webgen currently requires kramdown-0.10.0. However, I also use a custom gem that requires the newest version of Kramdown. As it turns out, including both Webgen and my gem in the Rails app forces webgen to use the newest version too. Apparently you can''t have two gems use different versions of another gem. So the rendering of a website fails because Kramdown is not compatible with the newest kramdown-0.13.4: Error while rendering </test.en.html>: wrong number of arguments (1 for 2) kramdown (0.13.4) lib/kramdown/converter/html.rb:59:in `initialize'' webgen (0.5.13) lib/webgen/contentprocessor/kramdown/html.rb:10:in `initialize'' Would it be possible to make Webgen always use the newest version of Kramdown? Thanks, Michael
Michael Franzl
2012-Jan-23 12:15 UTC
[webgen-users] Current Webgen not compatible with newest Kramdown
As a workaround I tried to call the executable directly from Rails by `webgen` This also doesn''t work: (rdb:14) `webgen` /home/michael/.rvm/gems/ruby-1.9.2-p290 at global/gems/bundler-1.0.21/lib/bundler/rubygems_integration.rb:143:in `block in replace_gem'': webgen is not part of the bundle. Add it to Gemfile. (Gem::LoadError) from /home/michael/.rvm/gems/ruby-1.9.2-p290/bin/webgen:18:in `<main>'' If I add webgen to the Gemfile, there is the other problem again with the incompatibility between Webgen and the newest Kramdown. Michael On 01/23/2012 12:16 PM, Michael Franzl wrote:> I''m writing a Rails application that uses the Webgen API to generate > static websites. Webgen currently requires kramdown-0.10.0. However, I > also use a custom gem that requires the newest version of Kramdown. > > As it turns out, including both Webgen and my gem in the Rails app > forces webgen to use the newest version too. Apparently you can''t have > two gems use different versions of another gem. So the rendering of a > website fails because Kramdown is not compatible with the newest > kramdown-0.13.4: > > Error while rendering </test.en.html>: > wrong number of arguments (1 for 2) > > kramdown (0.13.4) lib/kramdown/converter/html.rb:59:in `initialize'' > webgen (0.5.13) lib/webgen/contentprocessor/kramdown/html.rb:10:in > `initialize'' > > Would it be possible to make Webgen always use the newest version of > Kramdown? > > Thanks, > Michael
Thomas Leitner
2012-Jan-23 16:03 UTC
[webgen-users] Current Webgen not compatible with newest Kramdown
On 2012-01-23 12:16 +0100 Michael Franzl wrote:> I''m writing a Rails application that uses the Webgen API to generate > static websites. Webgen currently requires kramdown-0.10.0. However, > I also use a custom gem that requires the newest version of Kramdown. > > As it turns out, including both Webgen and my gem in the Rails app > forces webgen to use the newest version too. Apparently you can''t > have two gems use different versions of another gem. So the rendering > of a website fails because Kramdown is not compatible with the newest > kramdown-0.13.4: > > Error while rendering </test.en.html>: > wrong number of arguments (1 for 2) > > kramdown (0.13.4) lib/kramdown/converter/html.rb:59:in `initialize'' > webgen (0.5.13) lib/webgen/contentprocessor/kramdown/html.rb:10:in > `initialize'' > > Would it be possible to make Webgen always use the newest version of > Kramdown?Put the following code in ext/init.rb of your webgen website or anywhere before using the webgen API: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ require ''kramdown'' require ''webgen/contentprocessor/kramdown'' class Webgen::ContentProcessor::Kramdown # Convert the content in +context+ to HTML. def call(context) doc = ::Kramdown::Document.new(context.content, context.website.config[''contentprocessor.kramdown.options''].merge(context.options[''contentprocessor.kramdown.options''] || {})) context.content = KramdownHtmlConverter.convert(doc.root, doc.options, context) doc.warnings.each do |warn| log(:warn) { "Warning while parsing <#{context.ref_node}> with kramdown: #{warn}" } end context end end class Webgen::ContentProcessor::Kramdown::KramdownHtmlConverter < Kramdown::Converter::Html def initialize(root, options, context) #:nodoc: super(root, options) @context = context @do_convert = if context.options.has_key?(''contentprocessor.kramdown.handle_links'') context.options[''contentprocessor.kramdown.handle_links''] else context.website.config[''contentprocessor.kramdown.handle_links''] end end # Convert the element tree under +root+ to HTML using the webgen +context+ object. def self.convert(root, options, context) new(root, options, context).convert(root) end def convert_a(el, indent) el.attr[''href''] = @context.tag(''relocatable'', {''path'' => el.attr[''href'']}) if @do_convert "<a#{html_attributes(el.attr)}>#{inner(el, indent)}</a>" end def convert_img(el, indent) el.attr[''src''] = @context.tag(''relocatable'', {''path'' => el.attr[''src'']}) if @do_convert "<img#{html_attributes(el.attr)} />" end end ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This should allow you to use webgen with kramdown 0.13.4. Note that this won''t work when you use the webgen executable provided via rubygems. Best regards, Thomas
Michael Franzl
2012-Jan-24 21:37 UTC
[webgen-users] Current Webgen not compatible with newest Kramdown
On 01/23/2012 05:03 PM, Thomas Leitner wrote:> This should allow you to use webgen with kramdown 0.13.4. Note that > this won''t work when you use the webgen executable provided via > rubygems.This worked like a charm! Thank you very much, Michael
Michael Franzl
2012-Aug-29 05:49 UTC
[webgen-users] Current Webgen not compatible with newest Kramdown
On 01/23/2012 12:16 PM, Michael Franzl wrote:> I''m writing a Rails application that uses the Webgen API to generate > static websites. Webgen currently requires kramdown-0.10.0. However, I > also use a custom gem that requires the newest version of Kramdown. > > As it turns out, including both Webgen and my gem in the Rails app > forces webgen to use the newest version too.I just discovered that when running my gem standalone, in which I have the following Gemfile: gem ''webgen'', ''0.5.13'' gem ''kramdown'', ''0.13.7'' only kramdown 0.10.0 is used, which is unfortunately too ancient for my purposes. Is there any way to use both webgen API and the newest kramdown API in a gem? Michael
Thomas Leitner
2012-Aug-29 06:32 UTC
[webgen-users] Current Webgen not compatible with newest Kramdown
On 2012-08-29 07:49 +0200 Michael Franzl wrote:> On 01/23/2012 12:16 PM, Michael Franzl wrote: > > I''m writing a Rails application that uses the Webgen API to generate > > static websites. Webgen currently requires kramdown-0.10.0. > > However, I also use a custom gem that requires the newest version > > of Kramdown. > > > > As it turns out, including both Webgen and my gem in the Rails app > > forces webgen to use the newest version too. > > I just discovered that when running my gem standalone, in which I > have the following Gemfile: > > gem ''webgen'', ''0.5.13'' > gem ''kramdown'', ''0.13.7'' > > only kramdown 0.10.0 is used, which is unfortunately too ancient for > my purposes. > > Is there any way to use both webgen API and the newest kramdown API > in a gem?Not with this version of webgen, no... I have just released a temporary fix, webgen 0.5.15 should hopefully work fine with the above setup. Best regards, Thomas
Michael Franzl
2012-Aug-29 08:04 UTC
[webgen-users] Current Webgen not compatible with newest Kramdown
On 08/29/2012 08:32 AM, Thomas Leitner wrote:> Not with this version of webgen, no... I have just released a temporary > fix, webgen 0.5.15 should hopefully work fine with the above setup.It''s working and looking very good. Thanks so much for the quick reply! Michael