figlet-text-converter

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Figlet 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
    <figlet>
    tags
  • 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
<figlet>
tags anywhere in a file to mark text for ASCII art conversion:
With font specification:
<figlet font="3-D">Text to Convert</figlet>
Using default font (standard):
<figlet>Text to Convert</figlet>
在文件的任意位置插入
<figlet>
标签,标记需要转换为ASCII艺术字的文本:
指定字体:
<figlet font="3-D">Text to Convert</figlet>
使用默认字体(standard):
<figlet>Text to Convert</figlet>

Usage in Different Contexts

不同场景下的用法

Markdown Documents

Markdown文档

markdown
undefined
markdown
undefined

Section Title

Section Title

<figlet font="Standard">Important Notice</figlet>
Content goes here...
undefined
<figlet font="Standard">Important Notice</figlet>
Content goes here...
undefined

Shell Scripts

Shell脚本

bash
#!/bin/bash

echo '<figlet>Deployment Started</figlet>'
bash
#!/bin/bash

echo '<figlet>Deployment Started</figlet>'

Script logic...

Script logic...

undefined
undefined

Python Code

Python代码

python
undefined
python
undefined

<figlet>Configuration</figlet>

<figlet>Configuration</figlet>

config = { 'setting': 'value' }
undefined
config = { 'setting': 'value' }
undefined

PHP/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:
  1. Read the file containing
    <figlet>
    tags
  2. Validate all font names (error immediately if invalid)
  3. 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
  4. Replace tags with formatted ASCII art
  5. Write changes back to the file
当用户请求转换ASCII艺术字时:
  1. 读取包含
    <figlet>
    标签的文件
  2. 验证所有字体名称(若字体无效则立即报错)
  3. 针对每个标签:
    • 提取字体名称(若未指定则使用'standard')
    • 为文本生成ASCII艺术字
    • 检测所在行的注释格式(// # -- /*)
    • 使用合适的注释前缀格式化输出
  4. 用格式化后的ASCII艺术字替换标签
  5. 将修改内容写回文件

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
    <figlet>
    tags, validates fonts, generates ASCII art, detects comment styles, and writes results
  • 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
  • 主处理脚本,负责读取文件、查找所有
    <figlet>
    标签、验证字体、生成ASCII艺术字、检测注释格式并写入结果
  • 首次运行时会自动验证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:
    <figlet font="font-name">text</figlet>
    or
    <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
  • 文件处理方式:原地修改