Skip to content

Why this code is not adding a simple class into a node? #333

@gvlpedro

Description

@gvlpedro

I modified the method modifyAst to add a simple class 'underline' to links but it does not work, why?

// example based on https://arslexis.io/goplayground/#2yV5-HDKBUV

func modifyAst(doc ast.Node) ast.Node {
	ast.WalkFunc(doc, func(node ast.Node, entering bool) ast.WalkStatus {
		if link, ok := node.(*ast.Link); ok && entering {
			if link.Attribute == nil {
				link.Attribute = &ast.Attribute{}
			}
			link.Attribute.Classes = append(link.Attribute.Classes, []byte("underline"))
		}
		return ast.GoToNext
	})
	return doc
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions