github.com/kovansky/hugo@v0.92.3-0.20220224232819-63076e4ff19f/markup/goldmark/goldmark_config/config.go (about)

     1  // Copyright 2019 The Hugo Authors. All rights reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  // http://www.apache.org/licenses/LICENSE-2.0
     7  //
     8  // Unless required by applicable law or agreed to in writing, software
     9  // distributed under the License is distributed on an "AS IS" BASIS,
    10  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    11  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  
    14  // Package goldmark_config holds Goldmark related configuration.
    15  package goldmark_config
    16  
    17  const (
    18  	AutoHeadingIDTypeGitHub      = "github"
    19  	AutoHeadingIDTypeGitHubAscii = "github-ascii"
    20  	AutoHeadingIDTypeBlackfriday = "blackfriday"
    21  )
    22  
    23  // DefaultConfig holds the default Goldmark configuration.
    24  var Default = Config{
    25  	Extensions: Extensions{
    26  		Typographer:    true,
    27  		Footnote:       true,
    28  		DefinitionList: true,
    29  		Table:          true,
    30  		Strikethrough:  true,
    31  		Linkify:        true,
    32  		TaskList:       true,
    33  	},
    34  	Renderer: Renderer{
    35  		Unsafe: false,
    36  	},
    37  	Parser: Parser{
    38  		AutoHeadingID:     true,
    39  		AutoHeadingIDType: AutoHeadingIDTypeGitHub,
    40  		Attribute: ParserAttribute{
    41  			Title: true,
    42  			Block: false,
    43  		},
    44  	},
    45  }
    46  
    47  // Config configures Goldmark.
    48  type Config struct {
    49  	Renderer   Renderer
    50  	Parser     Parser
    51  	Extensions Extensions
    52  }
    53  
    54  type Extensions struct {
    55  	Typographer    bool
    56  	Footnote       bool
    57  	DefinitionList bool
    58  
    59  	// GitHub flavored markdown
    60  	Table         bool
    61  	Strikethrough bool
    62  	Linkify       bool
    63  	TaskList      bool
    64  }
    65  
    66  type Renderer struct {
    67  	// Whether softline breaks should be rendered as '<br>'
    68  	HardWraps bool
    69  
    70  	// XHTML instead of HTML5.
    71  	XHTML bool
    72  
    73  	// Allow raw HTML etc.
    74  	Unsafe bool
    75  }
    76  
    77  type Parser struct {
    78  	// Enables custom heading ids and
    79  	// auto generated heading ids.
    80  	AutoHeadingID bool
    81  
    82  	// The strategy to use when generating heading IDs.
    83  	// Available options are "github", "github-ascii".
    84  	// Default is "github", which will create GitHub-compatible anchor names.
    85  	AutoHeadingIDType string
    86  
    87  	// Enables custom attributes.
    88  	Attribute ParserAttribute
    89  }
    90  
    91  type ParserAttribute struct {
    92  	// Enables custom attributes for titles.
    93  	Title bool
    94  	// Enables custom attributeds for blocks.
    95  	Block bool
    96  }