1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
module LanguageServer
module Protocol
module Interface
#
# 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.
#
class MarkupContent
def initialize(kind:, value:)
@attributes = {}
@attributes[:kind] = kind
@attributes[:value] = value
@attributes.freeze
end
#
# The type of the Markup
#
# @return [MarkupKind]
def kind
attributes.fetch(:kind)
end
#
# The content itself
#
# @return [string]
def value
attributes.fetch(:value)
end
attr_reader :attributes
def to_hash
attributes
end
def to_json(*args)
to_hash.to_json(*args)
end
end
end
end
end
|