Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Converting multiline haddock module description with markup creates parse error #212

Closed
1 task done
agentultra opened this issue Jul 8, 2022 · 3 comments · Fixed by #255
Closed
1 task done
Labels
bug Something isn't working good first issue

Comments

@agentultra
Copy link

agentultra commented Jul 8, 2022

Is your feature request specific to Fourmolu?

  • Yes, this feature is not relevant to Ormolu

Describe the current + desired formatting

{-|
This example
@
  test
@
-}

Gets translated to

-- |
--This example
--@
--  test
--@

Which will result in a parse error on --@

I'd recommend it translate to

-- |
-- This example
-- @
--  test
-- @
@brandonchinn178
Copy link
Collaborator

Thanks for the report! @georgefst, curious what your thoughts are on this. On one hand, it's been bothering me for a while that

-- | a
-- multiline
-- comment

gets converted into

{- | a
 multiline
 comment
-}

with leading spaces, since with single line -- comment style, I don't think of the leading space as part of the comment, but as part of the syntax. But I also get that the GHC parser parses the space as part of the comment content, and we probably don't want to modify what GHC parsed.

@georgefst
Copy link
Collaborator

On one hand, it's been bothering me for a while that

Yeah, it annoys me too. I think we can and should fix it.

But I also get that the GHC parser parses the space as part of the comment content, and we probably don't want to modify what GHC parsed.

I'm pretty sure we already have some sort of ignoreASTChange function somewhere (inherited from Ormolu) for special cases where we know we're technically changing the AST, but nobody's likely to care.

@georgefst
Copy link
Collaborator

As for this issue, I think inserting a leading space on all lines (when there isn't one already) would be totally reasonable. Especially since #120.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants