Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support for the linefeed #2

Merged
merged 2 commits into from
May 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion copyAsMarkdown.spBundle/command.plist
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class CopyAsMarkdown
if (!empty($str)) {
$str .= "|";
}
$str .= $val;
$str .= str_replace(array("\n", "\r"), '', nl2br($val));
}
$result[] = $str;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/CopyAsMarkdown/CopyAsMarkdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
10 changes: 10 additions & 0 deletions tests/lib/CopyAsMarkdown/CopyAsMarkdownTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ public function testCreateDataRows()
array('d', 'e', 'f'),
)));
}

public function testCreateDataRows_ReturnLineFeedRemovedData_WhenHasLineFeedInData()
{
$expected = 'a|b1<br />b2<br />b3|c';
$this->assertEquals($expected, $this->copyAsMarkdown->createDataRows(array(
array('a', 'b1
b2
b3', 'c'),
)));
}
}

class CopyAsMarkdownExtended extends CopyAsMarkdown
Expand Down