markup/goldmark: Add attributes support for blocks (tables etc.)

E.g.:

```
> foo
> bar
{.myclass}
```

There are some current limitations: For tables you can currently only apply it to the full table, and for lists the ul/ol-nodes only, e.g.:

```
* Fruit
  * Apple
  * Orange
  * Banana
  {.fruits}
* Dairy
  * Milk
  * Cheese
  {.dairies}
{.list}
```

Fixes #7548
This commit is contained in:
Bjørn Erik Pedersen
2021-02-07 18:08:46 +01:00
parent 1b24728256
commit 2681633db8
8 changed files with 303 additions and 6 deletions

View File

@@ -44,6 +44,8 @@ type Config struct {
func Decode(cfg config.Provider) (conf Config, err error) {
conf = Default
normalizeConfig(cfg)
m := cfg.GetStringMap("markup")
if m == nil {
return
@@ -65,6 +67,17 @@ func Decode(cfg config.Provider) (conf Config, err error) {
return
}
func normalizeConfig(cfg config.Provider) {
// Changed from a bool in 0.81.0
const attrKey = "markup.goldmark.parser.attribute"
av := cfg.Get(attrKey)
if avb, ok := av.(bool); ok {
cfg.Set(attrKey, goldmark_config.ParserAttribute{
Title: avb,
})
}
}
func applyLegacyConfig(cfg config.Provider, conf *Config) error {
if bm := cfg.GetStringMap("blackfriday"); bm != nil {
// Legacy top level blackfriday config.