Skip to content

Instantly share code, notes, and snippets.

@juancarlospaco
Last active April 6, 2018 19:31
Show Gist options
  • Save juancarlospaco/dc24fb7365016b5c235b to your computer and use it in GitHub Desktop.
Save juancarlospaco/dc24fb7365016b5c235b to your computer and use it in GitHub Desktop.
Universal markup for Markdown and reStructuredText. Template that works with GitHub Markdown AND ReStructuredText at the same time!

Markdown

  • Grey part at the Bottom means is ignored and not rendered on the output.
  • Both plain text templates are the same code, copypaste it and use it for whatever you want.
.. ..
 [Template](# "Template that works with GitHub Markdown AND ReStructuredText at the same time !.")

 - **Write your GitHub Markdown here**: This will be hidden on the ReStructuredText.
 - MarkDown content needs 1 white space indent on the whole content to work, mandatory.

.. ..

<!--- `Template <#foo>`_

- `Write your ReStructuredText here ! <#bar>`_: This will be hidden on the GitHub Markdown.

..  --->

ReStructuredText

  • Grey part at the Top means is ignored and not rendered on the output.
  • Both plain text templates are the same code, copypaste it and use it for whatever you want.
.. ..
 [Template](# "Template that works with GitHub Markdown AND ReStructuredText at the same time !.")

 - **Write your GitHub Markdown here**: This will be hidden on the ReStructuredText.
 - MarkDown content needs 1 white space indent on the whole content to work, mandatory.

.. ..

<!--- `Template <#foo>`_

- `Write your ReStructuredText here ! <#bar>`_: This will be hidden on the GitHub Markdown.

..  --->

Raw

.. ..
 [Template](# "Template that works with GitHub Markdown AND ReStructuredText at the same time !.")

 - **Write your GitHub Markdown here**: This will be hidden on the ReStructuredText.
 - MarkDown content needs 1 white space indent on the whole content to work, mandatory.

.. ..

<!--- `Template <#foo>`_

- `Write your ReStructuredText here ! <#bar>`_: This will be hidden on the GitHub Markdown.

..  --->

Rendered GitHub Markdown:

.. .. Template

  • Write your GitHub Markdown here: This will be hidden on the ReStructuredText.
  • MarkDown content needs 1 white space indent on the whole content to work, mandatory.

.. ..

@juancarlospaco
Copy link
Author

Based on this: https://gist.github.com/dupuy/1855764

I try everything to make it work and not look weird, is not possible, it gets too complex,
even if you try on the end you get a very weird syntax on both sides, instead this is the KISS way,
then I decided to try something like this PseudoCode:

if mardown:
   markdown_here.
else:
   restructured_text_here.

Then I implemented it with Conditional Comments.

  • No weird artifacts floating around, very clean and professional looking.
  • I suggest the *.rst.md file extension to know thats an universal file that will work for RST and MD.

Merge 2 files (1 .RST, 1 .MD) on 1 Universal file:

  • Paste the whole RST plain text content as-is on the RST part of this Template, at the Bottom.
  • Paste the whole MD plain text content as-is on the MD part of this Template, at the Top.
  • Indent whole MD plain text content by 1 white space. You are Ok to go ❕

🌟 this Gist if you like the idea 😸 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment