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.
  1. Replacement of the main title with a proper header.

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

  3. Addition of the :toclevels: 4 attribute in the header to show up to level 4 headings in the TOC.

  4. Addition of the :numbered: attribute in the header to generate numbered headings.

  5. Addition of the :sectlinks: attribute in the header to generate clickable headings (useful for bookmarking).

  6. Addition of the :imagesdir: ./Images attribute in the header to set the relative path of the images to load.

  7. Addition of the :experimental: attribute in the header to be able to use certain user interface elements, like the inline kbd macro.

  8. 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/
  9. Conversion of level 3 headings with the following regular expression:

    /^### <a id=".*?"><\/a>[0-9]\.[0-9]+\. (.*?)$/=== \1/
  10. Conversion of level 4 headings with the following regular expression:

    /^#### <a id=".*?"><\/a>[0-9]\.[0-9]+\.[0-9]+\. (.*?)$/==== \1/
  11. Conversion of bold text with the following regular expression:

    /\*\*(.*?)\*\*/*\1*/
  12. Conversion of URLs with the following regular expression:

    /\[(.*?)\]\((http[s]?:\/\/.*?)\)/\2[\1]/
  13. Manual conversion of internal cross references. For example:

    /[foo](#bar)/"<<Bar section, foo>>"/
  14. Conversion of numbered lists with the following regular expression:

    /^[0-9]+\././
  15. Deindentation of bulleted lists (first level) with the following regular expression:

    /^[\t]+\*/*/
  16. Deindentation of bulleted lists (second level) with the following regular expression:

    /^\t\t- (.*?)$/** \1/
  17. Removal of unnecessary escape characters in italicized text with the following regular expression:

    /\\_/_/
  18. Conversion of images with the following regular expression:

    /^!\[(.*?)\]\(Images\/(.*?)\)$/.\1\nimage::\2[\1]/
  19. Correction of images in numbered lists with the following regular expression:

    /^(\. .*?)\n(\..*?)\n(image::.*?)$/\1\n+\n\2\n\3/
  20. Correction of images in bulleted lists with the following regular expression:

    /^(\* .*?)\n(\..*?)\n(image::.*?)$/\1\n+\n\2\n\3/
  21. Conversion of <kbd /> elements with the following regular expression:

    /<kbd>(.*?)<\/kbd>/kbd:[\1]/
  22. Conversion of literal blocks with the following regular expression:

    /```.*?\n(.*?)\n```/----\n\1\n----/
  23. Conversion of subscripts with the following regular expression:

    /<sup>(.*?)<\/sup>/^\1^/
  24. Final manual corrections throughout the text.

⚠️ **GitHub.com Fallback** ⚠️