Skip to content

Heredoc newlines are removed when copying and pasting #2096

@axelson

Description

@axelson

With a function doc like:

@doc """
Example

    iex> existing_zipper = (\"\"\"
    ...> IO.inspect("Hello, world!")
    ...> IO.puts("abc")
    ...> \"\"\"
    ...> |> Sourceror.parse_string!()
    ...> |> Sourceror.Zipper.zip())
"""
def abc do
end

The generated ex_doc docs look correct:

Image

However, when those docs are copy and pasted, the newlines within the heredoc are stripped, resulting in the string:

existing_zipper = ("""IO.inspect("Hello, world!")IO.puts("abc")"""
|> Sourceror.parse_string!()
|> Sourceror.Zipper.zip())

When that is run in IEx the user gets an error like:

iex(17)> existing_zipper = ("""IO.inspect("Hello, world!")IO.puts("abc")"""
** (SyntaxError) invalid syntax found on iex:17:23:
    error: heredoc allows only whitespace characters followed by a new line after opening """
    │
 17 │ existing_zipper = ("""IO.inspect("Hello, world!")IO.puts("abc")"""
    │                       ^
    │
    └─ iex:17:23

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions