[#118346] [Ruby master Bug#20586] Some filesystem calls in dir.c are missing error handling and can return incorrect results if interrupted — "ivoanjo (Ivo Anjo) via ruby-core" <ruby-core@...>
Issue #20586 has been reported by ivoanjo (Ivo Anjo).
13 messages
2024/06/19
[ruby-core:118180] [Ruby master Bug#20525] Percent string literal with indentation support
From:
"bradgessler (Brad Gessler) via ruby-core" <ruby-core@...>
Date:
2024-06-04 22:35:45 UTC
List:
ruby-core #118180
Issue #20525 has been reported by bradgessler (Brad Gessler).
----------------------------------------
Bug #20525: Percent string literal with indentation support
https://bugs.ruby-lang.org/issues/20525
* Author: bradgessler (Brad Gessler)
* Status: Open
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
I have code that looks like this in an application:
```ruby
ContentSlide(title: "Why Phlex?"){
Markdown <<~MARKDOWN
* Because its fun
* Because its super-de-dooper
MARKDOWN
},
```
The "squiggle" HEREDOCs strips the indentation, but the name of the HEREDOC doesn't look that great since "Markdown" appears twice.
What I'd prefer is a string literal that deals with indentation, maybe it looks something like this:
```
ContentSlide(title: "Why Phlex?"){
Markdown %~{
# Why do you like markdown?
* Because its fun
* Because its super-de-dooper
}
},
```
If Ruby doesn't want to go down the path of adding another type of literal, I'd propose adding a method to String that does the same thing as the `~` HEREDOC so something like this is possible:
```ruby
ContentSlide(title: "Why Phlex?"){
Markdown %{
# Why do you like markdown?
* Because its fun
* Because its super-de-dooper
}.deindent
},
```
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/