...

Source file src/github.com/xanzy/go-gitlab/markdown.go

Documentation: github.com/xanzy/go-gitlab

     1  package gitlab
     2  
     3  import "net/http"
     4  
     5  // MarkdownService handles communication with the markdown related methods of
     6  // the GitLab API.
     7  //
     8  // Gitlab API docs: https://docs.gitlab.com/ee/api/markdown.html
     9  type MarkdownService struct {
    10  	client *Client
    11  }
    12  
    13  // Markdown represents a markdown document.
    14  //
    15  // Gitlab API docs: https://docs.gitlab.com/ee/api/markdown.html
    16  type Markdown struct {
    17  	HTML string `json:"html"`
    18  }
    19  
    20  // RenderOptions represents the available Render() options.
    21  //
    22  // Gitlab API docs:
    23  // https://docs.gitlab.com/ee/api/markdown.html#render-an-arbitrary-markdown-document
    24  type RenderOptions struct {
    25  	Text                    *string `url:"text,omitempty" json:"text,omitempty"`
    26  	GitlabFlavouredMarkdown *bool   `url:"gfm,omitempty" json:"gfm,omitempty"`
    27  	Project                 *string `url:"project,omitempty" json:"project,omitempty"`
    28  }
    29  
    30  // Render an arbitrary markdown document.
    31  //
    32  // Gitlab API docs:
    33  // https://docs.gitlab.com/ee/api/markdown.html#render-an-arbitrary-markdown-document
    34  func (s *MarkdownService) Render(opt *RenderOptions, options ...RequestOptionFunc) (*Markdown, *Response, error) {
    35  	req, err := s.client.NewRequest(http.MethodPost, "markdown", opt, options)
    36  	if err != nil {
    37  		return nil, nil, err
    38  	}
    39  
    40  	md := new(Markdown)
    41  	response, err := s.client.Do(req, md)
    42  	if err != nil {
    43  		return nil, response, err
    44  	}
    45  
    46  	return md, response, nil
    47  }
    48  

View as plain text