Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tilt 2.0.2 and later no longer looks for .md files when redcarpet is used #300

Closed
wants to merge 1 commit into from

Conversation

tommay
Copy link
Contributor

@tommay tommay commented Sep 25, 2016

I'm using markdown :somefile from haml, which with tilt 2.0.1 will find a file named "somefile.md" but which with tilt 2.0.2 and later will try only "somefile.markdown" and fail. This is because there's a call to register_lazy which is still using the obsolete name :RedcarpetTemplate when it needs to use :Redcarpet1Template and :Redcarpet2Template.

There is a variable Tilt::RedcarpetTemplate which is set to the class to use, but it's not yet set when register_lazy is called, so this patch just registers both, easy.

Sorry no test because I don't really understand enough of what's going on here to even know whether I made a good fix.

These are the new class names that replaced RedcarpetTemplate.  There
is a variable Tilt::RedcarpetTemplate which is set to the class to use,
but it's not yet set when register_lazy is called.
@tommay tommay changed the title registery_lazy :Redcarpet1Template and :Redcarpet2Template. Tilt 2.0.2 and later no longer looks for .md files when redcarpet is used Sep 25, 2016
@judofyr
Copy link
Collaborator

judofyr commented Sep 26, 2016

There is still a RedcarpetTemplate which is set depending on which version is loaded:

https://github.com/rtomayko/tilt/blob/master/lib/tilt/redcarpet.rb#L77

@judofyr
Copy link
Collaborator

judofyr commented Sep 26, 2016

Can give an example (for instance, a Ruby file + a Gemfile) of where it breaks down?

@tommay
Copy link
Contributor Author

tommay commented Sep 26, 2016

That variable is not yet set when the register_lazy calls happen.

I'll try to get a .rb + Gemfile together soonish, like today.

On Mon, Sep 26, 2016 at 6:54 AM, Magnus Holm notifications@github.com
wrote:

There is still a RedcarpetTemplate which is set depending on which
version is loaded:

https://github.com/rtomayko/tilt/blob/master/lib/tilt/redcarpet.rb#L77


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#300 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAGYHWDrIN7e7JUMW_Ov48WxITh5gYpWks5qt85_gaJpZM4KF0QT
.

@tommay
Copy link
Contributor Author

tommay commented Sep 27, 2016

Here's a Gemfile, Gemfile.lock, and bug.rb that prints out the Tilt.default_mapping.extensions_for Redcarpet2Template and for comparison BlueClothTemplate. Redcarpet2Template does not have the .mkd or .md extensions, so code that relies on this list won't find .md files when using redcarpet.

When I run it I get:
Extensions for Tilt::Redcarpet2Template: ["markdown"]
Extensions for Tilt::BlueClothTemplate: ["markdown", "mkd", "md"]

stuff.zip

@judofyr
Copy link
Collaborator

judofyr commented Sep 27, 2016

Huh. I see. It's only extensions_for that is broken though. This works as expected:

#!/usr/bin/env ruby

require "bundler/setup"
require "redcarpet"
require "tilt"

engine = Tilt.default_mapping[:markdown]
extensions = Tilt.default_mapping.extensions_for(engine)
puts "Extensions for #{engine}: #{extensions}"

engine = Tilt::BlueClothTemplate
extensions = Tilt.default_mapping.extensions_for(engine)
puts "Extensions for #{engine}: #{extensions}"

p Tilt[:md] # => Tilt::Redcarpet2Template

@judofyr
Copy link
Collaborator

judofyr commented Oct 26, 2019

The reason for not accepting this pull request was because I wasn't quite happy with approach. It felt like the incorrect fix, and I also think it caused problem because Tilt::RedcarpetTemplate would no longer be autoloaded (which is a breaking change). I've found a different solution which seems to work nicely: aea852b

@judofyr judofyr closed this Oct 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants