Skip to content

Commit f772a26

Browse files
authored
Merge pull request #4 from rcmoret/update-plain-serializer
Replace squeeze w/ squish
2 parents 767782a + 289a6ae commit f772a26

4 files changed

Lines changed: 4 additions & 4 deletions

File tree

lib/portable_text/plain/serializer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def visit(nodes)
1515
nodes.map do |block|
1616
case block.type
1717
when "block"
18-
block.children.map(&:text).join(" ").squeeze.strip
18+
block.children.map(&:text).join(" ").squish
1919
when "list"
2020
visit(block.items)
2121
when "image"

test/fixtures/body.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
"_key": "3b5016890b16",
135135
"_type": "span",
136136
"marks": [],
137-
"text": "Texte avec les mots "
137+
"text": "Texte avec les mots comme pomme de terre "
138138
},
139139
{
140140
"_key": "03b232374034",

test/plain/serializer_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def test_it_serialiszes_to_plain_text
1616
Citation
1717
Texte avec le mot gras en gras
1818
Texte avec le mot italique en italique
19-
Texte avec les mots gras italique en gras et italique
19+
Texte avec les mots comme pomme de terre gras italique en gras et italique
2020
liste level 1
2121
liste level 1
2222
liste level 1

test/serializer_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def test_it_can_render_a_whole_body
131131
content = render PortableText::Serializer.new(content: body["body"]).render
132132
assert_equal(
133133
content,
134-
"<h1>Titre h1</h1><h2>Titre h2</h2><h3>Titre h3</h3><h4>Titre h4</h4><blockquote>Citation</blockquote><p>Texte avec le mot <strong>gras</strong> en gras</p><p>Texte avec le mot <em>italique</em> en italique</p><p>Texte avec les mots <strong><em>gras italique</em></strong> en gras et italique</p><ul><li>liste level 1</li><li>liste level 1</li><li>liste level 1</li><ul><li>sous liste level 2</li></ul><ul><li>sous liste <strong>level 2</strong></li><ul><li>sous liste <em>level 3</em></li></ul></ul><ul><li>sous liste level 2</li></ul><li>liste level 1</li><ul><li>sous liste level 2</li><ul><li>sous liste level 3</li></ul></ul><ul><li>sous liste level 2</li></ul></ul><p><a href=\"http://www.sanity.io\">Lien externe</a> </p>"
134+
"<h1>Titre h1</h1><h2>Titre h2</h2><h3>Titre h3</h3><h4>Titre h4</h4><blockquote>Citation</blockquote><p>Texte avec le mot <strong>gras</strong> en gras</p><p>Texte avec le mot <em>italique</em> en italique</p><p>Texte avec les mots comme pomme de terre <strong><em>gras italique</em></strong> en gras et italique</p><ul><li>liste level 1</li><li>liste level 1</li><li>liste level 1</li><ul><li>sous liste level 2</li></ul><ul><li>sous liste <strong>level 2</strong></li><ul><li>sous liste <em>level 3</em></li></ul></ul><ul><li>sous liste level 2</li></ul><li>liste level 1</li><ul><li>sous liste level 2</li><ul><li>sous liste level 3</li></ul></ul><ul><li>sous liste level 2</li></ul></ul><p><a href=\"http://www.sanity.io\">Lien externe</a> </p>"
135135
)
136136
end
137137
# rubocop:enable Layout/LineLength

0 commit comments

Comments
 (0)