← Master Index
Vol. 13 Module 13.1 Lecture

Markdown Formatting

Prompting Techniques

How This Lesson Fits the Module & Volume

Not every answer must be JSON or XML. Markdown formatting is the human-facing twin of structured output: headings, lists, tables, and fenced code that render cleanly in chat UIs, docs, and tickets. It complements JSON (for machines) and XML (for tagged sections).

In Module 13.2 you will refine presentation further via tone and output-format craft; here the focus is reliable Markdown as a prompt and response contract.

Learning Objectives

By the end of this lesson, students should be able to:

  • Specify Markdown structure (H2s, bullets, tables, code fences) in prompts.
  • Choose Markdown vs. JSON based on human vs. machine consumers.
  • Prevent fence leakage and broken tables in model output.
  • Use Markdown inside system prompts as a style guide.
  • Combine Markdown answers with machine-readable footers when needed.
  • Evaluate format compliance (heading presence, list length).
Definition

Markdown formatting (in prompting) means instructing the model to organize its reply using Markdown syntax—headings, emphasis, lists, links, tables, and fenced code blocks—so the result is scannable for humans and consistently renderable in Markdown-aware clients.

What to Specify

Structure

  • Exact heading titles
  • Bullet vs. numbered
  • Section order

Constraints

  • Max bullets / words
  • No extra sections
  • Language / tone

Code

  • Fence language tags
  • Complete snippets
  • No stray fences
ConsumerPreferWhy
Chat / docs UIMarkdownReadable, renderable
Backend serviceJSON / toolsTyped parse
Mixed productBothMD body + JSON appendix

Practical Format Spec

FORMAT = """ Respond in Markdown with EXACTLY these sections in order: ## Summary One sentence. ## Key Points - Exactly 3 bullets, each <= 20 words. ## Risks A Markdown table with columns: Risk | Likelihood | Mitigation Include 2–3 rows. ## Next Step One imperative sentence. Do not add other headings. Do not wrap the whole reply in a code fence. """ messages = [ {"role": "system", "content": "You are a concise technical writer.\n" + FORMAT}, {"role": "user", "content": f"Topic: {topic}\nNotes:\n{notes}"}, ] # Lightweight compliance checks (evaluation hook): assert "## Summary" in reply and "## Key Points" in reply assert reply.count("\n- ") + reply.count("\n* ") >= 3
Specify

Headings & limits.

Generate

Markdown reply.

Render

UI or docs.

Check

Section presence.

Strengths

  • Excellent human UX
  • Native to chat products
  • Easy partial compliance checks

Tradeoffs

  • Weaker than schemas for data
  • Tables can break under stress
  • Fence confusion with code tasks
Common Misconception

“Ask for Markdown and the model will always produce a perfect GFM table.” Complex tables are a frequent failure mode. Prefer short tables, or use JSON for tabular data and render Markdown yourself in the app.

Knowledge Check

  1. Short Answer: What is Markdown formatting in prompting? Answer: Instructing replies to use Markdown structure for scannable, renderable text.
  2. True/False: Markdown is usually best for typed database writes. Answer: False—prefer JSON/tools.
  3. Multiple Choice: Specifying exact heading titles helps: (a) compliance checks, (b) CUDA occupancy, (c) batch norm. Answer: (a).
  4. Short Answer: Name one Markdown failure mode. Answer: Broken tables or whole-reply code fences (among others).
  5. True/False: You can mix a Markdown body with a JSON appendix. Answer: True.
  6. Multiple Choice: Prefer Markdown when the consumer is: (a) a human reader/UI, (b) a strict schema validator only, (c) a kernel driver. Answer: (a).
  7. Short Answer: Why limit bullet count? Answer: Keeps answers concise and evaluable.
  8. Short Answer: Where can FORMAT rules live durably? Answer: In the system prompt (or a shared template).
  9. Multiple Choice: Rendering JSON as Markdown in the app is useful when: (a) tables are unreliable from the model, (b) JSON is illegal, (c) GPUs overheat. Answer: (a).
  10. True/False: Format checks belong in prompt evaluation. Answer: True.

Key Takeaways

  • Markdown is the human contract; JSON is the machine contract.
  • Specify sections, lengths, and fence rules explicitly.
  • Validate structure; render hard tables in code when needed.
  • Next: System Prompt—where durable format rules often live.
Trainer’s Guide

Hands-on: A/B a vague “use Markdown” vs. the exact section template above; score heading compliance.

Discussion: Should product UIs hide raw Markdown or show a rich preview?

Recap: Markdown formatting makes answers scannable when you specify the skeleton. Continue with System Prompt.