Fix newlines being chomped in RSS import (#10476)
The CustomText converter was monkey patched to fix a bug related to preserve_tags. Somewhere in that process, remove_inner_newlines was changed to strip newlines completely, instead of replacing them with a single space. This restores that functionality. In development mode, files are not eager loaded. That means that the converters were not being required, so it was not possible to reproduce that issue in development mode (since it was falling back to the original converter, which does not have the bug). This commit also adds an initializer that requires every converter.
This commit is contained in:
parent
fe75dcde1c
commit
24e9f81f5a
3 changed files with 20 additions and 1 deletions
|
|
@ -40,7 +40,7 @@ module ReverseMarkdown
|
|||
end
|
||||
|
||||
def remove_inner_newlines(text)
|
||||
text.tr("\n\t", "")
|
||||
text.tr("\r\n\t", " ").squeeze(" ")
|
||||
end
|
||||
|
||||
def preserve_keychars_within_backticks(text)
|
||||
|
|
|
|||
3
config/initializers/reverse_markdown.rb
Normal file
3
config/initializers/reverse_markdown.rb
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Dir.glob(Rails.root.join("app/lib/reverse_markdown/converters/*.rb")).sort.each do |filename|
|
||||
require_dependency filename
|
||||
end
|
||||
16
spec/lib/reverse_markdown/converters/custom_text_spec.rb
Normal file
16
spec/lib/reverse_markdown/converters/custom_text_spec.rb
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe ReverseMarkdown::Converters::CustomText, type: :lib do
|
||||
def create_custom_text
|
||||
ReverseMarkdown.config.github_flavored = true
|
||||
described_class.new
|
||||
end
|
||||
|
||||
describe "#convert" do
|
||||
it "keeps some blankspace between lines in the same paragraph" do
|
||||
node = Nokogiri::HTML("newlines\nbecome\nspaces")
|
||||
result = create_custom_text.convert(node)
|
||||
expect(result).to eq("newlines become spaces")
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue