figlet-text-converter
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFiglet Text Converter
Figlet文本转换器
Overview
概述
This skill converts marked text in files to ASCII art using the figlet library. It uses a simple, universal tag syntax that works across all file types and intelligently preserves comment formatting when tags are placed in commented sections. The skill handles dependency management automatically and supports 400+ fonts with sensible defaults.
本技能借助figlet库将文件中标记的文本转换为ASCII艺术字。它采用简单通用的标签语法,适用于所有文件类型,且当标签位于注释区域时,能智能保留注释格式。该技能可自动处理依赖管理,支持400余种字体,并提供合理的默认配置。
When to Use This Skill
适用场景
Use this skill when:
- User asks to convert text in a file to ASCII art
- User provides a file containing tags
<figlet> - User requests to list available figlet fonts
- User wants to add visual ASCII art headers or banners to code, documentation, or configuration files
在以下场景中使用本技能:
- 用户要求将文件中的文本转换为ASCII艺术字
- 用户提供包含标签的文件
<figlet> - 用户请求列出可用的figlet字体
- 用户希望为代码、文档或配置文件添加可视化的ASCII艺术字标题或横幅
Tag Syntax
标签语法
Universal Markup
通用标记
Insert tags anywhere in a file to mark text for ASCII art conversion:
<figlet>With font specification:
<figlet font="3-D">Text to Convert</figlet>Using default font (standard):
<figlet>Text to Convert</figlet>在文件的任意位置插入标签,标记需要转换为ASCII艺术字的文本:
<figlet>指定字体:
<figlet font="3-D">Text to Convert</figlet>使用默认字体(standard):
<figlet>Text to Convert</figlet>Usage in Different Contexts
不同场景下的用法
Markdown Documents
Markdown文档
markdown
undefinedmarkdown
undefinedSection Title
Section Title
<figlet font="Standard">Important Notice</figlet>
Content goes here...
undefined<figlet font="Standard">Important Notice</figlet>
Content goes here...
undefinedShell Scripts
Shell脚本
bash
#!/bin/bash
echo '<figlet>Deployment Started</figlet>'bash
#!/bin/bash
echo '<figlet>Deployment Started</figlet>'Script logic...
Script logic...
undefinedundefinedPython Code
Python代码
python
undefinedpython
undefined<figlet>Configuration</figlet>
<figlet>Configuration</figlet>
config = {
'setting': 'value'
}
undefinedconfig = {
'setting': 'value'
}
undefinedPHP/JavaScript
PHP/JavaScript
php
// <figlet font="Block">Database Connection</figlet>
function connectDB() {
// ...
}php
// <figlet font="Block">Database Connection</figlet>
function connectDB() {
// ...
}Plain Text/Config Files
纯文本/配置文件
<figlet>System Status Report</figlet>
This report contains...<figlet>System Status Report</figlet>
This report contains...Workflow
工作流程
Processing a File
文件处理
When a user requests ASCII art conversion:
- Read the file containing tags
<figlet> - Validate all font names (error immediately if invalid)
- For each tag:
- Extract the font name (or use 'standard' if omitted)
- Generate ASCII art for the text
- Detect comment style from the surrounding line (// # -- /*)
- Format output with appropriate comment prefixes
- Replace tags with formatted ASCII art
- Write changes back to the file
当用户请求转换ASCII艺术字时:
- 读取包含标签的文件
<figlet> - 验证所有字体名称(若字体无效则立即报错)
- 针对每个标签:
- 提取字体名称(若未指定则使用'standard')
- 为文本生成ASCII艺术字
- 检测所在行的注释格式(// # -- /*)
- 使用合适的注释前缀格式化输出
- 用格式化后的ASCII艺术字替换标签
- 将修改内容写回文件
Handling Comments
注释处理
The skill automatically detects comment context:
Single-line comments:
bash
// <figlet>Section Break</figlet>Outputs each line with prefix:
// bash
// ___ _ _ ____ _
// / __| ___ | | | | ___ _ _ | __ ) _ _ __| | |
// \__ \/ -_) | |_| |/ _ \| ' \ | _ \| '_|/ _` | |
// |___/\___| \___/ \___/|_|_|_| |_| \_\_| \__,_|_|Hash comments (Python, Shell):
python
undefined该技能可自动检测注释上下文:
单行注释:
bash
// <figlet>Section Break</figlet>输出的每一行都会带有前缀:
// bash
// ___ _ _ ____ _
// / __| ___ | | | | ___ _ _ | __ ) _ _ __| | |
// \__ \/ -_) | |_| |/ _ \| ' \ | _ \| '_|/ _` | |
// |___/\___| \___/ \___/|_|_|_| |_| \_\_| \__,_|_|哈希注释(Python、Shell):
python
undefined<figlet>Configuration</figlet>
<figlet>Configuration</figlet>
Outputs with `# ` prefix.
**SQL/SQL comments:**
```sql
-- <figlet>Query Section</figlet>Outputs with prefix.
-- Block comments:
java
/* <figlet>Module Start</figlet>Outputs with prefix:
*java
* ___ _ _ _ ___ _ _
* | \/ | ___ __| | _ | | ___ / __| | |_ __ _ _ | |_
* | |\/| |/ _ \ / _` ||_|| |/ -_) \__ \ | _|/ _` || || _|
* |_| |_|\___/ \__,_| \__/ \___| |___/ |_| \__,_|\__|\__|Plain text (no comment prefix):
<figlet>Plain ASCII Art</figlet>Outputs raw ASCII art without formatting.
输出会带有`# `前缀。
**SQL注释:**
```sql
-- <figlet>Query Section</figlet>输出会带有前缀。
-- 块注释:
java
/* <figlet>Module Start</figlet>输出会带有前缀:
*java
* ___ _ _ _ ___ _ _
* | \/ | ___ __| | _ | | ___ / __| | |_ __ _ _ | |_
* | |\/| |/ _ \ / _` ||_|| |/ -_) \__ \ | _|/ _` || || _|
* |_| |_|\___/ \__,_| \__/ \___| |___/ |_| \__,_|\__|\__|纯文本(无注释前缀):
<figlet>Plain ASCII Art</figlet>输出原始ASCII艺术字,不带任何格式。
Font Selection
字体选择
Default Font
默认字体
If no font is specified, 'standard' is used:
<figlet>Default Font Example</figlet>若未指定字体,将使用'standard'字体:
<figlet>Default Font Example</figlet>Custom Fonts
自定义字体
Specify any of 400+ available fonts:
<figlet font="Block">Bold Text</figlet>
<figlet font="3-D">3D Effect</figlet>
<figlet font="Shadow">Shadowed</figlet>可指定400余种可用字体中的任意一种:
<figlet font="Block">Bold Text</figlet>
<figlet font="3-D">3D Effect</figlet>
<figlet font="Shadow">Shadowed</figlet>Finding Fonts
查找字体
When user requests to list available fonts, run the font discovery script to show:
- Previews of the first 10 fonts with examples
- Complete alphabetical listing of all 400+ fonts
- Font names for use in tags
Popular fonts:
- standard (default)
- 3-D
- Block
- Big
- Shadow
- Slant
- Graffiti
- Doom
当用户请求列出可用字体时,运行字体发现脚本可展示:
- 前10种字体的预览及示例
- 所有400余种字体的完整字母顺序列表
- 可在标签中使用的字体名称
热门字体:
- standard(默认)
- 3-D
- Block
- Big
- Shadow
- Slant
- Graffiti
- Doom
Error Handling
错误处理
The skill validates fonts before processing:
- Invalid font specified: Error immediately with font name and suggestion to list available fonts
- File not found: Error with file path
- Node.js/npm issues: Error with installation instructions
该技能在处理前会验证字体:
- 指定的字体无效:立即报错,告知无效字体名称,并建议用户列出可用字体
- 文件未找到:报错并显示文件路径
- Node.js/npm问题:报错并提供安装说明
Bundled Resources
内置资源
scripts/
scripts/
process-file.js
- Main processing script that reads files, finds all tags, validates fonts, generates ASCII art, detects comment styles, and writes results
<figlet> - Handles automatic Node.js verification and npm dependency installation on first run
- Usage:
node process-file.js <file-path>
list-fonts.js
- Displays all available figlet fonts with previews and complete listing
- Helps users find the exact font names to use in tags
- Usage:
node list-fonts.js
package.json
- Node.js project file with figlet v1.7.0+ dependency
.gitignore
- Excludes node_modules from version control
process-file.js
- 主处理脚本,负责读取文件、查找所有标签、验证字体、生成ASCII艺术字、检测注释格式并写入结果
<figlet> - 首次运行时会自动验证Node.js环境并安装npm依赖
- 使用方法:
node process-file.js <file-path>
list-fonts.js
- 展示所有可用的figlet字体,包含预览及完整列表
- 帮助用户找到可在标签中使用的准确字体名称
- 使用方法:
node list-fonts.js
package.json
- Node.js项目文件,依赖figlet v1.7.0及以上版本
.gitignore
- 排除node_modules目录,不纳入版本控制
references/
references/
usage-guide.md - Comprehensive reference documentation for all features and edge cases
usage-guide.md - 涵盖所有功能及边缘情况的综合参考文档
Technical Details
技术细节
- Node.js Requirement: v14 or higher
- Figlet Package: v1.7.0 or higher (auto-installed on first use)
- Tag Format: or
<figlet font="font-name">text</figlet><figlet>text</figlet> - Comment Styles Supported: //, #, --, /*, or none
- Default Font: standard
- File Processing: In-place modification
- Node.js要求:v14或更高版本
- Figlet包版本:v1.7.0或更高版本(首次使用时自动安装)
- 标签格式:或
<figlet font="font-name">text</figlet><figlet>text</figlet> - 支持的注释格式://、#、--、/* 或无注释
- 默认字体:standard
- 文件处理方式:原地修改