{"record":{"id":"f2834ae5a1cb7a6a","repo":"gohugoio/hugo","slug":"must-provide-at-least-one-argument","errorCode":null,"errorMessage":"must provide at least one argument","messagePattern":"must provide at least one argument","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/transform/transform.go","lineNumber":259,"sourceCode":"// We may add more options in the future.\nfunc (ns *Namespace) PortableText(v any) (string, error) {\n\tbuf := bp.GetBuffer()\n\tdefer bp.PutBuffer(buf)\n\topts := goportabletext.ToMarkdownOptions{\n\t\tDst: buf,\n\t\tSrc: v,\n\t}\n\tif err := goportabletext.ToMarkdown(opts); err != nil {\n\t\treturn \"\", err\n\t}\n\treturn buf.String(), nil\n}\n\n// ToMath converts a LaTeX string to math in the given format, default MathML.\n// This uses KaTeX to render the math, see https://katex.org/.\nfunc (ns *Namespace) ToMath(ctx context.Context, args ...any) (template.HTML, error) {\n\tif len(args) < 1 {\n\t\treturn \"\", errors.New(\"must provide at least one argument\")\n\t}\n\texpression, err := cast.ToStringE(args[0])\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tkatexInput := warpc.KatexInput{\n\t\tExpression: expression,\n\t\tOptions: warpc.KatexOptions{\n\t\t\tOutput:           \"mathml\",\n\t\t\tMinRuleThickness: 0.04,\n\t\t\tErrorColor:       \"#cc0000\",\n\t\t\tThrowOnError:     true,\n\t\t\tStrict:           \"error\",\n\t\t},\n\t}\n\n\tif len(args) > 1 {","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/transform/transform.go#L241-L277","documentation":"Thrown by transform.ToMath when no argument is supplied (tpl/transform/transform.go:258-259). ToMath requires at least a LaTeX expression string; it renders math to MathML via KaTeX.","triggerScenarios":"Calling {{ transform.ToMath }} with no arguments, or piping nothing into it.","commonSituations":"Forgetting the expression; using a partial that doesn't forward the expression; conditionally rendering a math block where the value is absent.","solutions":["Always pass the expression: {{ transform.ToMath \"e^{i\\\\pi}+1=0\" }}.","Guard against empty input: {{ with .Expr }}{{ transform.ToMath . }}{{ end }}."],"exampleFix":"// before\n{{ transform.ToMath }}\n// after\n{{ transform.ToMath \"\\\\frac{a}{b}\" }}","handlingStrategy":"validation","validationCode":"{{ with .Expr }}{{ transform.ToMath . }}{{ end }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass the LaTeX expression.","Guard optional math blocks with {{ with }}."],"tags":["template-function","transform","tomath","katex","arity","argument"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}