Giter Club home page Giter Club logo

Comments (3)

bencentra avatar bencentra commented on August 21, 2024

It looks like {% raw %} is working exactly as expected; any liquid syntax within the raw tags isn't getting compiled. See https://github.com/Shopify/liquid/wiki/Liquid-for-Designers#raw

The problem is the HTML syntax isn't escaped and is rendering on the page. Here's what I use in my own Jekyll site to get HTML syntax highlighting working:

{% highlight html %}
<p class="add">Add new: 
  <input type="text" ng-model="newItem" ng-enter="addItem()" placeholder="New item">
</p>
{% endhighlight %}

This creates the escaped HTML (note all the &lt;'s and &gt;'s):

<div class="highlight">
   <pre><code class="language-html hljs xml" data-lang="html"><span class="nt"><span class="hljs-tag">&lt;<span class="hljs-title">p</span></span></span><span class="hljs-tag"> </span><span class="na"><span class="hljs-tag"><span class="hljs-attribute">class</span>=</span></span><span class="s"><span class="hljs-tag"><span class="hljs-value">"add"</span></span></span><span class="nt"><span class="hljs-tag">&gt;</span></span>Add new: 
  <span class="nt"><span class="hljs-tag">&lt;<span class="hljs-title">input</span></span></span><span class="hljs-tag"> </span><span class="na"><span class="hljs-tag"><span class="hljs-attribute">type</span>=</span></span><span class="s"><span class="hljs-tag"><span class="hljs-value">"text"</span></span></span><span class="hljs-tag"> </span><span class="na"><span class="hljs-tag"><span class="hljs-attribute">ng-model</span>=</span></span><span class="s"><span class="hljs-tag"><span class="hljs-value">"newItem"</span></span></span><span class="hljs-tag"> </span><span class="na"><span class="hljs-tag"><span class="hljs-attribute">ng-enter</span>=</span></span><span class="s"><span class="hljs-tag"><span class="hljs-value">"addItem()"</span></span></span><span class="hljs-tag"> </span><span class="na"><span class="hljs-tag"><span class="hljs-attribute">placeholder</span>=</span></span><span class="s"><span class="hljs-tag"><span class="hljs-value">"New item"</span></span></span><span class="nt"><span class="hljs-tag">&gt;</span></span>
<span class="nt"><span class="hljs-tag">&lt;/<span class="hljs-title">p</span>&gt;</span></span></code></pre>
</div>

See the Jekyll docs for more details: http://jekyllrb.com/docs/posts/#highlighting-code-snippets. I don't think I did any special configuration to get those {% highlight %} tags working.

My demo page for Centrarium doesn't show this as the correct way to highlight code. I will fix that!

from centrarium.

christopherlovell avatar christopherlovell commented on August 21, 2024

Ah, I knew it would be something simple. I had to use a combination of the highlight and raw tags to get the html and Liquid to render correctly; just using the highlight tag ended up showing the unescaped html multiple times due to the liquid loops!

Thanks, I think it would be useful to clarify for future users on the readme.

from centrarium.

bencentra avatar bencentra commented on August 21, 2024

I updated the README and demo post with info about {% highlight %}.

from centrarium.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.