Skip to content

Commit

Permalink
Merge pull request #2 from hypermkt/linefeed-support
Browse files Browse the repository at this point in the history
Support for the linefeed
  • Loading branch information
Makoto Chiba committed May 14, 2016
2 parents 4f5bc50 + 4d3fe8c commit afb29fd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
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

0 comments on commit afb29fd

Please # to comment.