Markdown to MediaWiki Conversion Guide: Difference between revisions

From Irregularpedia
Jump to navigation Jump to search
added context category and regex sections. Improved the gpt prompt template by providing examples
Tag: 2017 source edit
updated table and code
Tag: 2017 source edit
Line 6: Line 6:
=== REGEX Instructions ===
=== REGEX Instructions ===
==== VS Code ====
==== VS Code ====
```Bold```
{| class="wikitable"
Search:
! Title !! Find !! Replace !! Description
<pre>
|-
\*\*(.*?)\*\*
| Bold || \*\*(.*?)\*\* || '''$1''' || Converts markdown bold to MediaWiki bold
</pre>
|-
Replace:
| Heading || =(.*?)= || ==$1== || Adjusts heading level since MediaWiki doesn't support multiple h1 headers
<pre>
|-
'''$1'''
| Bullet || ^ \* || ** || Converts indented bullets to MediaWiki double asterisk
</pre>
|-
```Heading```
| Numbering || ^\d(.?) || # || Converts numbered lists with digits to MediaWiki numbered list format
media wiki doesn't do more than one h1 in a single page for wiki pages
|-
Search:
| Italics || \_(.*?)\_ || ''$1'' || Converts markdown italics to MediaWiki italics
<pre>
|-
=(.*?)=
| External Links || \[(.*?)\]\((https?:\/\/.*?)\) || [$2 $1] || Converts markdown external links to MediaWiki format
</pre>
|-
Replace:
| Internal Links || \[(.*?)\]\((.*?)\.md\) || [[$2|$1]] || Converts markdown internal links to MediaWiki format
<pre>
|-
==$1==
| Images || !\[(.*?)\]\((.*?)\) || [[File:$2|alt=$1]] || Converts markdown images to MediaWiki format
</pre>
|-
```Bullet```
| Code Blocks || ```(.*?)``` || <pre>$1</pre> || Converts markdown code blocks to MediaWiki pre tags
media wiki doesn't do intendted bullet instead it is **
|-
Search:
| Inline Code || `(.*?)` || <code>$1</code> || Converts markdown inline code to MediaWiki code tags
<pre>
|-
^ \*
| Horizontal Rule || ^---$ || ---- || Converts markdown horizontal rule to MediaWiki format
</pre>
|}
Replace:
<pre>
**
</pre>
 
```Numbering```
media wiki doesn't do 1. numbered list with digits
Search:
<pre>
^\d(.?)
</pre>
Replace:
<pre>
#
</pre>
==== SED ====
==== 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.
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.
Line 52: Line 37:


=== GPT Instructions ===
=== GPT Instructions ===
```
<pre>
Please convert the following page into MediaWiki format, adhering to the following guidelines:
Please convert the following page into MediaWiki format, adhering to the following guidelines:


Line 119: Line 104:


Apply these instructions to the provided content, ensuring that the final output complies with MediaWiki standards and preserves readability and accuracy.
Apply these instructions to the provided content, ensuring that the final output complies with MediaWiki standards and preserves readability and accuracy.
```
</pre>
 
[[Category:Template]]
[[Category:AI Template]]

Revision as of 01:54, 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

Title Find Replace Description
Bold \*\*(.*?)\*\* $1 Converts markdown bold to MediaWiki bold
Heading =(.*?)= ==$1== Adjusts heading level since MediaWiki doesn't support multiple h1 headers
Bullet ^ \* ** Converts indented bullets to MediaWiki double asterisk
Numbering ^\d(.?) # Converts numbered lists with digits to MediaWiki numbered list format
Italics \_(.*?)\_ $1 Converts markdown italics to MediaWiki italics
External Links \[(.*?)\]\((https?:\/\/.*?)\) [$2 $1] Converts markdown external links to MediaWiki format
Internal Links \[(.*?)\]\((.*?)\.md\) $1 Converts markdown internal links to MediaWiki format
Images !\[(.*?)\]\((.*?)\) $1 Converts markdown images to MediaWiki format
Code Blocks ```(.*?)```
$1
Converts markdown code blocks to MediaWiki pre tags
Inline Code `(.*?)` $1 Converts markdown inline code to MediaWiki code tags
Horizontal Rule ^---$ ---- Converts markdown horizontal rule to MediaWiki format

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.