Skip to content

feat: render Markdown in rich parameter descriptions - #6098

Merged
mtojek merged 10 commits into
coder:mainfrom
mtojek:5931-description-markdown-2
Feb 8, 2023
Merged

mtojek merged 10 commits into
coder:mainfrom
mtojek:5931-description-markdown-2

Conversation

@mtojek

@mtojek mtojek commented Feb 8, 2023 •

Copy link
Copy Markdown
Member

Fixes: #5931

This PR introduces an option to use Markdown tags in rich parameter descriptions.

CLI will switch to description_plaintext to skip all tags. It uses glow to render the Markdown content as ASCII text.

CLI:
Screenshot 2023-02-08 at 11 39 18

Site:
Screenshot 2023-02-08 at 11 39 24

Template:

data "coder_parameter" "random_string" {
  name        = "Random string"
  icon        = "/icon/aws.png"
  description = <<-EOT
    See the [registry](https://container.registry.blah/namespace) for *options*.
    EOT
  default     = "helloworld"
  mutable     = true
}

@mtojek mtojek self-assigned this Feb 8, 2023
@mtojek
mtojek marked this pull request as ready for review February 8, 2023 10:57
@mtojek
mtojek requested a review from mafredri February 8, 2023 10:57

@mafredri mafredri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That markdown lib was an nice find! My main concern is the lossiness of the plaintext output, otherwise this looks good. 👍🏻

Comment thread coderd/parameter/plaintext_test.go Outdated

` + "`There are also code tags!`"

expected := "Provide the machine image See the registry for options. Minion This is bold text. This is bold text. This is italic text. Blockquotes can also be nested. Strikethrough. 1. Lorem ipsum dolor sit amet. 2. Consectetur adipiscing elit. 3. Integer molestie lorem at massa. There are also code tags!"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually want the CLI output to be this lossy? For instance:

  • Why do we not keep newlines?
  • Why don't we print links? We could e.g. do something like: See the registry (https://container.registry.blah/namespace) for options.

If newlines are not wanted here, perhaps we could call the field DescriptionCondensed instead of plaintext?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, mate! We can safely leave them.

Screenshot 2023-02-08 at 12 39 59

@mtojek
mtojek requested a review from mafredri February 8, 2023 11:42

@mafredri mafredri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely!

@mtojek
mtojek merged commit 1dc4778 into coder:main Feb 8, 2023
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow template parameter descriptions to be markdown

2 participants