Show Pretty Code in Django

I am looking for something that I can use in django to display pre-formatted code. Ideally, this would include syntax highlighting for various programming languages, although just starting with something that rendered html and xml well would be a good starting point.

Is there something similar?

Basically I am looking for something like a dpaste widget (as well as a stack overflow) to display code.

eg. http://dpaste.com/hold/102141/

or

<?xml version="1.0" encoding='UTF-8'?>
<painting>
  <img src="madonna.jpg" alt='Foligno Madonna, by Raphael'/>
  <caption>This is Raphael "Foligno" Madonna, painted in
  <date>1511</date>-<date>1512</date>.</caption>
</painting>

I know this question , but my business is not in the mechanism of code escaping, but about the user interface.

+3
source share
2 answers

Pygments, HTML.

:

from pygments import highlight
from pygments.lexers import PythonLexer
from pygments.formatters import HtmlFormatter

highlighted = highlight('# Some Python code', PythonLexer(), HtmlFormatter())

. .

+8

SyntaxHighlighter (http://alexgorbatchev.com), Django .

+2

Source: https://habr.com/ru/post/1719187/


All Articles