ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:118180] [Ruby master Bug#20525] Percent string literal with indentation support
@ 2024-06-04 22:35 bradgessler (Brad Gessler) via ruby-core
  2024-07-30  7:22 ` [ruby-core:118734] [Ruby master Feature#20525] Percent string literal with indentation support or String#dedent nobu (Nobuyoshi Nakada) via ruby-core
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: bradgessler (Brad Gessler) via ruby-core @ 2024-06-04 22:35 UTC (permalink / raw)
  To: ruby-core; +Cc: bradgessler (Brad Gessler)

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/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:118734] [Ruby master Feature#20525] Percent string literal with indentation support or String#dedent
  2024-06-04 22:35 [ruby-core:118180] [Ruby master Bug#20525] Percent string literal with indentation support bradgessler (Brad Gessler) via ruby-core
@ 2024-07-30  7:22 ` nobu (Nobuyoshi Nakada) via ruby-core
  2024-07-31  2:32 ` [ruby-core:118753] " shyouhei (Shyouhei Urabe) via ruby-core
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2024-07-30  7:22 UTC (permalink / raw)
  To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)

Issue #20525 has been updated by nobu (Nobuyoshi Nakada).


It conflicts with the existing syntax.
`%` plus a punctuation starts a string literal that ends with the punctuation.

----------------------------------------
Feature #20525: Percent string literal with indentation support or String#dedent
https://bugs.ruby-lang.org/issues/20525#change-109273

* Author: bradgessler (Brad Gessler)
* Status: Open
----------------------------------------
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
  }.dedent
},
```




-- 
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/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:118753] [Ruby master Feature#20525] Percent string literal with indentation support or String#dedent
  2024-06-04 22:35 [ruby-core:118180] [Ruby master Bug#20525] Percent string literal with indentation support bradgessler (Brad Gessler) via ruby-core
  2024-07-30  7:22 ` [ruby-core:118734] [Ruby master Feature#20525] Percent string literal with indentation support or String#dedent nobu (Nobuyoshi Nakada) via ruby-core
@ 2024-07-31  2:32 ` shyouhei (Shyouhei Urabe) via ruby-core
  2024-07-31  5:14 ` [ruby-core:118757] " bradgessler (Brad Gessler) via ruby-core
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: shyouhei (Shyouhei Urabe) via ruby-core @ 2024-07-31  2:32 UTC (permalink / raw)
  To: ruby-core; +Cc: shyouhei (Shyouhei Urabe)

Issue #20525 has been updated by shyouhei (Shyouhei Urabe).


Why not `<<~"}"` ?

----------------------------------------
Feature #20525: Percent string literal with indentation support or String#dedent
https://bugs.ruby-lang.org/issues/20525#change-109299

* Author: bradgessler (Brad Gessler)
* Status: Open
----------------------------------------
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
  }.dedent
},
```




-- 
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/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:118757] [Ruby master Feature#20525] Percent string literal with indentation support or String#dedent
  2024-06-04 22:35 [ruby-core:118180] [Ruby master Bug#20525] Percent string literal with indentation support bradgessler (Brad Gessler) via ruby-core
  2024-07-30  7:22 ` [ruby-core:118734] [Ruby master Feature#20525] Percent string literal with indentation support or String#dedent nobu (Nobuyoshi Nakada) via ruby-core
  2024-07-31  2:32 ` [ruby-core:118753] " shyouhei (Shyouhei Urabe) via ruby-core
@ 2024-07-31  5:14 ` bradgessler (Brad Gessler) via ruby-core
  2024-08-01 10:42 ` [ruby-core:118772] " mame (Yusuke Endoh) via ruby-core
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: bradgessler (Brad Gessler) via ruby-core @ 2024-07-31  5:14 UTC (permalink / raw)
  To: ruby-core; +Cc: bradgessler (Brad Gessler)

Issue #20525 has been updated by bradgessler (Brad Gessler).


Actually this looks decent:

```rb
Markdown ~{
  # Hi!

  This is markdown
}
```

----------------------------------------
Feature #20525: Percent string literal with indentation support or String#dedent
https://bugs.ruby-lang.org/issues/20525#change-109303

* Author: bradgessler (Brad Gessler)
* Status: Open
----------------------------------------
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
  }.dedent
},
```




-- 
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/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:118772] [Ruby master Feature#20525] Percent string literal with indentation support or String#dedent
  2024-06-04 22:35 [ruby-core:118180] [Ruby master Bug#20525] Percent string literal with indentation support bradgessler (Brad Gessler) via ruby-core
                   ` (2 preceding siblings ...)
  2024-07-31  5:14 ` [ruby-core:118757] " bradgessler (Brad Gessler) via ruby-core
@ 2024-08-01 10:42 ` mame (Yusuke Endoh) via ruby-core
  2024-09-03  8:31 ` [ruby-core:119021] " bradgessler (Brad Gessler) via ruby-core
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mame (Yusuke Endoh) via ruby-core @ 2024-08-01 10:42 UTC (permalink / raw)
  To: ruby-core; +Cc: mame (Yusuke Endoh)

Issue #20525 has been updated by mame (Yusuke Endoh).

Status changed from Open to Rejected

This was briefly discussed at the dev meeting, but ended with "why not use a shorter delimiter like `<<~END` or `<<~MD`?"

----------------------------------------
Feature #20525: Percent string literal with indentation support or String#dedent
https://bugs.ruby-lang.org/issues/20525#change-109324

* Author: bradgessler (Brad Gessler)
* Status: Rejected
----------------------------------------
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
  }.dedent
},
```




-- 
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/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:119021] [Ruby master Feature#20525] Percent string literal with indentation support or String#dedent
  2024-06-04 22:35 [ruby-core:118180] [Ruby master Bug#20525] Percent string literal with indentation support bradgessler (Brad Gessler) via ruby-core
                   ` (3 preceding siblings ...)
  2024-08-01 10:42 ` [ruby-core:118772] " mame (Yusuke Endoh) via ruby-core
@ 2024-09-03  8:31 ` bradgessler (Brad Gessler) via ruby-core
  2024-09-03 12:28 ` [ruby-core:119026] " ufuk (Ufuk Kayserilioglu) via ruby-core
  2024-09-03 15:37 ` [ruby-core:119028] " bradgessler (Brad Gessler) via ruby-core
  6 siblings, 0 replies; 8+ messages in thread
From: bradgessler (Brad Gessler) via ruby-core @ 2024-09-03  8:31 UTC (permalink / raw)
  To: ruby-core; +Cc: bradgessler (Brad Gessler)

Issue #20525 has been updated by bradgessler (Brad Gessler).


Same reason you can conjure up a Proc via `-> {}` — the syntax looks cleaner and you don't have to stop and try to name it.

Not having to name a string is a pretty big boost in terms staying in the flow.

The second thing: it looks ugly having two of the same names by each other, which the original example shows:

```
markdown <<~MD
  # Hello
  
  How are you doing?
MD
```

still looks kind of weird. 

This looks better:

```
markdown <<~
  # Hello
  
  How are you doing?
>>
```



----------------------------------------
Feature #20525: Percent string literal with indentation support or String#dedent
https://bugs.ruby-lang.org/issues/20525#change-109599

* Author: bradgessler (Brad Gessler)
* Status: Rejected
----------------------------------------
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
  }.dedent
},
```




-- 
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/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:119026] [Ruby master Feature#20525] Percent string literal with indentation support or String#dedent
  2024-06-04 22:35 [ruby-core:118180] [Ruby master Bug#20525] Percent string literal with indentation support bradgessler (Brad Gessler) via ruby-core
                   ` (4 preceding siblings ...)
  2024-09-03  8:31 ` [ruby-core:119021] " bradgessler (Brad Gessler) via ruby-core
@ 2024-09-03 12:28 ` ufuk (Ufuk Kayserilioglu) via ruby-core
  2024-09-03 15:37 ` [ruby-core:119028] " bradgessler (Brad Gessler) via ruby-core
  6 siblings, 0 replies; 8+ messages in thread
From: ufuk (Ufuk Kayserilioglu) via ruby-core @ 2024-09-03 12:28 UTC (permalink / raw)
  To: ruby-core; +Cc: ufuk (Ufuk Kayserilioglu)

Issue #20525 has been updated by ufuk (Ufuk Kayserilioglu).


@bradgessler I am not sure if you've missed the suggestion by @shyouhei in https://bugs.ruby-lang.org/issues/20525#note-5:
```ruby
markdown <<~"}"
  # Hello

  How are you doing?
}
```
This doesn't need naming anything and has no repetition either.

----------------------------------------
Feature #20525: Percent string literal with indentation support or String#dedent
https://bugs.ruby-lang.org/issues/20525#change-109603

* Author: bradgessler (Brad Gessler)
* Status: Rejected
----------------------------------------
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
  }.dedent
},
```




-- 
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/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:119028] [Ruby master Feature#20525] Percent string literal with indentation support or String#dedent
  2024-06-04 22:35 [ruby-core:118180] [Ruby master Bug#20525] Percent string literal with indentation support bradgessler (Brad Gessler) via ruby-core
                   ` (5 preceding siblings ...)
  2024-09-03 12:28 ` [ruby-core:119026] " ufuk (Ufuk Kayserilioglu) via ruby-core
@ 2024-09-03 15:37 ` bradgessler (Brad Gessler) via ruby-core
  6 siblings, 0 replies; 8+ messages in thread
From: bradgessler (Brad Gessler) via ruby-core @ 2024-09-03 15:37 UTC (permalink / raw)
  To: ruby-core; +Cc: bradgessler (Brad Gessler)

Issue #20525 has been updated by bradgessler (Brad Gessler).


Oh interesting, I thought that was a typo 😂.

I was playing around with characters after I wrote this and found something that I think looks a little better than the "}" thing:

```ruby
markdown <<~___
  # Hello

  How are you doing?
___
```

I now understand that both of those work, but it's still not as beautiful syntactically speaking as a HEREDOCS that doesn't require a name or work-around.

----------------------------------------
Feature #20525: Percent string literal with indentation support or String#dedent
https://bugs.ruby-lang.org/issues/20525#change-109606

* Author: bradgessler (Brad Gessler)
* Status: Rejected
----------------------------------------
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
  }.dedent
},
```




-- 
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/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-09-03 15:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-04 22:35 [ruby-core:118180] [Ruby master Bug#20525] Percent string literal with indentation support bradgessler (Brad Gessler) via ruby-core
2024-07-30  7:22 ` [ruby-core:118734] [Ruby master Feature#20525] Percent string literal with indentation support or String#dedent nobu (Nobuyoshi Nakada) via ruby-core
2024-07-31  2:32 ` [ruby-core:118753] " shyouhei (Shyouhei Urabe) via ruby-core
2024-07-31  5:14 ` [ruby-core:118757] " bradgessler (Brad Gessler) via ruby-core
2024-08-01 10:42 ` [ruby-core:118772] " mame (Yusuke Endoh) via ruby-core
2024-09-03  8:31 ` [ruby-core:119021] " bradgessler (Brad Gessler) via ruby-core
2024-09-03 12:28 ` [ruby-core:119026] " ufuk (Ufuk Kayserilioglu) via ruby-core
2024-09-03 15:37 ` [ruby-core:119028] " bradgessler (Brad Gessler) via ruby-core

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).