I would like to put the following code in an article that is written in AP Style:

puts 'Hello, world!'

How do I do this? If I were to put the code (C++, Ruby, whatever) in an article that was written in a newspaper, how would I write it? Is the entire thing surrounded by quotes, brackets, etc? How do you deal with line breaks?

I didn't find any help in this guide.

  • 2
    I think that's up to the publication editor. It's a formatting question, and is governed by house rules, not AP style. Nov 30 '16 at 17:58
  • Why don't you look in the AP Stylebook? I'm sure any university library will have a copy or online subscription.
    – user5645
    Dec 1 '16 at 21:33
  • 2
    @what I own this and have looked in it pretty thoroughly... Dec 2 '16 at 19:47
  • 1
    That's good, because then you know that they don't prescribe how you quote programming code, and that is the answer to your question.
    – user5645
    Dec 2 '16 at 20:33

I don't believe this is specifically covered by AP style. My personal approach would be to present the code in a block quote. (Or, if it's something really short, just a different font face.) But you're not going to find a "rule" that everybody follows for this situation. It's really up to the individual publisher.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.