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

Kramdown warnings #967

Merged
merged 2 commits into from
Oct 29, 2016
Merged

Kramdown warnings #967

merged 2 commits into from
Oct 29, 2016

Conversation

gpakosz
Copy link
Member

@gpakosz gpakosz commented Oct 23, 2016

Summary

This PR does two things in two commits:

To do

The :warning_filters array should be documented on https://nanoc.ws as part of the filters reference documentation.


# Run filter
io = capturing_stdio do
filter.setup_and_run('{:foo}this is bogus')
end
assert_empty io[:stdout]
assert_equal "kramdown warning: Found span IAL after text - ignoring it\n", io[:stderr]
assert_equal "kramdown warning(s) for item, rep: #{item.identifier}, #{item_rep.name}\n Found span IAL after text - ignoring it\n", io[:stderr]
Copy link
Member

Choose a reason for hiding this comment

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

I’d replace

"… item, rep: #{item.identifier}, #{item_rep.name}"

with

"… #{item_rep.inspect}"
@denisdefreyne
Copy link
Member

Looks good! There’s a couple of style issues that Travis CI complains about still.

warnings = document.warnings
end

if warnings.length != 0
Copy link
Member

Choose a reason for hiding this comment

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

Replace this with warnings.any? (I know Rubocop says warnings.length.nonzero? but that’s not as nice.)

$stderr.puts "kramdown warning: #{warning}"
if (warning_filters)
r = Regexp.union(warning_filters)
warnings = document.warnings.select { |warning| !(r =~ warning) }
Copy link
Member

Choose a reason for hiding this comment

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

Replace

!(r =~ warning)

with

r !~ warning

Or alternatively, replace

select { |warning| !(r =~ warning) }

with

reject { |warning| r =~ warning }
@denisdefreyne
Copy link
Member

Does it make sense to provide the warning filters via the configuration file, rather than arguments to the filter call? That’d make the dup dance unnecessary, and I guess it’d avoid having to copy the filter warnings if you call the :kramdown filter more than once…

@gpakosz
Copy link
Member Author

gpakosz commented Oct 23, 2016

I took your comments into account.

Well in my setup, I was already doing e.g in nanoc.yaml.

# erb filter options
erb:
  trim_mode: '<>'

and then when filtering

filter :erb, @config[:erb] || {}

A quick grep didn't really exhibit existing filters reading their options straight from @config, do you want to introduce a new behavior? (which kinda opens other questions like @config[:kramdown][:warning_filters] or @config[:kramdown_warning_filters] 🤔 ?)

@connorshea
Copy link

This is awesome, I've wanted this myself. Thanks @gpakosz!

@denisdefreyne
Copy link
Member

I’m OK with leaving it as a filter argument, as it’s more flexible, and still leaves open the option for using the configuration in the way you described.

Is this still WIP or is it ready to go?

@denisdefreyne denisdefreyne merged commit e51fb4b into nanoc:master Oct 29, 2016
@gpakosz gpakosz deleted the kramdown-warnings branch February 28, 2017 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants