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

Add smartify Liquid filter for SmartyPants #4323

Merged
merged 2 commits into from Jan 10, 2016
Merged

Add smartify Liquid filter for SmartyPants #4323

merged 2 commits into from Jan 10, 2016

Conversation

pathawks
Copy link
Member

@pathawks pathawks commented Jan 7, 2016

Is there a better place to put the Kramdown::Parser::SmartyPants class?

Am I on the right track with this?

@pathawks
Copy link
Member Author

pathawks commented Jan 7, 2016

@envygeeks
Copy link
Contributor

This is a tough spot, I don't know how @jekyll/core likes file organization in that aspect. For my own libs and apps, I would put it in lib/kramdown/parser/smarty_pants even if I had lib/jekyll but not all authors are strict in that way in that the class must point to the file or I'm doing it wrong.

@parkr
Copy link
Member

parkr commented Jan 7, 2016

How does the SmartyPants converter hook into Kramdown::Parser::SmartyPants?

@parkr
Copy link
Member

parkr commented Jan 8, 2016

Hm. Ok. Can it point to a class in our namespace? I'm generally weary of writing something in someone else's namespace.

@pathawks
Copy link
Member Author

pathawks commented Jan 8, 2016

Can it point to a class in our namespace?

Yes, good call. How does this look?

The failing tests freaked me out since they are related to Kramdown, but they are the same tests that are failing on master, so...

@pathawks
Copy link
Member Author

pathawks commented Jan 8, 2016

There is one test that fails on Ruby 2.0 and nothing else:

Error:
TestFilters#test_: filters should smartify with simple string. :
NameError: wrong constant name Jekyll::Converters::SmartyPants::KramdownParser
    /home/travis/build/jekyll/jekyll/vendor/bundle/ruby/2.0.0/gems/kramdown-1.9.0/lib/kramdown/document.rb:106:in `const_defined?'
    /home/travis/build/jekyll/jekyll/vendor/bundle/ruby/2.0.0/gems/kramdown-1.9.0/lib/kramdown/document.rb:106:in `initialize'
    /home/travis/build/jekyll/jekyll/lib/jekyll/converters/smartypants.rb:23:in `new'
    /home/travis/build/jekyll/jekyll/lib/jekyll/converters/smartypants.rb:23:in `convert'
    /home/travis/build/jekyll/jekyll/lib/jekyll/filters.rb:26:in `smartify'
    /home/travis/build/jekyll/jekyll/test/test_filters.rb:35:in `block (2 levels) in <class:TestFilters>'
    /home/travis/build/jekyll/jekyll/vendor/bundle/ruby/2.0.0/gems/shoulda-context-1.2.1/lib/shoulda/context/context.rb:413:in `instance_exec'
    /home/travis/build/jekyll/jekyll/vendor/bundle/ruby/2.0.0/gems/shoulda-context-1.2.1/lib/shoulda/context/context.rb:413:in `block in create_test_from_should_hash'

Any idea what could be tripping up Ruby 2.0?

@pathawks
Copy link
Member Author

pathawks commented Jan 8, 2016

Can it point to a class in our namespace? I'm generally weary of writing something in someone else's namespace.

According to Kramdown:

The special options key :input can be used to select the parser that should parse the source. It has to be the name of a class in the Kramdown::Parser module.

It seems to work anyway, but maybe this is the cause of the Ruby 2.0 fail?

@parkr
Copy link
Member

parkr commented Jan 8, 2016

The special options key :input can be used to select the parser that should parse the source. It has to be the name of a class in the Kramdown::Parser module.

Ah, very interesting. So I guess we do. If it's that small, I don't mind it being in the smartypants converter.

@@ -172,6 +172,7 @@ def sanitized_path(base_directory, questionable_path)
require_all 'jekyll/commands'
require_all 'jekyll/converters'
require_all 'jekyll/converters/markdown'
require_all 'jekyll/converters/smartypants'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be covered by line 173 :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 173 included jekyll/converters/smartypants.rb but not jekyll/converters/smartypants/kramdown_parser.rb

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think both those requires should be put into jekyll/converters tbh, they are subs of it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One is a sub of Kramdown::Parser::Markdown, another of Jekyll::Converter?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parkr wat? I'm talking about the markdown and smartypants requires, both those belong in jekyll/coverters.rb.

@pathawks
Copy link
Member Author

pathawks commented Jan 8, 2016

If it's that small, I don't mind it being in the smartypants converter.

In the same file?

@parkr
Copy link
Member

parkr commented Jan 8, 2016

In the same file?

Yeah. It's like 5 lines, right?

@pathawks
Copy link
Member Author

pathawks commented Jan 9, 2016

I have added several tests, and am now allowing HTML to passthrough. There are separate filters that will escape/strip HTML, if that is desired.

@pathawks
Copy link
Member Author

Just for reference, I brought up the idea of adding this parser to kramdown proper.

gettalong/kramdown#299

@parkr parkr changed the title Add smartify filter for SmartyPants Add smartify Liquid filter for SmartyPants Jan 10, 2016
@parkr
Copy link
Member

parkr commented Jan 10, 2016

@jekyllbot: merge +minor

jekyllbot added a commit that referenced this pull request Jan 10, 2016
@jekyllbot jekyllbot merged commit 15eaefa into jekyll:master Jan 10, 2016
jekyllbot added a commit that referenced this pull request Jan 10, 2016
@pathawks pathawks deleted the smartypants branch January 10, 2016 00:20
@parkr
Copy link
Member

parkr commented Jan 10, 2016

Most useful robot EVER.

@ndarville
Copy link
Contributor

Would definitely love an alternative to {{ page.title | markdownify | strip_html }}. :)

@jekyll jekyll locked and limited conversation to collaborators Jul 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants