asciidoctor / asciidoctor-latex

:triangular_ruler: Add LaTeX features to AsciiDoc & convert AsciiDoc to LaTeX
http://asciidoctor.org
Other
111 stars 26 forks source link

Prepend hack #40

Closed jxxcarlson closed 8 years ago

jxxcarlson commented 8 years ago

@mojavelinux, @Mogztter , @jirutka -- if you have a chance, could you look at the prepend-hack2 branch of asciidoctor-latex? This is a proposed workaround to avoid Ruby 2.0 prepend, based on @mojavelinex's code. It seems to me that in this case one does not have to remove methods before including the Html5ConverterExtensions module.

I've only done one test, but it seems to work. It this is indeed the case, then the road is open for Chrome extension, Atom, etc., to support asciidoctor-latex. For us mathematicians, that would be awesome indeed.

I will do more testing. PS. @jirutka: ping!

jxxcarlson commented 8 years ago

The branch that should be merged with master if all is OK is prepend-hack, which deploys the hack only if prepend is not available. The branch prepend-hack2 is useful because the hack is forced in all situations, making testing easier. I've now tested it on a 60 page asciidoctor-latex file full of math.

jirutka commented 8 years ago

Why do you bother with pre-2.0 compatibility? MRI 1.9.3 is not officially supported anymore and JRuby 9.0.0.0 will be released soon.

jxxcarlson commented 8 years ago

The issue is cross-compilation with Opal so that asciidoctor-latex can be used with @Mogztter's chrome extension, with Atom, etc. It is a single Ruby 2.0+ issue: the use of prepend. Opal does not support prepend

jxxcarlson commented 8 years ago

See #26 and recent comment there

mojavelinux commented 8 years ago

Indeed, this is an issue we have to work around in Opal. Although, I'm still not prepared to drop 1.9.3 in the Asciidoctor ecosystem until I stop coming across OSX boxes with 1.9.3 installed by default. It's a big support overhead for us to help people upgrade their Ruby installation, so I like to go by what's available by default as the minimum version. We're still living in a 1.9.3 world.

The prepend hack looks good...though you may not even need the version switch. Just use the "include" method with a note that eventually you want to switch to "prepend". I left it the way I did in Asciidoctor PDF basically as a demonstration to contrast the options.

Keep in mind that when you use "include", the parent class is no longer the original class. Instead, you are replacing the original method. That's what makes "prepend" so special and awesome (and for now, out of reach). "prepend" actually inserts the method into the object hierarchy. So you'll have to look for any places that you rely on that behavior. If not, you are totally clear.

jirutka commented 8 years ago

…until I stop coming across OSX boxes with 1.9.3 installed by default.

The latest stable version of OS X is 10.10.x (Yosemite), 10.11.x (El Capitan) will be released this autumn. Upgrades are free and available for all Intel-based Macks (a colleague of mine has Yosemite on ~7 years old MacBook Pro). I’m using OS X 10.9.5 (Mavericks), so I’m one major version behind (b/c I hate UI redesign)… and yet, my system Ruby (i.e. “preinstalled”) version is 2.0.0p481.

This means that these boxes you’re talking about must be very outdated. Why you (we) should suffer for people that are just lazy/incompetent/ignorant/whatever to update their system? Moreover, it’s super easy to install recent Ruby on OS X, thanks to Homebrew.

Exaggerated backward compatibility is harmful.

We're still living in a 1.9.3 world.

Nope, 1.9.3 is officially dead (unsupported). ;)

mojavelinux commented 8 years ago

Why you (we) should suffer for people that are just lazy to update their system?

It's my own suffering I want to avoid :)

jirutka commented 8 years ago

Well, we can bundle Asciidoctor with Ruby into one (bloated) binary package for these people with outdated system. It’s ugly “enterprise” style of software distribution and I personally hate it, but it may suite well in this particular case. What do you think?

mojavelinux commented 8 years ago

:)