0

I am using drupal serving as a blog system. Now I need to show sample code in the articles. How can I let the editor recognize the programming language and highlight the syntax?

1 Answer 1

1

Depending on the WYSIWYG editor you're using, you should have the option to add <pre> tags, which will preserve spacing so your code is formatted properly.

You can then style the <pre> tags in your CSS, or use something like this Google code prettifier, which will do syntax highlighting.

You may have to allow the <pre> tag in your tag whitelist in your Drupal admin, under Admin > Configuration > Text Formats (for Drupal 7) or Admin > Site Configuration > Input Formats (for Drupal 6).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.