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