Skip to main content
Answered

Include code snippets in questions and answers

  • Aug 12, 2021 7:44 PM UTC
  • 5 replies
  • 683 views

Hi there,

I’m trying to write quiz questions that include 1- or 2-word code snippets. Is it possible to include <code> or <pre> snippets in questions or answers? I get that we can’t include a bunch of custom HTML or CSS directly in the forms, but it would be really useful to be able to toggle a monospace font on or off!

I got my hopes up when I saw this behavior:

 

Thanks!

Best answer by picsoung

To produce beautiful code images I usually Carbon.sh

View original

5 replies

Liz
Ex–Typefomer
Forum|alt.badge.img+5
  • Tech Community Advocate
  • Aug 12, 2021 9:30 PM UTC

Hi @mattjoc Welcome to the community! It isn’t possible to add any code into the forms, but I have seen people use the picture choice question to add the code snippets in without them changing. Would that work for you? 


picsoung
Typeform
Forum|alt.badge.img+5
  • Developer Advocate @ Typeform
  • Answer
  • Aug 12, 2021 10:15 PM UTC

To produce beautiful code images I usually Carbon.sh


  • Author
  • Explorer
  • Aug 16, 2021 2:33 PM UTC

Thanks for your responses, Liz and picsoung!

While producing code images would be an acceptable workaround for some cases, we often need to build questions that include references to code in the middle of other text. I appreciate how allowing users to add HTML into questions and answers could open up a can of worms, but it would be amazing if you could add a code/monospaced/pre-formatted option alongside bold and italic!


  • Navigating the Land
  • Feb 18, 2022 7:57 PM UTC

For anyone who finds this - pay attention to the aspect ratio so that the code snippet font is large enough to be readable. If it’s a tall rectangle or a square, the image layout is possible to get right. Wide rectangles are basically no good, the image editor will clip the photo in ways that cut off the code.


Liz
Ex–Typefomer
Forum|alt.badge.img+5
  • Tech Community Advocate
  • Feb 24, 2022 6:30 PM UTC

Oh, thank you, @defaultuser ! That’s handy to know. :grinning: