Markdown to Asciidoc conversion process - pcesarperez/Modding-never-changes GitHub Wiki
This is the process followed to perform the conversion from the Markdown source to the new Asciidoc source.
|
Extensive use of regular expressions ahead. Keep on reading at your own risk. |
-
Replacement of the main title with a proper header.
-
Replacement of the table of contents with a simple
:toc: left
attribute in the header. The TOC will be in its own column, to the left. -
Addition of the
:toclevels: 4
attribute in the header to show up to level 4 headings in the TOC. -
Addition of the
:numbered:
attribute in the header to generate numbered headings. -
Addition of the
:sectlinks:
attribute in the header to generate clickable headings (useful for bookmarking). -
Addition of the
:imagesdir: ./Images
attribute in the header to set the relative path of the images to load. -
Addition of the
:experimental:
attribute in the header to be able to use certain user interface elements, like the inlinekbd
macro. -
Conversion of level 2 headings with the following regular expression (from now on, the first part enclosed by
//
is the pattern, and the second part enclosed by//
is the substitution):/^## <a id=".*?"><\/a>[0-9]\. (.*?)$/== \1/
-
Conversion of level 3 headings with the following regular expression:
/^### <a id=".*?"><\/a>[0-9]\.[0-9]+\. (.*?)$/=== \1/
-
Conversion of level 4 headings with the following regular expression:
/^#### <a id=".*?"><\/a>[0-9]\.[0-9]+\.[0-9]+\. (.*?)$/==== \1/
-
Conversion of bold text with the following regular expression:
/\*\*(.*?)\*\*/*\1*/
-
Conversion of URLs with the following regular expression:
/\[(.*?)\]\((http[s]?:\/\/.*?)\)/\2[\1]/
-
Manual conversion of internal cross references. For example:
/[foo](#bar)/"<<Bar section, foo>>"/
-
Conversion of numbered lists with the following regular expression:
/^[0-9]+\././
-
Deindentation of bulleted lists (first level) with the following regular expression:
/^[\t]+\*/*/
-
Deindentation of bulleted lists (second level) with the following regular expression:
/^\t\t- (.*?)$/** \1/
-
Removal of unnecessary escape characters in italicized text with the following regular expression:
/\\_/_/
-
Conversion of images with the following regular expression:
/^!\[(.*?)\]\(Images\/(.*?)\)$/.\1\nimage::\2[\1]/
-
Correction of images in numbered lists with the following regular expression:
/^(\. .*?)\n(\..*?)\n(image::.*?)$/\1\n+\n\2\n\3/
-
Correction of images in bulleted lists with the following regular expression:
/^(\* .*?)\n(\..*?)\n(image::.*?)$/\1\n+\n\2\n\3/
-
Conversion of
<kbd />
elements with the following regular expression:/<kbd>(.*?)<\/kbd>/kbd:[\1]/
-
Conversion of literal blocks with the following regular expression:
/```.*?\n(.*?)\n```/----\n\1\n----/
-
Conversion of subscripts with the following regular expression:
/<sup>(.*?)<\/sup>/^\1^/
-
Final manual corrections throughout the text.