Markdown to MediaWiki Conversion Guide: Difference between revisions
→Prompt for Fixing Pages to MediaWiki Format: fixed external url formatting Tag: 2017 source edit |
added context category and regex sections. Improved the gpt prompt template by providing examples Tag: 2017 source edit |
||
Line 1: | Line 1: | ||
== | == Convert Markdown to MediaWiki == | ||
Mediawiki syntax is a bit different from markdown syntax and GPT tends to prefer markdown syntax and defaults to it even when you ask it to convert to mediawiki. | |||
This template is a guide to convert markdown to mediawiki syntax using gpt along with regex instructions to do the find and replace what is often missed by gpt. | |||
=== REGEX Instructions === | |||
==== VS Code ==== | |||
```Bold``` | |||
Search: | |||
<pre> | |||
\*\*(.*?)\*\* | |||
</pre> | |||
Replace: | |||
<pre> | <pre> | ||
'''$1''' | |||
</pre> | |||
```Heading``` | |||
media wiki doesn't do more than one h1 in a single page for wiki pages | |||
Search: | |||
<pre> | |||
=(.*?)= | |||
* Replace | </pre> | ||
* | Replace: | ||
<pre> | |||
==$1== | |||
</pre> | |||
```Bullet``` | |||
media wiki doesn't do intendted bullet instead it is ** | |||
Search: | |||
<pre> | |||
^ \* | |||
</pre> | |||
Replace: | |||
<pre> | |||
** | |||
</pre> | |||
```Numbering``` | |||
* Convert Markdown image syntax `![Alt Text](http://example.com/image.jpg)` | media wiki doesn't do 1. numbered list with digits | ||
Search: | |||
<pre> | |||
^\d(.?) | |||
</pre> | |||
Replace: | |||
<pre> | |||
# | |||
</pre> | |||
==== SED ==== | |||
You can do this on a mac or linux machine with sed using the clipboard as input and pipe it through sed and awk commands to get the output using the find and replace commands. | |||
echo pbpaste | sed -E 's/\*\*(.*?)\*\*/'''$1'''/g' | sed -E 's/=(.*?)=/==$1==/g' | sed -E 's/^ \*/**/g' | sed -E 's/^\d(.?)/#/g' | |||
==== Python ==== | |||
=== GPT Instructions === | |||
``` | |||
Please convert the following page into MediaWiki format, adhering to the following guidelines: | |||
1. **General Formatting**: | |||
* Remove any "---" separators, as they can interfere with formatting. | |||
* Convert any code blocks to use `<pre>` tags for MediaWiki formatting. | |||
* Replace Markdown bold (`**text**`) with MediaWiki bold (`'''text'''`). | |||
2. **Links**: | |||
* Convert Markdown external links `[Link Text](http://example.com)` to MediaWiki external links: `[http://example.com Link Text]` (add a space between the URL and the title). | |||
* Convert Markdown internal links `[Link Text](/path/page_title.md)` to MediaWiki internal links: `[[page_title|Link Text]]`. | |||
* Convert File Links from markddown `![Alt Text](http://example.com/image.jpg)` to MediaWiki syntax: `[[File:image.jpg|alt=Alt Text]]`. | |||
* Remove .md from the end of any internallink. | |||
3. **Images**: | |||
* Replace Markdown image syntax `![Alt Text](http://example.com/image.jpg)` with MediaWiki syntax: `[[File:image.jpg|alt=Alt Text]]`. | |||
4. **Lists**: | |||
* Convert unordered lists: | |||
- Replace Markdown `- item` or `* item` with MediaWiki list syntax: | |||
** `* item` | |||
** `** subitem` | |||
** `*** sub-sub-item` | |||
* Convert ordered lists: | |||
- Replace Markdown `1. item` or `2. item` with MediaWiki list syntax: | |||
** `# item` | |||
** `## subitem` | |||
** `### sub-sub-item` | |||
5. **Tables**: | |||
* Replace Markdown table syntax with MediaWiki table syntax: | |||
- Example Markdown: | |||
``` | |||
| Header 1 | Header 2 | | |||
|----------|----------| | |||
| Row 1 | Data 1 | | |||
``` | |||
- Example MediaWiki: | |||
``` | |||
{| class="wikitable" | |||
! Header 1 | |||
! Header 2 | |||
|- | |||
| Row 1 | |||
| Data 1 | |||
|} | |||
``` | |||
6. **References**: | |||
* | * Add references for any links used on the page. Include them as basic MediaWiki references and ensure a `<references />` tag is added at the bottom of the page. | ||
** | |||
* | |||
7. **Special Characters**: | |||
* | * Escape any special characters that may conflict with MediaWiki formatting by using `<nowiki>` tags where necessary. | ||
8. **Categories**: | |||
* | * Add appropriate categories to the page using MediaWiki category syntax: `[[Category:Category Name]]`. | ||
9. **Preservation of Content**: | |||
* | * Ensure all original content is preserved in meaning and context. | ||
* Maintain the integrity of the original text during conversion. | |||
10. **Headers**: | |||
* Convert Markdown headers (`# Header`, `## Subheader`) to MediaWiki headers: | |||
**`== Header ==` | |||
**`=== Subheader ===` | |||
Apply these instructions to the provided content, ensuring that the final output complies with MediaWiki standards and preserves readability and accuracy. | |||
``` | |||
[[Category: AI Template]] | [[Category:Template]] | ||
[[Category:AI Template]] |
Revision as of 01:49, 15 December 2024
Convert Markdown to MediaWiki
Mediawiki syntax is a bit different from markdown syntax and GPT tends to prefer markdown syntax and defaults to it even when you ask it to convert to mediawiki.
This template is a guide to convert markdown to mediawiki syntax using gpt along with regex instructions to do the find and replace what is often missed by gpt.
REGEX Instructions
VS Code
```Bold``` Search:
\*\*(.*?)\*\*
Replace:
'''$1'''
```Heading``` media wiki doesn't do more than one h1 in a single page for wiki pages Search:
=(.*?)=
Replace:
==$1==
```Bullet``` media wiki doesn't do intendted bullet instead it is ** Search:
^ \*
Replace:
**
```Numbering``` media wiki doesn't do 1. numbered list with digits Search:
^\d(.?)
Replace:
#
SED
You can do this on a mac or linux machine with sed using the clipboard as input and pipe it through sed and awk commands to get the output using the find and replace commands. echo pbpaste | sed -E 's/\*\*(.*?)\*\*/$1/g' | sed -E 's/=(.*?)=/==$1==/g' | sed -E 's/^ \*/**/g' | sed -E 's/^\d(.?)/#/g'
Python
GPT Instructions
``` Please convert the following page into MediaWiki format, adhering to the following guidelines:
1. **General Formatting**:
- Remove any "---" separators, as they can interfere with formatting.
- Convert any code blocks to use `
` tags for MediaWiki formatting.
* Replace Markdown bold (`**text**`) with MediaWiki bold (`text`). 2. **Links**: * Convert Markdown external links `[Link Text](http://example.com)` to MediaWiki external links: `Link Text` (add a space between the URL and the title). * Convert Markdown internal links `[Link Text](/path/page_title.md)` to MediaWiki internal links: `Link Text`. * Convert File Links from markddown `![Alt Text](http://example.com/image.jpg)` to MediaWiki syntax: ``. * Remove .md from the end of any internallink. 3. **Images**: * Replace Markdown image syntax `![Alt Text](http://example.com/image.jpg)` with MediaWiki syntax: ``. 4. **Lists**: * Convert unordered lists: - Replace Markdown `- item` or `* item` with MediaWiki list syntax: ** `* item` ** `** subitem` ** `*** sub-sub-item` * Convert ordered lists: - Replace Markdown `1. item` or `2. item` with MediaWiki list syntax: ** `# item` ** `## subitem` ** `### sub-sub-item` 5. **Tables**: * Replace Markdown table syntax with MediaWiki table syntax: - Example Markdown: ``` | Header 1 | Header 2 | |----------|----------| | Row 1 | Data 1 | ``` - Example MediaWiki: ```
Header 1 | Header 2 |
---|---|
Row 1 | Data 1 |
``` 6. **References**: * Add references for any links used on the page. Include them as basic MediaWiki references and ensure a `` tag is added at the bottom of the page. 7. **Special Characters**: * Escape any special characters that may conflict with MediaWiki formatting by using `<nowiki>` tags where necessary. 8. **Categories**: * Add appropriate categories to the page using MediaWiki category syntax: ``. 9. **Preservation of Content**: * Ensure all original content is preserved in meaning and context. * Maintain the integrity of the original text during conversion. 10. **Headers**: * Convert Markdown headers (`# Header`, `## Subheader`) to MediaWiki headers: **`== Header ==` **`=== Subheader ===` Apply these instructions to the provided content, ensuring that the final output complies with MediaWiki standards and preserves readability and accuracy. ```