Skip to content

Commit

Permalink
do not include the heredoc delemiters as part of the string
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgoebel committed Sep 28, 2020
1 parent 99f2edb commit a3f4904
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/languages/bash.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export default function(hljs) {
const HERE_DOC = hljs.END_SAME_AS_BEGIN({
className: 'string',
begin: /<<-?\s*(\w+)/,
end: /(\w+)/
end: /(\w+)/,
excludeBegin: true,
excludeEnd:true
});
const QUOTE_STRING = {
className: 'string',
Expand Down
11 changes: 11 additions & 0 deletions test/markup/bash/strings.expect.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
SCRIPT_DIR=<span class="hljs-string">&quot;<span class="hljs-subst">$( cd <span class="hljs-string">&quot;<span class="hljs-subst">$( dirname <span class="hljs-string">&quot;<span class="hljs-variable">${BASH_SOURCE[0]}</span>&quot;</span> )</span>&quot;</span> &gt;/dev/null 2&gt;&amp;1 &amp;&amp; pwd )</span>&quot;</span>
TLS_DIR=<span class="hljs-string">&quot;<span class="hljs-variable">$SCRIPT_DIR</span>/../src/main/resources/tls&quot;</span>
ROOT_DIR=<span class="hljs-string">&quot;<span class="hljs-variable">$SCRIPT_DIR</span>/..&quot;</span>

jshell -s - &lt;&lt; EOF<span class="hljs-string">
System.out.printf(&quot;Procs: %s%n&quot;, getdata())
</span>EOF

jshell -s - &lt;&lt;&lt;<span class="hljs-string">&#x27;System.out.printf(&quot;Procs: %s%n&quot;, getdata())&#x27;</span>

cat &lt;&lt;&lt; <span class="hljs-string">&#x27;$VARIABLE&#x27;</span>
cat &lt;&lt;&lt; <span class="hljs-string">&quot;<span class="hljs-variable">$VARIABLE</span>&quot;</span>
cat &lt;&lt;&lt; <span class="hljs-variable">$VARIABLE</span>
cat &lt;&lt;&lt; `<span class="hljs-variable">$VARIABLE</span>`
11 changes: 11 additions & 0 deletions test/markup/bash/strings.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
TLS_DIR="$SCRIPT_DIR/../src/main/resources/tls"
ROOT_DIR="$SCRIPT_DIR/.."

jshell -s - << EOF
System.out.printf("Procs: %s%n", getdata())
EOF

jshell -s - <<<'System.out.printf("Procs: %s%n", getdata())'

cat <<< '$VARIABLE'
cat <<< "$VARIABLE"
cat <<< $VARIABLE
cat <<< `$VARIABLE`

0 comments on commit a3f4904

Please sign in to comment.