mirror of
https://github.com/imfing/hextra.git
synced 2025-08-23 12:46:39 -04:00

* docs(blog): prepare for v0.10 release post * Update v0.10.md * Update v0.10.md to refine upgrade instructions and enhance blog features. Added synchronized tab switching and pagination controls, while improving the search experience and table of contents navigation. * Enhance v0.10 release documentation with detailed upgrade instructions and migration guide. Added Tailwind theme variable customization section and clarified breaking changes. Improved clarity on CSS class prefix changes for better user experience. * Update v0.10.md to enhance upgrade instructions, clarify breaking changes, and improve overall readability. Adjusted formatting for consistency and added details on asset management and user experience improvements. * Add notable new features to v0.10.md, including dropdown menu support, enhanced search experience, and blog list pagination. Updated FlexSearch upgrade details for clarity and improved migration guide by removing redundant breaking change notes. * chore: update zh-cn translation * chore: update ja translation * chore: update fa and ja translations * chore: prepare release
2.3 KiB
2.3 KiB
title, weight
title | weight |
---|---|
语法高亮 | 3 |
Hugo 使用纯 Go 编写的通用语法高亮工具 Chroma 来实现代码高亮。建议在 Markdown 内容中使用反引号标记代码块,例如:
```python
def say_hello():
print("Hello!")
```
将渲染为:
def say_hello():
print("Hello!")
功能特性
文件名标注
通过设置 filename
属性可为代码块添加文件名或标题:
```python {filename="hello.py"}
def say_hello():
print("Hello!")
```
def say_hello():
print("Hello!")
文件链接
{{< new-feature version="v0.9.2" >}}
通过 base_url
属性可设置基础 URL,该 URL 会与文件名组合生成可点击的链接。文件名可包含相对路径以指定文件在基础路径中的位置。
```go {base_url="https://github.com/imfing/hextra/blob/main/",filename="exampleSite/hugo.work"}
go 1.20
```
go 1.20
行号显示
设置 linenos=table
可启用行号,并通过 linenostart
指定起始行号:
```python {linenos=table,linenostart=42}
def say_hello():
print("Hello!")
```
42
43
def say_hello():
print("Hello!")
行高亮
通过 hl_lines
属性可高亮指定行号(支持数组格式):
```python {linenos=table,hl_lines=[2,4],linenostart=1,filename="hello.py"}
def say_hello():
print("Hello!")
def main():
say_hello()
```
1
2
3
4
5
def say_hello():
print("Hello!")
def main():
say_hello()
复制按钮
代码块默认启用复制功能,可通过站点配置文件修改其行为:
42
43
44
45
46
47
params:
highlight:
copy:
enable: true
# hover | always
display: hover
支持语言
完整支持的语言列表请参阅 Chroma 文档。