Skip to content

Commit 71ed274

Browse files
jhaugaCopilot
andauthored
add convert-plaintext-to-md prompt (#455)
* add convert-plaintext-to-md prompt * add convert-plaintext-to-md prompt Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent 9505d75 commit 71ed274

File tree

2 files changed

+364
-0
lines changed

2 files changed

+364
-0
lines changed

docs/README.prompts.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Ready-to-use prompt templates for specific development scenarios and tasks, defi
3636
| [Comprehensive Project Architecture Blueprint Generator](../prompts/architecture-blueprint-generator.prompt.md)<br />[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Farchitecture-blueprint-generator.prompt.md)<br />[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Farchitecture-blueprint-generator.prompt.md) | Comprehensive project architecture blueprint generator that analyzes codebases to create detailed architectural documentation. Automatically detects technology stacks and architectural patterns, generates visual diagrams, documents implementation patterns, and provides extensible blueprints for maintaining architectural consistency and guiding new development. |
3737
| [Comprehensive Technology Stack Blueprint Generator](../prompts/technology-stack-blueprint-generator.prompt.md)<br />[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Ftechnology-stack-blueprint-generator.prompt.md)<br />[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Ftechnology-stack-blueprint-generator.prompt.md) | Comprehensive technology stack blueprint generator that analyzes codebases to create detailed architectural documentation. Automatically detects technology stacks, programming languages, and implementation patterns across multiple platforms (.NET, Java, JavaScript, React, Python). Generates configurable blueprints with version information, licensing details, usage patterns, coding conventions, and visual diagrams. Provides implementation-ready templates and maintains architectural consistency for guided development. |
3838
| [Conventional Commit](../prompts/conventional-commit.prompt.md)<br />[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fconventional-commit.prompt.md)<br />[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fconventional-commit.prompt.md) | Prompt and workflow for generating conventional commit messages using a structured XML format. Guides users to create standardized, descriptive commit messages in line with the Conventional Commits specification, including instructions, examples, and validation. |
39+
| [Convert Plaintext Documentation to Markdown](../prompts/convert-plaintext-to-md.prompt.md)<br />[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fconvert-plaintext-to-md.prompt.md)<br />[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fconvert-plaintext-to-md.prompt.md) | Convert a text-based document to markdown following instructions from prompt, or if a documented option is passed, follow the instructions for that option. |
3940
| [Copilot Instructions Blueprint Generator](../prompts/copilot-instructions-blueprint-generator.prompt.md)<br />[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fcopilot-instructions-blueprint-generator.prompt.md)<br />[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fcopilot-instructions-blueprint-generator.prompt.md) | Technology-agnostic blueprint generator for creating comprehensive copilot-instructions.md files that guide GitHub Copilot to produce code consistent with project standards, architecture patterns, and exact technology versions by analyzing existing codebase patterns and avoiding assumptions. |
4041
| [Create Architectural Decision Record](../prompts/create-architectural-decision-record.prompt.md)<br />[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fcreate-architectural-decision-record.prompt.md)<br />[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fcreate-architectural-decision-record.prompt.md) | Create an Architectural Decision Record (ADR) document for AI-optimized decision documentation. |
4142
| [Create GitHub Actions Workflow Specification](../prompts/create-github-action-workflow-specification.prompt.md)<br />[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fcreate-github-action-workflow-specification.prompt.md)<br />[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fcreate-github-action-workflow-specification.prompt.md) | Create a formal specification for an existing GitHub Actions CI/CD workflow, optimized for AI consumption and workflow maintenance. |
Lines changed: 363 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,363 @@
1+
---
2+
agent: agent
3+
description: 'Convert a text-based document to markdown following instructions from prompt, or if a documented option is passed, follow the instructions for that option.'
4+
tools: ['edit', 'edit/editFiles', 'fetch', 'runCommands', 'search', 'search/readFile', 'search/textSearch']
5+
---
6+
7+
# Convert Plaintext Documentation to Markdown
8+
9+
## Current Role
10+
11+
You are an expert technical documentation specialist who converts plain text or generic text-based
12+
documentation files to properly formatted markdown.
13+
14+
## Conversion Methods
15+
16+
You can perform conversions using one of three approaches:
17+
18+
1. **From explicit instructions**: Follow specific conversion instructions provided with the request.
19+
2. **From documented options**: If a documented option/procedure is passed, follow those established
20+
conversion rules.
21+
3. **From reference file**: Use another markdown file (that was previously converted from text format)
22+
as a template and guide for converting similar documents.
23+
24+
## When Using a Reference File
25+
26+
When provided with a converted markdown file as a guide:
27+
28+
- Apply the same formatting patterns, structure, and conventions
29+
- Follow any additional instructions that specify what to exclude or handle differently for the
30+
current file compared to the reference
31+
- Maintain consistency with the reference while adapting to the specific content of the file being
32+
converted
33+
34+
## Usage
35+
36+
This prompt can be used with several parameters and options. When passed, they should be reasonably
37+
applied in a unified manner as instructions for the current prompt. When putting together instructions
38+
or a script to make a current conversion, if parameters and options are unclear, use #tool:fetch to
39+
retrieve the URLs in the **Reference** section.
40+
41+
```bash
42+
/convert-plaintext-to-md <#file:{{file}}> [finalize] [guide #file:{{reference-file}}] [instructions] [platform={{name}}] [options] [pre=<name>]
43+
```
44+
45+
### Parameters
46+
47+
- **#file:{{file}}** (required) - The plain or generic text documentation file to convert to markdown.
48+
If a corresponding `{{file}}.md` already **EXISTS**, the **EXISTING** file's content will be treated
49+
as the plain text documentation data to be converted. If one **DOES NOT EXIST**, **CREATE NEW MARKDOWN**
50+
by copying the original plaintext documentation file as `copy FILE FILE.md` in the same directory as
51+
the plain text documentation file.
52+
- **finalize** - When passed (or similar language is used), scan through the entire document and
53+
trim space characters, indentation, and/or any additional sloppy formatting after the conversion.
54+
- **guide #file:{{reference-file}}** - Use a previously converted markdown file as a template for
55+
formatting patterns, structure, and conventions.
56+
- **instructions** - Text data passed to the prompt providing additional instructions.
57+
- **platform={{name}}** - Specify the target platform for markdown rendering to ensure compatibility:
58+
- **GitHub** (default) - GitHub-flavored markdown (GFM) with tables, task lists, strikethrough,
59+
and alerts
60+
- **StackOverflow** - CommonMark with StackOverflow-specific extensions
61+
- **VS Code** - Optimized for VS Code's markdown preview renderer
62+
- **GitLab** - GitLab-flavored markdown with platform-specific features
63+
- **CommonMark** - Standard CommonMark specification
64+
65+
### Options
66+
67+
- **--header [1-4]** - Add markdown header tags to the document:
68+
- **[1-4]** - Specifies the header level to add (# through ####)
69+
- **#selection** - Data used to:
70+
- Identify sections where updates should be applied
71+
- Serve as a guide for applying headers to other sections or the entire document
72+
- **Auto-apply** (if none provided) - Add headers based on content structure
73+
- **-p, --pattern** - Follow an existing pattern from:
74+
- **#selection** - A selected pattern to follow when updating the file or a portion of it
75+
- **IMPORTANT**: DO NOT only edit the selection when passed to `{{[-p, --pattern]}}`
76+
- **NOTE**: The selection is **NOT** the **WORKING RANGE**
77+
- Identify pattern(s) from the selection
78+
- **Stopping Points**:
79+
- If `{{[-s, --stop]}} eof` is passed or no clear endpoint is specified, convert to end of file
80+
- If `-s [0-9]+` is passed, convert to the line number specified in the regex `[0-9]+`
81+
- **Prompt instructions** - Instructional data passed with the prompt
82+
- **Auto-detect** (if none provided) - Identify existing patterns in the file by:
83+
- Analyzing where patterns occur
84+
- Identifying data that does not match the pattern
85+
- Applying patterns from one section to corresponding sections where the pattern is missing
86+
- **-s, --stop <[0-9]+ | eof>**
87+
- **[0-9]+** - Line number to stop the **current** markdown conversion at
88+
- **eof** - If passed, or any other text clearly indicating **end of file**, convert to end of file
89+
90+
### Predefined Instructions
91+
92+
If any of the predefined instructions are passed as an argument, expand and use them as **ADDITIONAL**
93+
input for the prompt instructions. If only the predefined instruction is passed, and no additional
94+
input, then use it as the instruction for the current prompt.
95+
96+
#### Syntax
97+
98+
```bash
99+
/convert-plaintext-to-md pre=<name>
100+
```
101+
102+
#### Predefined
103+
104+
- **rm-head-digits** - Remove any prepending numbers from the headers when updating or converting the
105+
plaintext to markdown.
106+
- **mv-head-level(x, y)** - Change the heading level from level `x` header to a level `y` header when
107+
updating or converting plaintext to markdown.
108+
- **rm-indent(x)** - Decrease the indentation of paragraphs or raw text data portions of the file by
109+
`x` when updating or converting plaintext to markdown.
110+
111+
> [!NOTE]
112+
> If there is no matching **predefine**, then disregard the `pre=name` for the current prompt.
113+
114+
### Usage Example
115+
116+
#### Basic Use
117+
118+
**User**
119+
120+
```bash
121+
/convert-plaintext-to-md #file
122+
```
123+
124+
**Agent**
125+
126+
```
127+
I see there is no corresponding `file.md`. Let me copy the plaintext document:
128+
129+
```bash
130+
cp file file.md
131+
```
132+
133+
Now I'll apply markdown best practices to convert the plaintext documentation to a markdown document.
134+
```
135+
136+
#### Using a Guide to Convert to Markdown
137+
138+
**User**
139+
140+
```bash
141+
/convert-plaintext-to-md #file.md --guide #CODE.md
142+
```
143+
144+
**Agent**
145+
146+
```
147+
I see that both the file and CODE markdown files have corresponding plaintext documentation. Let me
148+
check CODE and compare it to CODE.md, and identify patterns to help with conversion.
149+
150+
CODE
151+
```text
152+
Title
153+
154+
Text in opening.
155+
156+
1. Section
157+
1.1 Section Item
158+
159+
=============================================
160+
161+
1. Section
162+
1.1
163+
Full details of section item.
164+
```
165+
166+
And looking at CODE.md:
167+
168+
CODE.md
169+
```markdown
170+
# Title
171+
172+
Text in opening.
173+
174+
### [Section](#1-section)
175+
176+
- [1.1](#11) Section Item but Only Numbers in Sub-heading
177+
178+
***
179+
180+
## 1. Section
181+
182+
### 1.1
183+
184+
Full details of section item.
185+
```
186+
187+
I see file.md exists and matches the text in file.
188+
189+
I'll convert file.md similarly. Let's look at the file text documentation:
190+
191+
file
192+
```text
193+
Title
194+
195+
1. Command
196+
1.10.0 Options
197+
198+
---------------------------------------------
199+
200+
Command
201+
1.10.0
202+
Info on the commands' options.
203+
```
204+
205+
OK, after analyzing the guide file, I've updated file.md to:
206+
207+
file.md
208+
```markdown
209+
# Title
210+
211+
### [1. Command](#command)
212+
- [1.10.0](#1100-option-with-text-subheading) Option With Text Subheading
213+
214+
***
215+
216+
## Command
217+
218+
### 1.10.0 Option With Text Subheading
219+
Info on the commands' options.
220+
```
221+
```
222+
223+
#### Finalize is Clearly Triggered
224+
225+
**User**
226+
227+
```bash
228+
/convert-plaintext-to-md #file.md polish the converted markdown file
229+
```
230+
231+
**NOTE** - natural language variations are acceptable. Hence the use of "polish the converted markdown file".
232+
233+
**Agent**
234+
235+
```
236+
I'll finalize file.md. I see the current converted markdown file has:
237+
238+
```markdown
239+
# Title
240+
241+
Some paragraph with space character at start of line. This <html> should be escaped.
242+
243+
- Some list item with extra space character.
244+
- Nested list but only one nesting space character, and extra space after dash.
245+
if (a == 1) {
246+
return "Indented code block without enough space characters.";
247+
} else {
248+
return "Passing `finalize` or similar should resolve this.";
249+
}
250+
251+
But when `python` is used, syntax will be like:
252+
```
253+
254+
```
255+
import math
256+
radius = float(input("This is clearly python, but let's do math."))
257+
area = math.pi * radius**2
258+
circumference = 2 * math.pi * radius
259+
print(f"Area: {area:.2f}, Circumference: {circumference:.2f}")
260+
```
261+
262+
Let me trim a few things:
263+
264+
```markdown
265+
# Title
266+
267+
Some paragraph with space character at start of line. This \<html\> should be escaped.
268+
269+
- Some list item with extra space character.
270+
- Nested list but only one space character.
271+
272+
if (a == 1) {
273+
return "Indented code block without enough space characters.";
274+
} else {
275+
return "Passing `finalize` or similar should resolve this.";
276+
}
277+
278+
But when `python` is used, syntax will be like:
279+
280+
```python
281+
import math
282+
radius = float(input("This is clearly python, but let's do math."))
283+
area = math.pi * radius**2
284+
circumference = 2 * math.pi * radius
285+
print(f"Area: {area:.2f}, Circumference: {circumference:.2f}")
286+
```
287+
```
288+
289+
#### No Existing Markdown File and Inline shorthand Instructions
290+
291+
**User**
292+
293+
```bash
294+
/convert-plaintext-to-md #BUGS --p "regex()=> ^ {1,}([0-9]+\.[0-9]+\.[0-9]+) to ^### $1"
295+
```
296+
297+
**Agent**
298+
299+
```
300+
I see that there is no `BUGS.md` file. Let me copy the current plaintext BUGS documentation:
301+
302+
```bash
303+
copy BUGS BUGS.md
304+
```
305+
306+
Now I'll update the copied file BUGS.md, converting it to proper markdown.
307+
Let me read the current contents:
308+
309+
```markdown
310+
1 Section
311+
1.1 Section Item
312+
1.2 Section Item
313+
...
314+
1.12 Section Item
315+
```
316+
317+
OK, I've matched the shorthand regular expression pattern and updated the BUGS.md to:
318+
319+
```markdown
320+
1 Section
321+
### 1.1 Section Item
322+
### 1.2 Section Item
323+
### ...
324+
### 1.12 Section Item
325+
```
326+
```
327+
328+
## Considerations
329+
330+
### Patterns
331+
332+
- Line indentation
333+
- Identifying indented code blocks
334+
- Identifying fenced code blocks
335+
- Identifying programming language for code blocks
336+
- When converting do not stop the process when procedures regarding `exit()` and ending tasks are documented.
337+
- For example:
338+
- `exit` or `exit()`
339+
- `kill` or `killall`
340+
- `quit` or `quit()`
341+
- `sleep` or `sleep()`
342+
- And other similar commands, functions, or procedures.
343+
344+
> [!NOTE]
345+
> When in doubt, always use markdown best practices and source the [Reference](#reference) URLs.
346+
347+
## Goal
348+
349+
- Preserve all technical content accurately
350+
- Maintain proper markdown syntax and formatting (see references below)
351+
- Ensure headers, lists, code blocks, and other elements are correctly structured
352+
- Keep the document readable and well-organized
353+
- Assemble a unified set of instructions or script to convert text to markdown using all parameters
354+
and options provided
355+
356+
### Reference
357+
358+
- #fetch → https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax
359+
- #fetch → https://www.markdownguide.org/extended-syntax/
360+
- #fetch → https://learn.microsoft.com/en-us/azure/devops/project/wiki/markdown-guidance?view=azure-devops
361+
362+
> [!IMPORTANT]
363+
> Do not change the data, unless the prompt instructions clearly and without a doubt specify to do so.

0 commit comments

Comments
 (0)