Class: LanguageServer::Protocol::Interface::MarkupContent
- Inherits:
-
Object
- Object
- LanguageServer::Protocol::Interface::MarkupContent
- 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
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#initialize(kind:, value:) ⇒ MarkupContent
constructor
A new instance of MarkupContent.
-
#kind ⇒ MarkupKind
The type of the Markup.
- #to_hash ⇒ Object
- #to_json(*args) ⇒ Object
-
#value ⇒ string
The content itself.
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
#attributes ⇒ Object (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
#kind ⇒ MarkupKind
The type of the Markup
44 45 46 |
# File 'lib/language_server/protocol/interface/markup_content.rb', line 44 def kind attributes.fetch(:kind) end |
#to_hash ⇒ Object
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 |
#value ⇒ string
The content itself
52 53 54 |
# File 'lib/language_server/protocol/interface/markup_content.rb', line 52 def value attributes.fetch(:value) end |