mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-12 11:36:29 +00:00
56a854fe14
* update github.com/docker/cli * update github.com/docker/distribution * update github.com/docker/docker * update github.com/gin-gonic/gin * update github.com/golang-jwt/jwt/v4 * update github.com/golangci/golangci-lint * update github.com/gorilla/securecookie * update github.com/mattn/go-sqlite3 * update github.com/moby/moby * update github.com/prometheus/client_golang * update github.com/xanzy/go-gitlab
47 lines
1.3 KiB
Go
47 lines
1.3 KiB
Go
package gitlab
|
|
|
|
import "net/http"
|
|
|
|
// MarkdownService handles communication with the markdown related methods of
|
|
// the GitLab API.
|
|
//
|
|
// Gitlab API docs: https://docs.gitlab.com/ee/api/markdown.html
|
|
type MarkdownService struct {
|
|
client *Client
|
|
}
|
|
|
|
// Markdown represents a markdown document.
|
|
//
|
|
// Gitlab API docs: https://docs.gitlab.com/ee/api/markdown.html
|
|
type Markdown struct {
|
|
HTML string `json:"html"`
|
|
}
|
|
|
|
// RenderOptions represents the available Render() options.
|
|
//
|
|
// Gitlab API docs:
|
|
// https://docs.gitlab.com/ee/api/markdown.html#render-an-arbitrary-markdown-document
|
|
type RenderOptions struct {
|
|
Text *string `url:"text,omitempty" json:"text,omitempty"`
|
|
GitlabFlavouredMarkdown *bool `url:"gfm,omitempty" json:"gfm,omitempty"`
|
|
Project *string `url:"project,omitempty" json:"project,omitempty"`
|
|
}
|
|
|
|
// Render an arbitrary markdown document.
|
|
//
|
|
// Gitlab API docs:
|
|
// https://docs.gitlab.com/ee/api/markdown.html#render-an-arbitrary-markdown-document
|
|
func (s *MarkdownService) Render(opt *RenderOptions, options ...RequestOptionFunc) (*Markdown, *Response, error) {
|
|
req, err := s.client.NewRequest(http.MethodPost, "markdown", opt, options)
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
|
|
md := new(Markdown)
|
|
response, err := s.client.Do(req, md)
|
|
if err != nil {
|
|
return nil, response, err
|
|
}
|
|
|
|
return md, response, nil
|
|
}
|