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

smithy format removes intended newlines in text block #2524

Open
mky4 opened this issue Feb 17, 2025 · 0 comments
Open

smithy format removes intended newlines in text block #2524

mky4 opened this issue Feb 17, 2025 · 0 comments

Comments

@mky4
Copy link

mky4 commented Feb 17, 2025

Example

Before running smithy format:

@pattern(
"""
(^\
((25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9])(\\.(?!$)|$)){4}\
$)\
|\
(^\
(\
([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}\
|([0-9a-fA-F]{1,4}:){1,7}:\
|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}\
|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}\
|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}\
|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}\
|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}\
|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})\
|:((:[0-9a-fA-F]{1,4}){1,7}|:)\
|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}\
|::(ffff(:0{1,4}){0,1}:){0,1}\
((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}\
(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\
|([0-9a-fA-F]{1,4}:){1,4}\
:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}\
(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\
)\
$)
"""
)
string Ipv4Orv6

After running smithy format, it gets collapsed into:

@pattern(
    """
    (^((25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9])(\.(?!$)|$)){4}$)|(^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$)
    """
)
string Ipv4Orv6

Expected behavior

The formatter should preserve intentional newlines inside the text block, as they are part of the intended structure.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant