preaction / Statocles

Static website CMS
http://preaction.me/statocles
Other
84 stars 33 forks source link

[highlight] Syntax highlighting fails with no content and no error #489

Closed preaction closed 8 years ago

preaction commented 8 years ago

For some reason, the following content, passed through the highlighter, yields an empty string.

% highlight html => begin
%% if ( $site->data->{twitter} ) {
    <script src="twitter.js"></script>
    <script>
        /* This JavaScript is completely made up */
        show_timeline(
            "<%%= $site->data->{twitter}{username} %>",
            <%%= $site->data->{twitter}{timeline_size} || 20 %>
        );
    </script>
%% }
% end

My guess is the unmatched, unescaped >. To mitigate this for HTML purposes, we could add some HTML escaping first, when the highlight routine is html.

We also need to detect errors in the highlighter. They should be printed as warnings when building the site. The content should be passed-through without highlighting so it doesn't seem missing.

preaction commented 8 years ago

On the other hand, this content gets highlighted effectively:

<ul class="tags">
% for my $tag ( $page->tags ) {
    <li>
        <a href="<%= $tag->href %>">
            <%= $tag->text %>
        </a>
    </li>
% }
</ul>

Perhaps something to do with opening a tag first?

preaction commented 8 years ago

Oh ffs. It's because I didn't %= at the front...