diff --git a/exampleSite/content/posts/basic-markdown-syntax/index.en.md b/exampleSite/content/posts/basic-markdown-syntax/index.en.md index 3bd940593..1ffeab1fc 100644 --- a/exampleSite/content/posts/basic-markdown-syntax/index.en.md +++ b/exampleSite/content/posts/basic-markdown-syntax/index.en.md @@ -557,17 +557,18 @@ grunt.initConfig({ You can supply extra options to the code block. -| Option | Description | -| ------ | ----------- | -| `open` | Whether to expand the code block. The default value is determined by the `maxShownLines` option. | -| `lineNos` | Whether to show line numbers. | -| `wrap` | Whether to wrap lines when they overflow. | -| `title` | Set the title of the code block. | +| Option | Description | Type | +| ------ | ----------- | ---- | +| open | Whether to expand the code block. The default value is determined by the `maxShownLines` option. | bool | +| lineNos | Whether to show line numbers. | int | +| wrap | Whether to wrap lines when they overflow. | bool | +| title | Set the title of the code block. | string | +| header | Whether to display the code header and control buttons. | bool | Here is an example ````markdown {open=true} -```go {open=true, lineNos=false, wrap=true, title="main.go"} +```go {open=true, lineNos=false, wrap=true, title="main.go", header=false} package main import "fmt" @@ -614,7 +615,7 @@ func main() { The rendered output looks like this: -```go {open=true, lineNos=false, wrap=true, title="main.go"} +```go {open=true, lineNos=false, wrap=true, title="main.go", header=false} package main import "fmt" diff --git a/exampleSite/content/posts/basic-markdown-syntax/index.zh-cn.md b/exampleSite/content/posts/basic-markdown-syntax/index.zh-cn.md index 88f471016..c8fe97a55 100644 --- a/exampleSite/content/posts/basic-markdown-syntax/index.zh-cn.md +++ b/exampleSite/content/posts/basic-markdown-syntax/index.zh-cn.md @@ -558,17 +558,19 @@ grunt.initConfig({ 您可以通过以下选项来自定义你的代码块: -| 选项 | 描述 | -| ------ | ----------- | -| `open` | 是否展开代码块。默认值由 `maxShownLines` 决定。 | -| `lineNos` | 是否显示行数。 | -| `wrap` | 长度溢出时是否换行。 | -| `title` | 自定义代码块的标题。 | +| 选项 | 描述 | 类型 | +| ------ | ----------- | ---- | +| open | 是否展开代码块。默认值由 `maxShownLines` 决定。 | bool | +| lineNos | 是否显示行数。 | int | +| wrap | 长度溢出时是否换行。 | bool | +| title | 自定义代码块的标题。 | string | +| header | 是否显示标题与控制按钮。 | bool | + 以下是一个例子: ````markdown {open=true} -```go {open=true, lineNos=false, wrap=true, title="main.go"} +```go {open=true, lineNos=false, wrap=true, header=false, title="main.go"} package main import "fmt" @@ -615,7 +617,7 @@ func main() { 输出的效果如下: -```go {open=true, lineNos=false, wrap=true, title="main.go"} +```go {open=true, lineNos=false, wrap=true, header=false, title="main.go"} package main import "fmt" diff --git a/exampleSite/content/posts/tests/codeblock-tests/index.en.md b/exampleSite/content/posts/tests/codeblock-tests/index.en.md index beab35881..872471c50 100644 --- a/exampleSite/content/posts/tests/codeblock-tests/index.en.md +++ b/exampleSite/content/posts/tests/codeblock-tests/index.en.md @@ -81,4 +81,13 @@ int main() std::cout << "Hello world!" << std::endl; return 0; } +``` + +```cpp {header=false} +#include +int main() +{ + std::cout << "Hello world!" << std::endl; + return 0; +} ``` \ No newline at end of file diff --git a/layouts/_default/_markup/render-codeblock.html b/layouts/_default/_markup/render-codeblock.html index 435928f09..97e8c0d22 100644 --- a/layouts/_default/_markup/render-codeblock.html +++ b/layouts/_default/_markup/render-codeblock.html @@ -11,10 +11,11 @@ {{- $open = cond (eq .Attributes.open false) "is-closed" "is-open" -}} {{- end -}} {{- $wrap := cond (eq .Attributes.wrap true) "is-wrap" "" -}} - +{{- $header := cond (eq .Attributes.header false) "tw-hidden" "" -}}