Include code snippets in questions and answers | Community
Skip to main content
Answered

Include code snippets in questions and answers


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
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 14904 replies
  • August 12, 2021

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
  • 384 replies
  • Answer
  • August 12, 2021

To produce beautiful code images I usually Carbon.sh


  • Author
  • Explorer
  • 1 reply
  • August 16, 2021

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
  • 1 reply
  • February 18, 2022

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
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 14904 replies
  • February 24, 2022

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


Reply