Created
November 11, 2022 01:03
-
-
Save mithereal/145e56ac4e077be10fe77dfb215c6201 to your computer and use it in GitHub Desktop.
php n2lbr implemented in elixir
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule n2lbr do | |
@doc """ | |
Replace newlines with <br />. | |
## Examples | |
iex> Nl2br('abc\ndef') | |
"abc<br/>def" | |
""" | |
def nl2br(string) do | |
String.replace(string, ~r/\r|\n/, "<br />") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment