-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enh(elixir) improve heredoc and sigil support (#2257)
- Loading branch information
1 parent
980ac21
commit c87f538
Showing
7 changed files
with
153 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<span class="hljs-string">~R'this + i\s "a" regex too'</span> | ||
<span class="hljs-string">~w(hello <span class="hljs-subst">#{ [<span class="hljs-string">"has"</span> <> <span class="hljs-string">"123"</span>, <span class="hljs-string">'\c\d'</span>, <span class="hljs-string">"\123 interpol"</span> | []] }</span> world)</span>s | ||
<span class="hljs-string">~W(hello #{no "123" \c\d \123 interpol} world)</span>s | ||
<span class="hljs-string">~s{Escapes terminators \{ and \}, but no {balancing}</span> <span class="hljs-comment"># outside of sigil here }</span> | ||
<span class="hljs-string">~S"No escapes \s\t\n and no #{interpolation}"</span> | ||
|
||
<span class="hljs-string">~S/hello/</span> | ||
<span class="hljs-string">~S|hello|</span> | ||
<span class="hljs-string">~S"hello"</span> | ||
<span class="hljs-string">~S'hello'</span> | ||
<span class="hljs-string">~S(hello)</span> | ||
<span class="hljs-string">~S[hello]</span> | ||
<span class="hljs-string">~S{hello}</span> | ||
<span class="hljs-string">~S<hello></span> | ||
|
||
<span class="hljs-string">~s/hello <span class="hljs-subst">#{name}</span>/</span> | ||
<span class="hljs-string">~s|hello <span class="hljs-subst">#{name}</span>|</span> | ||
<span class="hljs-string">~s"hello <span class="hljs-subst">#{name}</span>"</span> | ||
<span class="hljs-string">~s'hello <span class="hljs-subst">#{name}</span>'</span> | ||
<span class="hljs-string">~s(hello <span class="hljs-subst">#{name}</span>)</span> | ||
<span class="hljs-string">~s[hello <span class="hljs-subst">#{name}</span>]</span> | ||
<span class="hljs-string">~s{hello <span class="hljs-subst">#{name}</span>}</span> | ||
<span class="hljs-string">~s<hello <span class="hljs-subst">#{name}</span>></span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
~R'this + i\s "a" regex too' | ||
~w(hello #{ ["has" <> "123", '\c\d', "\123 interpol" | []] } world)s | ||
~W(hello #{no "123" \c\d \123 interpol} world)s | ||
~s{Escapes terminators \{ and \}, but no {balancing} # outside of sigil here } | ||
~S"No escapes \s\t\n and no #{interpolation}" | ||
|
||
~S/hello/ | ||
~S|hello| | ||
~S"hello" | ||
~S'hello' | ||
~S(hello) | ||
~S[hello] | ||
~S{hello} | ||
~S<hello> | ||
|
||
~s/hello #{name}/ | ||
~s|hello #{name}| | ||
~s"hello #{name}" | ||
~s'hello #{name}' | ||
~s(hello #{name}) | ||
~s[hello #{name}] | ||
~s{hello #{name}} | ||
~s<hello #{name}> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
a = <span class="hljs-string">"""test"""</span> | ||
b = <span class="hljs-string">'''test'''</span> | ||
c = <span class="hljs-string">"test"</span> | ||
d = <span class="hljs-string">'test'</span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
a = """test""" | ||
b = '''test''' | ||
c = "test" | ||
d = 'test' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<span class="hljs-class"><span class="hljs-keyword">defmodule</span> <span class="hljs-title">Long.Module.Name</span></span> <span class="hljs-keyword">do</span> | ||
<span class="hljs-variable">@doc</span> <span class="hljs-string">~S''' | ||
No #{interpolation} of any kind. | ||
\000 \x{ff} | ||
|
||
\n #{\x{ff}} | ||
'''</span> | ||
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">func</span></span>(a, b \\ []), <span class="hljs-symbol">do:</span> <span class="hljs-symbol">:ok</span> | ||
|
||
<span class="hljs-variable">@doc</span> <span class="hljs-string">~S""" | ||
No #{interpolation} of any kind. | ||
\000 \x{ff} | ||
|
||
\n #{\x{ff}} | ||
"""</span> | ||
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">func</span></span>(a, b \\ []), <span class="hljs-symbol">do:</span> <span class="hljs-symbol">:ok</span> | ||
<span class="hljs-keyword">end</span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
defmodule Long.Module.Name do | ||
@doc ~S''' | ||
No #{interpolation} of any kind. | ||
\000 \x{ff} | ||
|
||
\n #{\x{ff}} | ||
''' | ||
def func(a, b \\ []), do: :ok | ||
|
||
@doc ~S""" | ||
No #{interpolation} of any kind. | ||
\000 \x{ff} | ||
|
||
\n #{\x{ff}} | ||
""" | ||
def func(a, b \\ []), do: :ok | ||
end |