Skip to content

Commit

Permalink
feat: add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
HEIGE-PCloud committed Apr 28, 2024
1 parent ff05e94 commit 614e63b
Show file tree
Hide file tree
Showing 3 changed files with 212 additions and 17 deletions.
114 changes: 106 additions & 8 deletions exampleSite/content/posts/basic-markdown-syntax/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -486,11 +486,11 @@ The HTML looks like this:

Use "fences" <code>```</code> to block in multiple lines of code with a language attribute.

{{< highlight markdown >}}
````markdown
```markdown
Sample text here...
```
{{< / highlight >}}
````

The HTML looks like this:

Expand All @@ -509,7 +509,7 @@ To activate it, simply add the file extension of the language you want to use di

For example, to apply syntax highlighting to JavaScript code:

{{< highlight markdown >}}
````markdown {open=true}
```js
grunt.initConfig({
assemble: {
Expand All @@ -530,11 +530,11 @@ grunt.initConfig({
}
};
```
{{< / highlight >}}
````

The rendered output looks like this:

```js
```js {open=true}
grunt.initConfig({
assemble: {
options: {
Expand All @@ -555,9 +555,107 @@ grunt.initConfig({
};
```
{{< admonition >}}
[Syntax highlighting page](https://gohugo.io/content-management/syntax-highlighting/) in **Hugo** Docs introduces more about syntax highlighting, including highlight shortcode.
{{< /admonition >}}
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. |
| `title` | Set the title of the code block. |
Here is an example
````markdown
```go {open=true, lineNos=false, title="main.go"}
package main

import "fmt"

// calculateSquares calculates the sum of the squares of the digits of the given number
// and sends the result to the squareop channel.
func calculateSquares(number int, squareop chan int) {
sum := 0
for number != 0 {
digit := number % 10
sum += digit * digit
number /= 10
}
squareop <- sum
}

// calculateCubes calculates the sum of the cubes of the digits of the given number
// and sends the result to the cubeop channel.
func calculateCubes(number int, cubeop chan int) {
sum := 0
for number != 0 {
digit := number % 10
sum += digit * digit * digit
number /= 10
}
cubeop <- sum
}

func main() {
number := 589
sqrch := make(chan int)
cubech := make(chan int)

// Start two goroutines to calculate the sum of squares and cubes of the digits.
go calculateSquares(number, sqrch)
go calculateCubes(number, cubech)

// Receive the results from the channels and add them.
squares, cubes := <-sqrch, <-cubech
fmt.Println("Final result", squares+cubes)
}
```
````
The rendered output looks like this:
```go {open=true, lineNos=false, title="main.go"}
package main

import "fmt"

// calculateSquares calculates the sum of the squares of the digits of the given number
// and sends the result to the squareop channel.
func calculateSquares(number int, squareop chan int) {
sum := 0
for number != 0 {
digit := number % 10
sum += digit * digit
number /= 10
}
squareop <- sum
}

// calculateCubes calculates the sum of the cubes of the digits of the given number
// and sends the result to the cubeop channel.
func calculateCubes(number int, cubeop chan int) {
sum := 0
for number != 0 {
digit := number % 10
sum += digit * digit * digit
number /= 10
}
cubeop <- sum
}

func main() {
number := 589
sqrch := make(chan int)
cubech := make(chan int)

// Start two goroutines to calculate the sum of squares and cubes of the digits.
go calculateSquares(number, sqrch)
go calculateCubes(number, cubech)

// Receive the results from the channels and add them.
squares, cubes := <-sqrch, <-cubech
fmt.Println("Final result", squares+cubes)
}
```
## Tables
Expand Down
113 changes: 105 additions & 8 deletions exampleSite/content/posts/basic-markdown-syntax/index.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -487,11 +487,11 @@ odio non est accumsan facilisis. Aliquam id turpis in dolor tincidunt mollis ac

使用 "围栏" <code>```</code> 来生成一段带有语言属性的代码块.

{{< highlight markdown >}}
````markdown
```markdown
Sample text here...
```
{{< / highlight >}}
````

输出的 HTML 看起来像这样:

Expand All @@ -510,7 +510,7 @@ Sample text here...

例如, 在以下 JavaScript 代码中应用语法高亮:

{{< highlight markdown >}}
````markdown
```js
grunt.initConfig({
assemble: {
Expand All @@ -531,7 +531,7 @@ grunt.initConfig({
}
};
```
{{< / highlight >}}
````

呈现的输出效果如下:

Expand All @@ -556,10 +556,107 @@ grunt.initConfig({
};
```
{{< admonition >}}
**Hugo** 文档中的 [语法高亮页面](https://gohugo.io/content-management/syntax-highlighting/) 介绍了有关语法高亮的更多信息,
包括语法高亮的 shortcode.
{{< /admonition >}}
您可以通过以下选项来自定义你的代码块。
| 选项 | 描述 |
| ------ | ----------- |
| `open` | 是否展开代码块。默认值由 `maxShownLines` 决定。 |
| `lineNos` | 是否显示行数 |
| `title` | 自定义代码块的标题。 |
以下是一个例子
````markdown
```go {open=true, lineNos=false, title="main.go"}
package main

import "fmt"

// calculateSquares calculates the sum of the squares of the digits of the given number
// and sends the result to the squareop channel.
func calculateSquares(number int, squareop chan int) {
sum := 0
for number != 0 {
digit := number % 10
sum += digit * digit
number /= 10
}
squareop <- sum
}

// calculateCubes calculates the sum of the cubes of the digits of the given number
// and sends the result to the cubeop channel.
func calculateCubes(number int, cubeop chan int) {
sum := 0
for number != 0 {
digit := number % 10
sum += digit * digit * digit
number /= 10
}
cubeop <- sum
}

func main() {
number := 589
sqrch := make(chan int)
cubech := make(chan int)

// Start two goroutines to calculate the sum of squares and cubes of the digits.
go calculateSquares(number, sqrch)
go calculateCubes(number, cubech)

// Receive the results from the channels and add them.
squares, cubes := <-sqrch, <-cubech
fmt.Println("Final result", squares+cubes)
}
```
````
输出的效果如下:
```go {open=true, lineNos=false, title="main.go"}
package main

import "fmt"

// calculateSquares calculates the sum of the squares of the digits of the given number
// and sends the result to the squareop channel.
func calculateSquares(number int, squareop chan int) {
sum := 0
for number != 0 {
digit := number % 10
sum += digit * digit
number /= 10
}
squareop <- sum
}

// calculateCubes calculates the sum of the cubes of the digits of the given number
// and sends the result to the cubeop channel.
func calculateCubes(number int, cubeop chan int) {
sum := 0
for number != 0 {
digit := number % 10
sum += digit * digit * digit
number /= 10
}
cubeop <- sum
}

func main() {
number := 589
sqrch := make(chan int)
cubech := make(chan int)

// Start two goroutines to calculate the sum of squares and cubes of the digits.
go calculateSquares(number, sqrch)
go calculateCubes(number, cubech)

// Receive the results from the channels and add them.
squares, cubes := <-sqrch, <-cubech
fmt.Println("Final result", squares+cubes)
}
```
## 表格
Expand Down
2 changes: 1 addition & 1 deletion layouts/_default/_markup/render-codeblock.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
group-[.is-open]:tw-block
group-[.show-line-numbers]:tw-text-fgColor-link
print:!tw-hidden"
title="Toggle line number">
title="Toggle line numbers">
{{- partial "plugin/fontawesome.html" (dict "Style" "solid" "Icon" "list-ol") -}}
</button>

Expand Down

0 comments on commit 614e63b

Please sign in to comment.