Skip to content

Commit

Permalink
Remove entity output option
Browse files Browse the repository at this point in the history
Prior to post-processing being introduced to govspeak we had the ability
to specify the entity_output of the HTML. By using nokogiri to format
to format the HTML we lose the ability to do this as nokogiri will
automatically perform conversions to the entities.

In cases where nokogiri encounters a encoded HTML entity that it can
safely output as a utf-8 character it will automatically replace the
entity with the character. For example: `¥` is converted to `¥`

In cases where nokogiri encounters a numeric HTML entity it will convert
that into a symbolic one. For example: `>` is converted to `>`

I haven't found any instances where our applications are using the
`:numeric` option and believe it was only introduced as an option as a
side effect of a different change, rather than being something that was
required:
74ea8c7
  • Loading branch information
kevindew committed Aug 5, 2016
1 parent 7a597b7 commit 7f5b905
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/govspeak.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def initialize(source, options = {})
@images = options.delete(:images) || []
@attachments = Array(options.delete(:attachments))
@locale = options.fetch(:locale, "en")
@options = {input: PARSER_CLASS_NAME, entity_output: :symbolic}.merge(options)
@options = {input: PARSER_CLASS_NAME}.merge(options)
@options[:entity_output] = :symbolic
i18n_load_paths
end

Expand Down
6 changes: 3 additions & 3 deletions test/govspeak_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,9 @@ class GovspeakTest < Minitest::Test
refute html.include?('rel="external"'), "should not automatically add rel external attribute"
end

test "should be able to override default 'entity output' option" do
html = Govspeak::Document.new("&yen;", entity_output: :numeric).to_html
assert html.include?("&#165;")
test "should not be able to override default 'entity output' option" do
html = Govspeak::Document.new("&gt;", entity_output: :numeric).to_html
assert html.include?("&gt;")
end

test "should assume a link with an invalid uri is internal" do
Expand Down

0 comments on commit 7f5b905

Please sign in to comment.