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 :save_with parameter to relativize_paths #1237

Merged
merged 1 commit into from Oct 27, 2017

Conversation

@gpakosz
Copy link
Member

@gpakosz gpakosz commented Oct 25, 2017

Sometimes, you don't Nokogiri to reformat the document. Typically when you plan to style elements with white-space: pre;.

This PR adds a save_with parameter to the relativize_paths filter to which one can pass e.g. Nokogiri::XML::Node::SaveOptions::DEFAULT_HTML & ~Nokogiri::XML::Node::SaveOptions::FORMAT which clears the formatting bit from the default save options.

@@ -64,11 +64,12 @@ def relativize_html_like(content, params)
selectors = params.fetch(:select, SELECTORS)
namespaces = params.fetch(:namespaces, {})
type = params.fetch(:type)
save_with = params.fetch(:save_with, nil)
Copy link
Member

@ddfreyne ddfreyne Oct 26, 2017

Choose a reason for hiding this comment

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

The name save_with is confusing out of context; what about nokogiri_save_with?

Loading

@@ -64,11 +64,12 @@ def relativize_html_like(content, params)
selectors = params.fetch(:select, SELECTORS)
namespaces = params.fetch(:namespaces, {})
type = params.fetch(:type)
save_with = params.fetch(:save_with, nil)
Copy link
Member

@ddfreyne ddfreyne Oct 26, 2017

Choose a reason for hiding this comment

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

This change is missing a test case.

Loading

# Test
nokogiri_save_options = Nokogiri::XML::Node::SaveOptions::DEFAULT_HTML & ~Nokogiri::XML::Node::SaveOptions::FORMAT
actual_content = filter.setup_and_run(raw_content.freeze, type: :html, nokogiri_save_options: nokogiri_save_options)
assert actual_content == raw_content
Copy link
Contributor

@denis-soundcloud denis-soundcloud Oct 27, 2017

Choose a reason for hiding this comment

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

Prefer assert_equal(actual_content, raw_content) — the assertion failure message will be more clear.

Loading

Copy link
Member Author

@gpakosz gpakosz Oct 27, 2017

Choose a reason for hiding this comment

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

Done

Loading

@gpakosz gpakosz force-pushed the relativize_paths branch from 57a7c41 to 7a460cf Oct 27, 2017
@ddfreyne ddfreyne merged commit 9a8d608 into nanoc:master Oct 27, 2017
3 checks passed
Loading
@gpakosz gpakosz deleted the relativize_paths branch Nov 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants