Skip to content

Commit b9fb0be

Browse files
authored
Change code example type (#3619)
1 parent 63089cd commit b9fb0be

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

private/bufpkg/bufcobra/markdown.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ func generateMarkdownPage(
104104
p("\n\n")
105105
if command.Runnable() {
106106
p("### Usage\n")
107-
p("```terminal\n$ %s\n```\n\n", command.UseLine())
107+
p("```console\n$ %s\n```\n\n", command.UseLine())
108108
}
109109
if len(command.Long) > 0 {
110110
p("### Description\n\n")
111111
p("%s \n\n", processDescription(command.Long))
112112
}
113113
if len(command.Example) > 0 {
114114
p("### Examples\n\n")
115-
p("```\n%s\n```\n\n", processDescription(command.Example))
115+
p("```console\n%s\n```\n\n", processDescription(command.Example))
116116
}
117117
commandFlags := command.NonInheritedFlags()
118118
if commandFlags.HasAvailableFlags() {
@@ -183,15 +183,12 @@ func hasSubCommands(cmd *cobra.Command) bool {
183183

184184
// processDescription is used to process description and example text. It does the following:
185185
//
186-
// - Converts all code blocks to terminal code blocks (```terminal)
187-
// - Unidents code blocks
186+
// - Converts all code blocks to console code blocks (```console)
187+
// - Unindents code blocks
188188
// - Writes out the text, escaping all HTML characters.
189189
//
190-
// This is done because terminal code blocks have special handling in some documentation
191-
// systems (e.g. not copying the $ sign if the code block has a copy button).
192-
//
193-
// Also, Docusaurus treats indented code blocks different and does not escape HTML characters
194-
// so we do call that here unilaterally.
190+
// This is done because Pygments (which mkdocs-material uses for syntax highlighting)
191+
// specifies `console` as the language for bash sessions in code blocks.
195192
func processDescription(description string) string {
196193
out := &bytes.Buffer{}
197194
read := bufio.NewReader(strings.NewReader(description))
@@ -206,7 +203,7 @@ func processDescription(description string) string {
206203
// $ isn't copied when using the copy button
207204
if codeBlockRegex.MatchString(text) {
208205
if !inCodeBlock {
209-
out.WriteString("```terminal\n")
206+
out.WriteString("```console\n")
210207
inCodeBlock = true
211208
}
212209
// remove the indentation level from the indented code block

0 commit comments

Comments
 (0)