prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Page preview doesn't consider format
  Page preview needs to take into account format when previewing
  
  </issue>
  <code>
  [start of CTFd/admin/pages.py]
  1 from flask import render_template, request
  2 
  3 from CTFd.admin import admin
  4 from CTFd.models import Pages
  5 from CTFd.schemas.pages import PageSchema
  6 from CTFd.utils import markdown
  7 from CTFd.utils.decorators import admins_only
  8 
  9 
  10 @admin.route("/admin/pages")
  11 @admins_only
  12 def pages_listing():
  13     pages = Pages.query.all()
  14     return render_template("admin/pages.html", pages=pages)
  15 
  16 
  17 @admin.route("/admin/pages/new")
  18 @admins_only
  19 def pages_new():
  20     return render_template("admin/editor.html")
  21 
  22 
  23 @admin.route("/admin/pages/preview", methods=["POST"])
  24 @admins_only
  25 def pages_preview():
  26     # We only care about content.
  27     # Loading other attributes improperly will cause Marshmallow to incorrectly return a dict
  28     data = {"content": request.form.get("content")}
  29     schema = PageSchema()
  30     page = schema.load(data)
  31     return render_template("page.html", content=page.data.html)
  32 
  33 
  34 @admin.route("/admin/pages/<int:page_id>")
  35 @admins_only
  36 def pages_detail(page_id):
  37     page = Pages.query.filter_by(id=page_id).first_or_404()
  38     page_op = request.args.get("operation")
  39 
  40     if request.method == "GET" and page_op == "preview":
  41         return render_template("page.html", content=markdown(page.content))
  42 
  43     if request.method == "GET" and page_op == "create":
  44         return render_template("admin/editor.html")
  45 
  46     return render_template("admin/editor.html", page=page)
  47
  [end of CTFd/admin/pages.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/CTFd/admin/pages.py b/CTFd/admin/pages.py
  --- a/CTFd/admin/pages.py
  +++ b/CTFd/admin/pages.py
  @@ -25,7 +25,10 @@
   def pages_preview():
       # We only care about content.
       # Loading other attributes improperly will cause Marshmallow to incorrectly return a dict
  -    data = {"content": request.form.get("content")}
  +    data = {
  +        "content": request.form.get("content"),
  +        "format": request.form.get("format"),
  +    }
       schema = PageSchema()
       page = schema.load(data)
       return render_template("page.html", content=page.data.html)
  
verification_info: {"golden_diff": "diff --git a/CTFd/admin/pages.py b/CTFd/admin/pages.py\n--- a/CTFd/admin/pages.py\n+++ b/CTFd/admin/pages.py\n@@ -25,7 +25,10 @@\n def pages_preview():\n     # We only care about content.\n     # Loading other attributes improperly will cause Marshmallow to incorrectly return a dict\n-    data = {\"content\": request.form.get(\"content\")}\n+    data = {\n+        \"content\": request.form.get(\"content\"),\n+        \"format\": request.form.get(\"format\"),\n+    }\n     schema = PageSchema()\n     page = schema.load(data)\n     return render_template(\"page.html\", content=page.data.html)\n", "issue": "Page preview doesn't consider format\nPage preview needs to take into account format when previewing\n", "before_files": [{"content": "from flask import render_template, request\n\nfrom CTFd.admin import admin\nfrom CTFd.models import Pages\nfrom CTFd.schemas.pages import PageSchema\nfrom CTFd.utils import markdown\nfrom CTFd.utils.decorators import admins_only\n\n\n@admin.route(\"/admin/pages\")\n@admins_only\ndef pages_listing():\n    pages = Pages.query.all()\n    return render_template(\"admin/pages.html\", pages=pages)\n\n\n@admin.route(\"/admin/pages/new\")\n@admins_only\ndef pages_new():\n    return render_template(\"admin/editor.html\")\n\n\n@admin.route(\"/admin/pages/preview\", methods=[\"POST\"])\n@admins_only\ndef pages_preview():\n    # We only care about content.\n    # Loading other attributes improperly will cause Marshmallow to incorrectly return a dict\n    data = {\"content\": request.form.get(\"content\")}\n    schema = PageSchema()\n    page = schema.load(data)\n    return render_template(\"page.html\", content=page.data.html)\n\n\n@admin.route(\"/admin/pages/<int:page_id>\")\n@admins_only\ndef pages_detail(page_id):\n    page = Pages.query.filter_by(id=page_id).first_or_404()\n    page_op = request.args.get(\"operation\")\n\n    if request.method == \"GET\" and page_op == \"preview\":\n        return render_template(\"page.html\", content=markdown(page.content))\n\n    if request.method == \"GET\" and page_op == \"create\":\n        return render_template(\"admin/editor.html\")\n\n    return render_template(\"admin/editor.html\", page=page)\n", "path": "CTFd/admin/pages.py"}]}