Here Document(heredoc) for Ruby syntax highlighting

XMLWordPrintable

    • 1
    • Severity 3 - Minor
    • 0

      Summary

      Ruby syntax in Bitbucket Server where the heredoc is not functioning properly correctly for its syntax highlighting. The following types of Here Documents are not functioning properly:

      • indent
          expected_result = <<-INDENTED_HEREDOC
        This would contain specially formatted text.
        
        That might span many lines
          INDENTED_HEREDOC
        
      • squiggly
        expected_result = <<~SQUIGGLY_HEREDOC
          This would contain specially formatted text.
        
          That might span many lines
        SQUIGGLY_HEREDOC
        
      • single quotes
        expected_result = <<-'EXPECTED'
        One plus one is #{1 + 1}
        EXPECTED
        
      • double quotes
        puts <<-"HEREDOC"
        cat #{__FILE__}
        HEREDOC
        
      • backticks
        puts <<-`HEREDOC`
        cat #{__FILE__}
        HEREDOC
        

      Steps to Reproduce

      1. In the local repository, write poly.rb ruby script.
      2. Make the commit and push to the remote repository.
      3. View the file in the Source View page.

      Expected Results

      Bitbucket Server's source view page able to recognize the heredoc syntax and comment out/block out the content in between the heredoc.

      Actual Results.

      Bitbucket Server's source view page unable to recognize the heredoc syntax.

      Workaround

      Only the following heredoc syntax is recognized:

      expected_result = <<HEREDOC
      This would contain specially formatted text.
      
      That might span many lines
      HEREDOC
      

      The heredoc starts on the line following <<HEREDOC and ends with the next line that starts with HEREDOC. The result includes the ending newline.

      More information

      The syntax information was referred at - http://ruby-doc.org/core-2.3.0/doc/syntax/literals_rdoc.html#label-Here+Documents

            Assignee:
            Unassigned
            Reporter:
            Baskar Annamalai (Inactive)
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: