github.com/graemephi/kahugo@v0.62.3-0.20211121071557-d78c0423784d/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  	Katex: Katex{
    46  		Enable:   true,
    47  		Warnings: false,
    48  	},
    49  }
    50  
    51  // Config configures Goldmark.
    52  type Config struct {
    53  	Renderer   Renderer
    54  	Parser     Parser
    55  	Extensions Extensions
    56  	Katex      Katex
    57  }
    58  
    59  type Extensions struct {
    60  	Typographer    bool
    61  	Footnote       bool
    62  	DefinitionList bool
    63  
    64  	// GitHub flavored markdown
    65  	Table         bool
    66  	Strikethrough bool
    67  	Linkify       bool
    68  	TaskList      bool
    69  }
    70  
    71  type Renderer struct {
    72  	// Whether softline breaks should be rendered as '<br>'
    73  	HardWraps bool
    74  
    75  	// XHTML instead of HTML5.
    76  	XHTML bool
    77  
    78  	// Allow raw HTML etc.
    79  	Unsafe bool
    80  }
    81  
    82  type Parser struct {
    83  	// Enables custom heading ids and
    84  	// auto generated heading ids.
    85  	AutoHeadingID bool
    86  
    87  	// The strategy to use when generating heading IDs.
    88  	// Available options are "github", "github-ascii".
    89  	// Default is "github", which will create GitHub-compatible anchor names.
    90  	AutoHeadingIDType string
    91  
    92  	// Enables custom attributes.
    93  	Attribute ParserAttribute
    94  }
    95  
    96  type ParserAttribute struct {
    97  	// Enables custom attributes for titles.
    98  	Title bool
    99  	// Enables custom attributeds for blocks.
   100  	Block bool
   101  }
   102  
   103  type Katex struct {
   104  	// Enable the Katex extension.
   105  	Enable bool
   106  	// Enables warnings.
   107  	Warnings bool
   108  }