Create a gist now

Instantly share code, notes, and snippets.

Double file extensions


The official file extension for reStructuredText files is .txt, but this is a stupid standard that should be ignored.

2.4 What's the standard filename extension for a reStructuredText file?
It's ".txt". Some people would like to use ".rest" or ".rst" or ".restx", but why bother? ReStructuredText source files are meant to be readable as plaintext, and most operating systems already associate ".txt" with text files. Using a specialized filename extension would require that users alter their OS settings, which is something that many users will not be willing or able to do.


This is openable by normal text editors, but also indicates that it's formatted using reStructuredText, so it can be rendered nicely by things like GitHub. It's better than both .txt and .rst alone.


*.md are recognized by GitHub and rendered nicely, but not generally understood by plain text editors. There are a million other proposed extensions for markdown files, which alone is a problem:

  • .markdown
  • .mdown
  • .mkdn
  • .md
  • .mkd
  • .mdwn
  • .mdtxt
  • .mdtext
  • .text

The official extension is .text, but this is stupid, because it's already used for other incompatible formats and doesn't in any way indicate "markdown" for the benefit of renderers or syntax highlighting.


This is better than .md, .txt, or .text alone. Still openable by normal text editors, but also indicates that it's formatted using Markdown, without any other metadata in the file itself, so it could be rendered nicely by things like GitHub (but currently isn't).

Additionally, embedded documents with file names ending in .md.txt will also be displayed using markdown without needing the @pagedown preamble.

Tip: Using markdown with .md.txt and .txt files instead of .wiki ones has the advantage that browsers not supporting Javascript will still render the embedded document page in a readable way (a preformatted version of the raw text). Also, the .txt extension has a meaning outside of Fossil.

Tip: Since .md.txt files don't need the @pagedown preamble, they are pure markdown documents which can be converted straight away into other formats using other markdown tools.

# Convert the specified HTML files into Markdown text-format equivalents
# in the current working directory. The file extension will be .md.txt.

Specifically, the shell script looks for files in my Dropbox PlainText folder with the extension “.md.txt”. This indicates it’s a text file in Markdown format.

So I'm not the only one who's thought of this at least.

Test test

Recognized by GitHub

Test test
Not recognized by GitHub

Test test

These are understood by GitHub.

Test test

Hey these are already recognized by GitHub!

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