diff --git a/internal/cmd/preprocessor/cmd/sidebyside_node.go b/internal/cmd/preprocessor/cmd/sidebyside_node.go index 668670dc6..8c4f1183a 100644 --- a/internal/cmd/preprocessor/cmd/sidebyside_node.go +++ b/internal/cmd/preprocessor/cmd/sidebyside_node.go @@ -205,18 +205,18 @@ func (s *sidebysideNode) writeTransformTo(b *bytes.Buffer) error { in, out := analyses[0], analyses[1] tabs[0] = tabProps{ Name: strings.ToUpper(in.Ext), - Language: in.Ext, + Language: in.Language, } tabs[1] = tabProps{ Name: strings.ToUpper(out.Ext), - Language: out.Ext, + Language: out.Language, Type: "terminal", } } else { for i, a := range analyses { tp := &tabs[i] tp.Name = a.Filepath - tp.Language = a.Ext + tp.Language = a.Language if a.IsOut { tp.Name = "TERMINAL" tp.Type = "terminal" diff --git a/internal/cmd/preprocessor/cmd/txtar_node.go b/internal/cmd/preprocessor/cmd/txtar_node.go index 2870d8405..f4d6e326e 100644 --- a/internal/cmd/preprocessor/cmd/txtar_node.go +++ b/internal/cmd/preprocessor/cmd/txtar_node.go @@ -178,6 +178,11 @@ type filenameAnalysis struct { // IsOut is set if the file is considered an output in the archive. IsOut bool + + // Language is the name used when rendering a code block for the + // archive file. In most cases this will be the same value as Ext + // but this field exists in order to allow for varying it. + Language string } // analyseTxtarArchive provides common analysis that is used by @@ -221,6 +226,8 @@ func analyseFilename(p string) (res filenameAnalysis) { // Found a . res.Basename = b[:i] res.Ext = b[i+1:] + + res.Language = res.Ext } switch res.Basename { case "out", "stdout": diff --git a/internal/cmd/preprocessor/cmd/upload_node.go b/internal/cmd/preprocessor/cmd/upload_node.go index 3b75c366a..b611514d5 100644 --- a/internal/cmd/preprocessor/cmd/upload_node.go +++ b/internal/cmd/preprocessor/cmd/upload_node.go @@ -43,7 +43,7 @@ func (u *uploadNode) writeTransformTo(b *bytes.Buffer) error { a := u.analysis.fileNames[0] props := tabProps{ Name: f.Name, - Language: a.Ext, + Language: a.Language, } p("```%s { title=%q", props.Language, props.Name)