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. 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
-
#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.
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
#attributes ⇒ Object (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
#kind ⇒ MarkupKind
The type of the Markup
42 43 44 |
# File 'lib/language_server/protocol/interface/markup_content.rb', line 42 def kind attributes.fetch(:kind) end |
#to_hash ⇒ Object
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 |
#value ⇒ string
The content itself
50 51 52 |
# File 'lib/language_server/protocol/interface/markup_content.rb', line 50 def value attributes.fetch(:value) end |