Excerpt template tag and reStructuredText

29 views
Skip to first unread message

Josh Rosen

unread,
Feb 10, 2009, 1:02:10 PM2/10/09
to Hyde
I've been playing around with using reStructuredText to write pages.
I like its easy integration with Pygments. However, the {%excerpt%}
tag doesn't work properly with reStructuredText. Both Textile and
Markdown support inline html, so the excerpt tag is able to insert its
html comment. But reStructuredText treats the html comment as part of
the article's text, so it displays on the page.

As it turns out, reStructuredText's 'raw' directive (http://
docutils.sourceforge.net/docs/ref/rst/directives.html#raw-data-pass-
through) allows the template tag's html comment to pass through
without being interpreted as the article's text, but it doesn't insert
the newline. Because marker_start and marker_end have newlines, they
fail to match and the excerpt is not found. Is there a reason why
marker_start and marker_end have newlines?

Lakshmi Vyasarajan

unread,
Feb 10, 2009, 1:17:31 PM2/10/09
to hyde...@googlegroups.com
Don't remember there being a reason. You can remove the new lines.

Lakshmi

unread,
Feb 17, 2009, 2:03:13 AM2/17/09
to Hyde
Were you able to get this to work?

On Feb 10, 11:17 am, Lakshmi Vyasarajan <lakshmi.v...@gmail.com>
wrote:
> Don't remember there being a reason. You can remove the new lines.
>

Josh Rosen

unread,
Feb 17, 2009, 12:19:45 PM2/17/09
to hyde...@googlegroups.com
Yes. reStructuredText ignores the newlines and puts the html comment
on the same line as the rest of the generated html, resulting in
marker_start and marker_end being unable to match the tag.

Removing the newlines from them fixes this, but it causes the output
of the {%excerpt%} tag to always appear without newlines, so the html
comment appears on the same line as the content, which makes the
generated html harder to read. One option would be to insert newlines
when outputting the html comment from the {%excerpt%} tag, but ignore
the newlines when searching for it in the generated html.

Lakshmi Vyasarajan

unread,
Feb 17, 2009, 2:07:41 PM2/17/09
to hyde...@googlegroups.com
Since we have cherrypy integrated we can use the Tidy functionality
built into it to clean up the generated code. Would that solve this
issue?
Reply all
Reply to author
Forward
0 new messages