diff --git a/copyAsMarkdown.spBundle/command.plist b/copyAsMarkdown.spBundle/command.plist
index fd9313a..4f7d178 100644
--- a/copyAsMarkdown.spBundle/command.plist
+++ b/copyAsMarkdown.spBundle/command.plist
@@ -88,7 +88,7 @@ class CopyAsMarkdown
if (!empty($str)) {
$str .= "|";
}
- $str .= $val;
+ $str .= str_replace(array("\n", "\r"), '', nl2br($val));
}
$result[] = $str;
}
diff --git a/lib/CopyAsMarkdown/CopyAsMarkdown.php b/lib/CopyAsMarkdown/CopyAsMarkdown.php
index f68cbf9..623f819 100644
--- a/lib/CopyAsMarkdown/CopyAsMarkdown.php
+++ b/lib/CopyAsMarkdown/CopyAsMarkdown.php
@@ -81,10 +81,10 @@ protected function _createDataRows(array $rows)
if (!empty($str)) {
$str .= "|";
}
- $str .= $val;
+ $str .= str_replace(array("\n", "\r"), '', nl2br($val));
}
$result[] = $str;
}
return implode("\n", $result);
}
-}
\ No newline at end of file
+}
diff --git a/tests/lib/CopyAsMarkdown/CopyAsMarkdownTest.php b/tests/lib/CopyAsMarkdown/CopyAsMarkdownTest.php
index 52aaa35..7fbbe21 100644
--- a/tests/lib/CopyAsMarkdown/CopyAsMarkdownTest.php
+++ b/tests/lib/CopyAsMarkdown/CopyAsMarkdownTest.php
@@ -33,6 +33,16 @@ public function testCreateDataRows()
array('d', 'e', 'f'),
)));
}
+
+ public function testCreateDataRows_ReturnLineFeedRemovedData_WhenHasLineFeedInData()
+ {
+ $expected = 'a|b1
b2
b3|c';
+ $this->assertEquals($expected, $this->copyAsMarkdown->createDataRows(array(
+ array('a', 'b1
+b2
+b3', 'c'),
+ )));
+ }
}
class CopyAsMarkdownExtended extends CopyAsMarkdown