diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb
index 3295fb7e4..6bc22d2c7 100644
--- a/app/controllers/posts_controller.rb
+++ b/app/controllers/posts_controller.rb
@@ -16,7 +16,12 @@ class PostsController < ApplicationController
   end
 
   def markdown_num
-    markdown Post.find_by(topic_id: params[:topic_id].to_i, post_number: (params[:post_number] || 1).to_i)
+    if params[:revision].present?
+      post_revision = find_post_revision_from_topic_id
+      render text: post_revision.modifications[:raw].last, content_type: 'text/plain'
+    else
+      markdown Post.find_by(topic_id: params[:topic_id].to_i, post_number: (params[:post_number] || 1).to_i)
+    end
   end
 
   def markdown(post)
@@ -403,6 +408,22 @@ class PostsController < ApplicationController
     post_revision
   end
 
+  def find_post_revision_from_topic_id
+    post = Post.find_by(topic_id: params[:topic_id].to_i, post_number: (params[:post_number] || 1).to_i)
+    raise Discourse::NotFound unless guardian.can_see?(post)
+
+    revision = params[:revision].to_i
+    raise Discourse::NotFound if revision < 2
+
+    post_revision = PostRevision.find_by(post_id: post.id, number: revision)
+    raise Discourse::NotFound unless post_revision
+
+    post_revision.post = post
+    guardian.ensure_can_see!(post_revision)
+
+    post_revision
+  end
+
   private
 
   def user_posts(guardian, user_id, opts)