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.

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.



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

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.



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

def attributes
  @attributes
end

Instance Method Details

#kindMarkupKind

The type of the Markup

Returns:

  • (MarkupKind)


44
45
46
# File 'lib/language_server/protocol/interface/markup_content.rb', line 44

def kind
  attributes.fetch(:kind)
end

#to_hashObject



58
59
60
# File 'lib/language_server/protocol/interface/markup_content.rb', line 58

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



62
63
64
# File 'lib/language_server/protocol/interface/markup_content.rb', line 62

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

#valuestring

The content itself

Returns:

  • (string)


52
53
54
# File 'lib/language_server/protocol/interface/markup_content.rb', line 52

def value
  attributes.fetch(:value)
end