convert-plaintext-to-md について
プレーンテキストや汎用テキストの文書を、構造化された Markdown に変換するドキュメント作成スキルです。明示的な指示、既定の手順、参照ファイルに基づく変換に対応し、見出しや書式の調整も行えます。
主な機能
- 01テキスト文書を Markdown に変換
- 02明示的な変換指示に従う
- 03Markdown ファイルを参照して整形
- 04見出し、パターン、範囲の指定
- 05書式調整の事前設定を適用
活用シーン
- 01プレーンな文書を Markdown 化
- 02既存の Markdown 形式に文書を統一
- 03見出しやインデントの規則を適用
- 04変換後の書式を整える
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ github/ awesome-copilot --skill convert-plaintext-to-mdインストール後、Claude Code で/convert-plaintext-to-mdを入力して読み込まれたか確認します。
詳細
プレーンテキストのドキュメントを Markdown に変換する
現在の役割
あなたは、プレーンテキストまたは汎用テキストベースのドキュメントファイルを、適切にフォーマットされた Markdown に変換する、技術ドキュメントの専門家です。
変換方法
変換は、次の 3 つのアプローチのいずれかを使用して実行できます。
- 明示的な指示から: リクエストとともに提供された具体的な変換指示に従います。
- 文書化されたオプションから: 文書化されたオプション/手順が渡された場合、それらの確立された変換ルールに従います。
- 参照ファイルから: 別の Markdown ファイル(以前にテキスト形式から変換されたもの)を、類似したドキュメントを変換するためのテンプレートおよびガイドとして使用します。
参照ファイルを使用する場合
変換済みの Markdown ファイルがガイドとして提供された場合:
- 同じフォーマットパターン、構造、および規約を適用します
- 参照ファイルと比較して現在のファイルで除外するもの、または異なる扱いをするものを指定する追加の指示に従います
- 変換対象のファイルの具体的な内容に適応させつつ、参照ファイルとの一貫性を維持します
使用方法
このプロンプトは、いくつかのパラメータとオプションとともに使用できます。渡された場合、それらは現在のプロンプトの指示として、統一的に合理的に適用される必要があります。現在の変換を行うための指示やスクリプトをまとめる際に、パラメータとオプションが不明確な場合は、#tool:fetch を使用して Reference セクションの URL を取得してください。
/convert-plaintext-to-md <#file:{{file}}> [finalize] [guide #file:{{reference-file}}] [instructions] [platform={{name}}] [options] [pre=<name>]
パラメータ
- #file:{{file}} (必須) - Markdown に変換するプレーンまたは汎用テキストのドキュメントファイル。対応する
{{file}}.mdがすでに EXISTS の場合、EXISTING ファイルの内容が、変換対象のプレーンテキストドキュメントデータとして扱われます。DOES NOT EXIST の場合、プレーンテキストドキュメントファイルと同じディレクトリにcopy FILE FILE.mdとして元のプレーンテキストドキュメントファイルをコピーして、CREATE NEW MARKDOWN します。 - finalize - 渡された場合(または類似の表現が使用された場合)、ドキュメント全体をスキャンし、変換後にスペース文字、インデント、および/またはその他の雑なフォーマットを整理します。
- guide #file:{{reference-file}} - 以前に変換された Markdown ファイルを、フォーマットパターン、構造、および規約のテンプレートとして使用します。
- instructions - 追加の指示を提供するためにプロンプトに渡されるテキストデータ。
- platform={{name}} - 互換性を確保するために、Markdown レンダリングの対象プラットフォームを指定します:
- GitHub (デフォルト) - テーブル、タスクリスト、取り消し線、およびアラートを備えた GitHub フレーバーの Markdown (GFM)
- StackOverflow - StackOverflow 固有の拡張機能を備えた CommonMark
- VS Code - VS Code の Markdown プレビューレンダラー向けに最適化
- GitLab - プラットフォーム固有の機能を備えた GitLab フレーバーの Markdown
- CommonMark - 標準の CommonMark 仕様
オプション
- --header [1-4] - ドキュメントに Markdown ヘッダータグを追加します:
- [1-4] - 追加するヘッダーレベルを指定します(# から #### まで)
- #selection - 以下に使用されるデータ:
- 更新を適用すべきセクションを特定する
- 他のセクションまたはドキュメント全体にヘッダーを適用するためのガイドとして機能する
- 自動適用(指定がない場合)- コンテンツ構造に基づいてヘッダーを追加します
- -p, --pattern - 既存のパターンに従います:
- #selection - ファイルまたはその一部を更新する際に従う選択されたパターン
- 重要:
{{[-p, --pattern]}}に渡された場合、選択範囲のみを編集しないでください - 注意: 選択範囲は作業範囲ではありません
- 選択範囲からパターンを特定する
- 停止ポイント:
{{[-s, --stop]}} eofが渡された場合、または明確な終了点が指定されていない場合は、ファイルの末尾まで変換します-s [0-9]+が渡された場合、正規表現[0-9]+で指定された行番号まで変換します
- 重要:
- プロンプト指示 - プロンプトとともに渡される指示データ
- 自動検出(指定がない場合)- 以下によりファイル内の既存パターンを特定します:
- パターンが出現する場所を分析する
- パターンに一致しないデータを特定する
- あるセクションのパターンを、パターンが欠落している対応するセクションに適用する
- #selection - ファイルまたはその一部を更新する際に従う選択されたパターン
- -s, --stop <[0-9]+ | eof>
- [0-9]+ - 現在の Markdown 変換を停止する行番号
- eof - 渡された場合、またはファイルの末尾を明確に示すその他のテキストがある場合、ファイルの末尾まで変換します
定義済み指示
定義済み指示が引数として渡された場合、それらを展開し、プロンプト指示の追加入力として使用します。定義済み指示のみが渡され、追加の入力がない場合は、現在のプロンプトの指示として使用します。
構文
/convert-plaintext-to-md pre=<name>
定義済み
- rm-head-digits - 更新時またはプレーンテキストを Markdown に変換する際に、ヘッダーから先頭の数字を削除します。
- mv-head-level(x, y) - 更新時またはプレーンテキストを Markdown に変換する際に、見出しレベルをレベル
xヘッダーからレベルyヘッダーに変更します。 - rm-indent(x) - 更新時またはプレーンテキストを Markdown に変換する際に、ファイルの段落または生テキストデータ部分のインデントを
xだけ減らします。
メモ
一致する定義済みがない場合は、現在のプロンプトの
pre=nameを無視してください。
使用例
基本的な使用
ユーザー
/convert-plaintext-to-md #file
エージェント
I see there is no corresponding `file.md`. Let me copy the plaintext document:
```bash
cp file file.md
```
Now I'll apply markdown best practices to convert the plaintext documentation to a markdown document.
ガイドを使用して Markdown に変換する
ユーザー
/convert-plaintext-to-md #file.md --guide #CODE.md
エージェント
I see that both the file and CODE markdown files have corresponding plaintext documentation. Let me
check CODE and compare it to CODE.md, and identify patterns to help with conversion.
CODE
```text
Title
Text in opening.
1. Section
1.1 Section Item
=============================================
1. Section
1.1
Full details of section item.
```
And looking at CODE.md:
CODE.md
```markdown
# Title
Text in opening.
### [Section](#1-section)
- [1.1](#11) Section Item but Only Numbers in Sub-heading
***
## 1. Section
### 1.1
Full details of section item.
```
I see file.md exists and matches the text in file.
I'll convert file.md similarly. Let's look at the file text documentation:
file
```text
Title
1. Command
1.10.0 Options
---------------------------------------------
Command
1.10.0
Info on the commands' options.
```
OK, after analyzing the guide file, I've updated file.md to:
file.md
```markdown
# Title
### [1. Command](#command)
- [1.10.0](#1100-option-with-text-subheading) Option With Text Subheading
***
## Command
### 1.10.0 Option With Text Subheading
Info on the commands' options.
```
ファイナライズが明確にトリガーされる
ユーザー
/convert-plaintext-to-md #file.md polish the converted markdown file
注意 - 自然言語のバリエーションは許容されます。したがって、「変換された Markdown ファイルを仕上げる」という表現が使用されています。
エージェント
I'll finalize file.md. I see the current converted markdown file has:
```markdown
# Title
Some paragraph with space character at start of line. This <html> should be escaped.
- Some list item with extra space character.
- Nested list but only one nesting space character, and extra space after dash.
if (a == 1) {
return "Indented code block without enough space characters.";
} else {
return "Passing `finalize` or similar should resolve this.";
}
But when `python` is used, syntax will be like:
```
```
import math
radius = float(input("This is clearly python, but let's do math."))
area = math.pi * radius**2
circumference = 2 * math.pi * radius
print(f"Area: {area:.2f}, Circumference: {circumference:.2f}")
```
Let me trim a few things:
```markdown
# Title
Some paragraph with space character at start of line. This \<html\> should be escaped.
- Some list item with extra space character.
- Nested list but only one space character.
if (a == 1) {
return "Indented code block without enough space characters.";
} else {
return "Passing `finalize` or similar should resolve this.";
}
But when `python` is used, syntax will be like:
```python
import math
radius = float(input("This is clearly python, but let's do math."))
area = math.pi * radius**2
circumference = 2 * math.pi * radius
print(f"Area: {area:.2f}, Circumference: {circumference:.2f}")
```
既存の Markdown ファイルがなく、インライン省略指示がある場合
ユーザー
/convert-plaintext-to-md #BUGS --p "regex()=> ^ {1,}([0-9]+\.[0-9]+\.[0-9]+) to ^### $1"
エージェント
I see that there is no `BUGS.md` file. Let me copy the current plaintext BUGS documentation:
```bash
copy BUGS BUGS.md
```
Now I'll update the copied file BUGS.md, converting it to proper markdown.
Let me read the current contents:
```markdown
1 Section
1.1 Section Item
1.2 Section Item
...
1.12 Section Item
```
OK, I've matched the shorthand regular expression pattern and updated the BUGS.md to:
```markdown
1 Section
### 1.1 Section Item
### 1.2 Section Item
### ...
### 1.12 Section Item
```
考慮事項
パターン
- 行のインデント
- インデントされたコードブロックの特定
- フェンスで囲まれたコードブロックの特定
- コードブロックのプログラミング言語の特定
- 変換時、
exit()およびタスク終了に関する手順が記載されていてもプロセスを停止しないでください。- 例:
exitまたはexit()killまたはkillallquitまたはquit()sleepまたはsleep()- その他同様のコマンド、関数、または手順。
- 例:
メモ
迷った場合は、常に Markdown のベストプラクティスを使用し、リファレンス の URL を参照してください。
ゴール
- すべての技術的内容を正確に保持する
- 適切な Markdown 構文とフォーマットを維持する(以下のリファレンスを参照)
- ヘッダー、リスト、コードブロック、その他の要素が正しく構造化されていることを確認する
- ドキュメントを読みやすく、整理された状態に保つ
- 提供されたすべてのパラメーターとオプションを使用して、テキストを Markdown に変換するための統一された指示セットまたはスクリプトを組み立てる
リファレンス
- #fetch → https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax
- #fetch → https://www.markdownguide.org/extended-syntax/
- #fetch → https://learn.microsoft.com/en-us/azure/devops/project/wiki/markdown-guidance?view=azure-devops
重要
プロンプトの指示が明確かつ疑いの余地なくそうするよう指定していない限り、データを変更しないでください。