markup/goldmark: Add config options for the typographer extension

Note that the config per language part of this will be handled in #10602.

Updates #9772
This commit is contained in:
Bjørn Erik Pedersen
2023-04-12 10:15:02 +02:00
parent d01731d53c
commit 5596dc24a0
5 changed files with 139 additions and 12 deletions

View File

@@ -23,7 +23,19 @@ const (
// DefaultConfig holds the default Goldmark configuration.
var Default = Config{
Extensions: Extensions{
Typographer: true,
Typographer: Typographer{
Disable: false,
LeftSingleQuote: "‘",
RightSingleQuote: "’",
LeftDoubleQuote: "“",
RightDoubleQuote: "”",
EnDash: "–",
EmDash: "—",
Ellipsis: "…",
LeftAngleQuote: "«",
RightAngleQuote: "»",
Apostrophe: "’",
},
Footnote: true,
DefinitionList: true,
Table: true,
@@ -54,7 +66,7 @@ type Config struct {
}
type Extensions struct {
Typographer bool
Typographer Typographer
Footnote bool
DefinitionList bool
@@ -66,6 +78,33 @@ type Extensions struct {
TaskList bool
}
// Typographer holds typographer configuration.
type Typographer struct {
// Whether to disable typographer.
Disable bool
// Value used for left single quote.
LeftSingleQuote string
// Value used for right single quote.
RightSingleQuote string
// Value used for left double quote.
LeftDoubleQuote string
// Value used for right double quote.
RightDoubleQuote string
// Value used for en dash.
EnDash string
// Value used for em dash.
EmDash string
// Value used for ellipsis.
Ellipsis string
// Value used for left angle quote.
LeftAngleQuote string
// Value used for right angle quote.
RightAngleQuote string
// Value used for apostrophe.
Apostrophe string
}
type Renderer struct {
// Whether softline breaks should be rendered as '<br>'
HardWraps bool