Skip to content

Commit

Permalink
fixup! [#6] Add a switch for allowing comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nalkuatov committed Jun 29, 2022
1 parent 8479164 commit 4ae43ac
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 15 deletions.
17 changes: 12 additions & 5 deletions core/tests/Test/Interpolator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,20 @@ test_DefaultInterpolator = testGroup "Default interpolator"
-}
|] @?= " My text \n"

, testCase "Other switches keep the comments" do
[int|t|
, testCase "Line comments do not affect the indentation" do
[int|tc|
The beginning
-- some comments in the middle
-- some comments in the middle
The end
|] @?= "The beginning\n-- some comments in the middle\nThe end\n"
]
|] @?= " The beginning\n\n The end\n"

, testCase "Block comments do not affect the indentation" do
[int|tc|
The beginning {- some clarifying
comments in the middle -}

This comment has been minimized.

Copy link
@Martoon-00

Martoon-00 Jun 29, 2022

Member

In this case, as far as I can see the comment does not affect the indentation just because it is already aligned with the other text, comments enabling would not change the result in this regard?

The end
|] @?= "The beginning \nThe end\n"
]

]

Expand Down
30 changes: 20 additions & 10 deletions full/src/Text/Interpolation/Nyan/Tutorial.hs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,20 @@ In case monadic actions have side effects, they will be applied in the same orde
in which placeholders appear in the quoter. /But you are not going to use this
behaviour, don't you?/
==== c ([c]omments handling)
Handle line comments starting with @--@ and/or block comments enclosed in @{- ... -}@.
>>> :{
[int|c|My text -- this is a line comment|]
:}
"My text "
>>> :{
[int|c|My {- this is a block comment -} text|]
:}
"My text"
==== t (return [t]ext)
The quoter will return concrete t'Text'.
Expand All @@ -223,10 +237,6 @@ The quoter will return concrete t'Builder'.
The quoter will return any type with t'FromBuilder' instance.
==== c ([c]omments handling)
Ignore line comments starting with @--@ and/or block comments enclosed in @{- ... -}@.
==== ! (preview)
Quoter will show as an error (non-blocking for the module's build) how the
Expand Down Expand Up @@ -276,16 +286,16 @@ affects indentation stripping to also ignore the line with @|]@:
:}
"\nValue 1 is 5, value 2 is 10\n"
* Comments __are not ignored__ by other switches unless comments handling is explicitly turned on:
* Comments remain invisible for other switches and thus do not affect them.
Consider the following indentation stripping example:
>>> :{
[int|t|
[int|c|
The beginning
-- some comments in the middle
The end
|]
-- some comments in the middle
The end|]
:}
"The beginning\n-- some comments in the middle\nThe end\n"
"The beginning\n\nThe end"
=== Customizing the interpolator
Expand Down

0 comments on commit 4ae43ac

Please sign in to comment.