On Jan 26, 2011, at 4:11 PM, ian douglas wrote: > Thanks Tino, > > It's certainly not homework, I'm learning Python after being in the Perl/PHP > world for well over a decade. Trying to teach this old dog some new tricks. > > On Jan 26, 2011 6:47 AM, "Tino Dai" <obe...@gmail.com> wrote: > > On Wed, Jan 26, 2011 at 2:46 AM, ian douglas > > <ian.doug...@iandouglas.com>wrote: > > > >> Hey all, > >> > >> I followed a tutorial on creating a very simple wiki in Python, which > >> worked fine until the example where the instructor wanted to render the > >> output through markdown.markdown() > >> > >> Here's the view code: > >> > >> from agwiki.wiki.models import Page > >> from django.shortcuts import render_to_response > >> from django.http import HttpResponseRedirect > >> import markdown > >> > >> def view_page(request, page_name): > >> try: > >> page = Page.objects.get(pk=page_name) > >> except Page.DoesNotExist: > >> return render_to_response("create.html", {"page_name":page_name}) > >> content = page.content > >> return > >> render_to_response("view.html",{"page_name":page_name,"content":markdown.markdown(content)}) > >> > >> The problem I'm having is that the output in a browser is outputing HTML > >> markers as < and > instead of < and > so the browser literally shows > >> "<p>hello world</p>". If I leave the line as it originally was: > >> > >> return > >> render_to_response("view.html",{"page_name":page_name,"content":content}) > >> > >> It just prints "hello world" as saved in the database. I'm just not sure > >> where to start looking for a solution here, and would appreciate any > >> pointers. > >> > >> > >> Two thing: > > - This sounds like homework. > > - This is a python mailing list, not a django mailing list > > > > Where I would start would be to investigate what the markdown class does. In > > addition I would read over the django documentation to see why django is > > doing that. It's in the django documentation, I hit that issue not too long > > ago. > > > > HTH, > > Tino > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor
Hi Ian. Well, I did that very same tutorial a few months ago and ran into the same issue. It's not an issue with markdown but a feature called auto-escaping. The tutorial is quite old (but nonetheless good), so back in that day auto-escaping wasn't the default in Django. Now it is. However, you might want consult the Django docs about auto-escaping http://docs.djangoproject.com/en/1.2/ref/templates/builtins/#autoescape ;) -- Benjamin _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor