Class: LanguageServer::Protocol::Interface::MarkupContent

Inherits:
Object
  • Object
show all
Defined in:
lib/language_server/protocol/interface/markup_content.rb

Overview

A ‘MarkupContent` literal represents a string value which content is interpreted base on its kind flag. Currently the protocol supports `plaintext` and `markdown` as markup kinds.

If the kind is ‘markdown` then the value can contain fenced code blocks like in GitHub issues. See help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting

Here is an example how such a string can be constructed using JavaScript / TypeScript: “‘typescript let markdown: MarkdownContent = { kind: MarkupKind.Markdown, value: [ ’# Header’, ‘Some text’, ‘“`typescript’, ‘someCode();’, ‘“`’ ].join(‘n’) }; “‘

*Please Note* that clients might sanitize the return markdown. A client could decide to remove HTML from the markdown to avoid script execution.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kind:, value:) ⇒ MarkupContent

Returns a new instance of MarkupContent.



29
30
31
32
33
34
35
36
# File 'lib/language_server/protocol/interface/markup_content.rb', line 29

def initialize(kind:, value:)
  @attributes = {}

  @attributes[:kind] = kind
  @attributes[:value] = value

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



54
55
56
# File 'lib/language_server/protocol/interface/markup_content.rb', line 54

def attributes
  @attributes
end

Instance Method Details

#kindMarkupKind

The type of the Markup

Returns:

  • (MarkupKind)


42
43
44
# File 'lib/language_server/protocol/interface/markup_content.rb', line 42

def kind
  attributes.fetch(:kind)
end

#to_hashObject



56
57
58
# File 'lib/language_server/protocol/interface/markup_content.rb', line 56

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



60
61
62
# File 'lib/language_server/protocol/interface/markup_content.rb', line 60

def to_json(*args)
  to_hash.to_json(*args)
end

#valuestring

The content itself

Returns:

  • (string)


50
51
52
# File 'lib/language_server/protocol/interface/markup_content.rb', line 50

def value
  attributes.fetch(:value)
end