gjtorikian / html-pipeline

HTML processing filters and utilities
MIT License
2.27k stars 383 forks source link

'lexer' is removed from github-linguist #217

Closed aptx4869 closed 3 years ago

aptx4869 commented 9 years ago

We get a

NoMethodError:
       undefined method `lexer' for #<Linguist::Language name=Ruby>

since github/linguist@5d0e9484ce9a3c1ae22637cfc61bda088a74c315 the `lexer' api is no longer exists Should we change

(Linguist::Language[lang] && Linguist::Language[lang].lexer) || Pygments::Lexer[lang]

into

 (Linguist::Language[lang] && Linguist::Language[lang].try(:lexer)) || Pygments::Lexer[lang]

or add some code to check github-linguist version?

jch commented 9 years ago

That fallback is already pretty confusing, so I'd rather not add another try to the mix. We could update the warning at the require, but it would still error out early. It's tricky because we don't require explicit versions for linguist.

royzinn commented 9 years ago

Hi, So, from the above, what would be the better solution to keep using SyntaxHighlighter? should I move to some specific earlier version of Linguist or is there another solution? Thanks in advance

jch commented 9 years ago

@aptx4869 I haven't come up with a better way to address this, so in the interest of maintaining semver, would you be up for creating a PR with your fix?

@royzinn as a temporary fix, I suggest applying @aptx4869's changes locally to your project. Alternatively, you can use an older version of linguist.

bmikol commented 9 years ago

Alternatively, you could also just use the HTML::Pipeline-rouge_filter - it's been working great for me.

jch commented 9 years ago

@bmikol :+1: totally forgot about that one.

royzinn commented 9 years ago

@bmikol @jch - thanks both! it works for me with rouge filter

gjtorikian commented 3 years ago

Old issue