Markdown to MediaWiki Conversion Guide: Difference between revisions

From Irregularpedia
Jump to navigation Jump to search
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:
== Prompt for Fixing Pages to MediaWiki Format ==
== 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>
Please convert the following page into MediaWiki format, following these instructions:
'''$1'''
remove any "---" as it can mess with the code
</pre>
Convert any codeblocks to use the mediawiki pre box
```Heading```
Add Categories to the page that make sense
media wiki doesn't do more than one h1 in a single page for wiki pages
Bold should not be ** it should be ''', remember this is media syntax
Search:
Any links referenced add them as basic mediawiki references and add a reference end to the bottom of the page if so
<pre>
Convert Markdown Links to MediaWiki Syntax:
=(.*?)=
* Replace External Markdown links with MediaWiki links. For example, change `[Link Text](http://example.com)` to `[http://example.com Link Text]`. space between the url and the title
</pre>
* Replace Internal Markdown links with MediaWiki links. For example, change `[Link Text](/path/page_title.md)` to `[page_title|Link Text]`.
Replace:
<pre>
==$1==
</pre>
```Bullet```
media wiki doesn't do intendted bullet instead it is **
Search:
<pre>
^ \*
</pre>
Replace:
<pre>
**
</pre>


Update Image and Media Links:
```Numbering```
* Convert Markdown image syntax `![Alt Text](http://example.com/image.jpg)` to MediaWiki syntax `[[File:image.jpg|alt=Alt Text]]`.
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
|}
```


Handle Lists:
6. **References**:
* Replace Markdown unordered list syntax `- item` or `* item` with MediaWiki list syntax:
* 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.
** subitem
*** sub-sub-item
** subitem
# Replace Markdown ordered list syntax `1. item` or `2. item` with MediaWiki list syntax:
## subitem
## subitem


Preserve Code Blocks:
7. **Special Characters**:
* Ensure code blocks are correctly formatted with <pre> tags. Maintain the content without any additional MediaWiki formatting:
* Escape any special characters that may conflict with MediaWiki formatting by using `<nowiki>` tags where necessary.
    content without wiki syntax formatting


Ensure Proper Formatting:
8. **Categories**:
* Ensure headers, tables, and other elements are converted to appropriate MediaWiki formatting.
* Add appropriate categories to the page using MediaWiki category syntax: `[[Category:Category Name]]`.


Preserve Existing Content:
9. **Preservation of Content**:
* Keep all content intact and ensure that the conversion maintains the original meaning and context.
* Ensure all original content is preserved in meaning and context.
* Maintain the integrity of the original text during conversion.


Please apply these changes to the provided content and ensure the final output aligns with MediaWiki standards.
10. **Headers**:
</pre>
* 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: `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: `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: ```

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. ```