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

Projects
None yet
3 participants
@gpakosz
Copy link
Member

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)

This comment has been minimized.

Copy link
@ddfreyne

ddfreyne Oct 26, 2017

Member

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

@@ -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)

This comment has been minimized.

Copy link
@ddfreyne

ddfreyne Oct 26, 2017

Member

This change is missing a test case.

@gpakosz gpakosz force-pushed the gpakosz:relativize_paths branch 2 times, most recently from 4ec1409 to 57a7c41 Oct 26, 2017

# 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

This comment has been minimized.

Copy link
@denis-soundcloud

denis-soundcloud Oct 27, 2017

Contributor

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

This comment has been minimized.

Copy link
@gpakosz

gpakosz Oct 27, 2017

Author Member

Done

@gpakosz gpakosz force-pushed the gpakosz:relativize_paths branch from 57a7c41 to 7a460cf Oct 27, 2017

@ddfreyne ddfreyne merged commit 9a8d608 into nanoc:master Oct 27, 2017

3 checks passed

codecov/patch 100% of diff hit (target 98.24%)
Details
codecov/project 98.24% (+<.01%) compared to 6f84ecc
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@gpakosz gpakosz deleted the gpakosz:relativize_paths branch Nov 2, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.