mirror of
https://github.com/gohugoio/hugo.git
synced 2025-03-19 16:34:23 +00:00
Fix some Go code doc issues
This commit is contained in:
parent
1583d8d094
commit
de7dd70bbc
4 changed files with 11 additions and 12 deletions
|
@ -26,13 +26,13 @@ import (
|
||||||
var undraftCmd = &cobra.Command{
|
var undraftCmd = &cobra.Command{
|
||||||
Use: "undraft path/to/content",
|
Use: "undraft path/to/content",
|
||||||
Short: "Undraft changes the content's draft status from 'True' to 'False'",
|
Short: "Undraft changes the content's draft status from 'True' to 'False'",
|
||||||
Long: `Undraft changes the content's draft status from 'True' to 'False'
|
Long: `Undraft changes the content's draft status from 'True' to 'False'
|
||||||
and updates the date to the current date and time.
|
and updates the date to/ the current date and time.
|
||||||
If the content's draft status is 'False', nothing is done.`,
|
If the content's draft status is 'False', nothing is done.`,
|
||||||
Run: Undraft,
|
Run: Undraft,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Publish publishes the specified content by setting its draft status
|
// Undraft publishes the specified content by setting its draft status
|
||||||
// to false and setting its publish date to now. If the specified content is
|
// to false and setting its publish date to now. If the specified content is
|
||||||
// not a draft, it will log an error.
|
// not a draft, it will log an error.
|
||||||
func Undraft(cmd *cobra.Command, args []string) {
|
func Undraft(cmd *cobra.Command, args []string) {
|
||||||
|
|
|
@ -134,7 +134,7 @@ func BytesToHTML(b []byte) template.HTML {
|
||||||
return template.HTML(string(b))
|
return template.HTML(string(b))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetHtmlRenderer creates a new Renderer with the given configuration.
|
// GetHTMLRenderer creates a new Blackfriday Renderer with the given configuration.
|
||||||
func GetHTMLRenderer(defaultFlags int, ctx *RenderingContext) blackfriday.Renderer {
|
func GetHTMLRenderer(defaultFlags int, ctx *RenderingContext) blackfriday.Renderer {
|
||||||
renderParameters := blackfriday.HtmlRendererParameters{
|
renderParameters := blackfriday.HtmlRendererParameters{
|
||||||
FootnoteAnchorPrefix: viper.GetString("FootnoteAnchorPrefix"),
|
FootnoteAnchorPrefix: viper.GetString("FootnoteAnchorPrefix"),
|
||||||
|
@ -172,12 +172,11 @@ func GetHTMLRenderer(defaultFlags int, ctx *RenderingContext) blackfriday.Render
|
||||||
htmlFlags |= blackfriday.HTML_SMARTYPANTS_LATEX_DASHES
|
htmlFlags |= blackfriday.HTML_SMARTYPANTS_LATEX_DASHES
|
||||||
}
|
}
|
||||||
|
|
||||||
return &HugoHtmlRenderer{
|
return &hugoHtmlRenderer{
|
||||||
blackfriday.HtmlRendererWithParameters(htmlFlags, "", "", renderParameters),
|
blackfriday.HtmlRendererWithParameters(htmlFlags, "", "", renderParameters),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func getMarkdownExtensions(ctx *RenderingContext) int {
|
func getMarkdownExtensions(ctx *RenderingContext) int {
|
||||||
flags := 0 | blackfriday.EXTENSION_NO_INTRA_EMPHASIS |
|
flags := 0 | blackfriday.EXTENSION_NO_INTRA_EMPHASIS |
|
||||||
blackfriday.EXTENSION_TABLES | blackfriday.EXTENSION_FENCED_CODE |
|
blackfriday.EXTENSION_TABLES | blackfriday.EXTENSION_FENCED_CODE |
|
||||||
|
@ -209,7 +208,7 @@ func markdownRenderWithTOC(ctx *RenderingContext) []byte {
|
||||||
getMarkdownExtensions(ctx))
|
getMarkdownExtensions(ctx))
|
||||||
}
|
}
|
||||||
|
|
||||||
// mmark
|
// GetMmarkHtmlRenderer creates a new MMark Renderer with the given configuration.
|
||||||
func GetMmarkHtmlRenderer(defaultFlags int, ctx *RenderingContext) mmark.Renderer {
|
func GetMmarkHtmlRenderer(defaultFlags int, ctx *RenderingContext) mmark.Renderer {
|
||||||
renderParameters := mmark.HtmlRendererParameters{
|
renderParameters := mmark.HtmlRendererParameters{
|
||||||
FootnoteAnchorPrefix: viper.GetString("FootnoteAnchorPrefix"),
|
FootnoteAnchorPrefix: viper.GetString("FootnoteAnchorPrefix"),
|
||||||
|
@ -220,7 +219,6 @@ func GetMmarkHtmlRenderer(defaultFlags int, ctx *RenderingContext) mmark.Rendere
|
||||||
|
|
||||||
if b && !ctx.getConfig().PlainIDAnchors {
|
if b && !ctx.getConfig().PlainIDAnchors {
|
||||||
renderParameters.FootnoteAnchorPrefix = ctx.DocumentID + ":" + renderParameters.FootnoteAnchorPrefix
|
renderParameters.FootnoteAnchorPrefix = ctx.DocumentID + ":" + renderParameters.FootnoteAnchorPrefix
|
||||||
// renderParameters.HeaderIDSuffix = ":" + ctx.DocumentId
|
|
||||||
}
|
}
|
||||||
|
|
||||||
htmlFlags := defaultFlags
|
htmlFlags := defaultFlags
|
||||||
|
|
|
@ -8,12 +8,12 @@ import (
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Wraps a blackfriday.Renderer, typically a blackfriday.Html
|
// hugoHtmlRenderer wraps a blackfriday.Renderer, typically a blackfriday.Html
|
||||||
type HugoHtmlRenderer struct {
|
type hugoHtmlRenderer struct {
|
||||||
blackfriday.Renderer
|
blackfriday.Renderer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (renderer *HugoHtmlRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string) {
|
func (renderer *hugoHtmlRenderer) blockCode(out *bytes.Buffer, text []byte, lang string) {
|
||||||
if viper.GetBool("PygmentsCodeFences") {
|
if viper.GetBool("PygmentsCodeFences") {
|
||||||
str := html.UnescapeString(string(text))
|
str := html.UnescapeString(string(text))
|
||||||
out.WriteString(Highlight(str, lang, ""))
|
out.WriteString(Highlight(str, lang, ""))
|
||||||
|
|
|
@ -85,6 +85,7 @@ func MakePathToLower(s string) string {
|
||||||
return strings.ToLower(MakePath(s))
|
return strings.ToLower(MakePath(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MakeTitle trims any space and replaces hypens with a single space.
|
||||||
func MakeTitle(inpath string) string {
|
func MakeTitle(inpath string) string {
|
||||||
return strings.Replace(strings.TrimSpace(inpath), "-", " ", -1)
|
return strings.Replace(strings.TrimSpace(inpath), "-", " ", -1)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue