Skill站外收录 @skilllib/skill-2117939930272411506
check-highlights
用于校验 Markdown代码块中高亮行标记的准确性,确保 hl_lines 属性正确指向代码片段内需强调的实际内容行,尤其适用于文档审阅、前后对比示例验证及高亮逻辑排查场景。
效率工具 AI 技能
Skills.MD
# Check Code Block Highlights
Verify that `hl_lines` attributes in markdown code blocks are correctly set to highlight the intended lines.
## Critical Understanding
**`hl_lines` is snippet-relative, NOT related to `linenums`**:
- `linenums="21"` sets the _displayed_ starting line number
- `hl_lines="3"` highlights the _3rd line of the snippet_ (which displays as line 23)
- These are completely independent attributes
Example:
```markdown
`groovy linenums="21" hl_lines="3"
process FOO { <- displayed as line 21 (snippet line 1)
input: <- displayed as line 22 (snippet line 2)
val x <- displayed as line 23 (snippet line 3) - HIGHLIGHTED
}
`
```
## When to Use
- After writing or editing code blocks with highlights
- When reviewing Before/After comparison blocks
- When a user reports highlights look wrong
- As part of lesson review/validation
## How to Check
For each code block with `hl_lines`:
1. **Identify the code block** - Find blocks with `hl_lines="..."` attribute
2. **Count snippet lines** - Number each line of the code block starting from 1:
```
1: #!/usr/bin/env nextflow
2: (blank line)
3: process FOO {
4: publishDir 'results' <- if this should be highlighted, hl_lines should include "4"
...
```
3. **Verify intent** - For Before/After blocks:
- "After" should highlight the NEW or CHANGED lines
- "Before" should highlight the lines that WILL change (same content positions)
- Both blocks should highlight corresponding lines showing the difference
4. **Check for common errors**:
- Off-by-one errors (highlighting blank lines instead of code)
- Confusing `linenums` with `hl_lines` (thinking hl_lines="21" highlights displayed line 21)
- Highlighting section headers (`input:`, `output:`) instead of the actual values
## Fixing Issues
When you find incorrect highlights:
1. Count the actual line positions in the snippet (1-indexed)
2. Identify which lines contain the meaningful changes
3. Update `hl_lines` to reference those snippet line numbers
4. Verify Before/After blocks highlight corresponding positions
## Output Format
For each file checked, report:
```
## [filename]
### Block at line [N]: [description]
- Current: hl_lines="X Y Z"
- Lines X, Y, Z contain: [what's on those lines]
- Issue: [description of problem, if any]
- Suggested fix: hl_lines="A B C" (highlighting [what those lines contain])
### Summary
- Blocks checked: N
- Issues found: M
- [List of fixes needed]
```
## Example Analysis
Given this code block:
```markdown
`groovy title="example.nf" linenums="1" hl_lines="8 11 14"
#!/usr/bin/env nextflow <- snippet line 1
<- snippet line 2 (blank)
process SAY_HELLO { <- snippet line 3
<- snippet line 4 (blank)
publishDir 'results' <- snippet line 5
<- snippet line 6 (blank)
input: <- snippet line 7
val greeting <- snippet line 8 - HIGHLIGHTED
<- snippet line 9 (blank)
output: <- snippet line 10
path "*.txt" <- snippet line 11 - HIGHLIGHTED
<- snippet line 12 (blank)
script: <- snippet line 13
"""echo hi""" <- snippet line 14 - HIGHLIGHTED
}
`
```
Analysis: `hl_lines="8 11 14"` correctly highlights the input value (line 8), output value (line 11), and script content (line 14).
## Notes
- Blank lines count! They're common sources of off-by-one errors
- In Before/After comparisons, both blocks should highlight the same conceptual elements
- When in doubt, count every line including blanks and comments
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「check-highlights」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次