Do Liquid templares support the concept of documents? - jekyll

I am using the Liquid templating language with Jekyll. I need to be able to define Liquid variables that have a document scope where a document may contain several pages. Is this possible?

Related

Defining (X)HTML node code content in phpStorm

For our HTML templates, we use a content aggregation engine based on a namespaced XML-based markup syntax that has some custom tags defining various fragments of the template. For example, for js code we have:
<foo:js src="http://..." />
<p>
This is regular HTML; this document with the namespaced tags will be
aggregated into HTML by our metalanguage aggregator.
</p>
<foo:js>
console.log('bar');
</foo:js>
I'd be very happy if these could be parsed and edited as JS code or JS reference tags (the self-closing one) in phpStorm. I figured out the "Language injections" settings is designed for that, but I can't find any documentation how to achieve this. The "Places Patterns" seems to be the key to this enigma. So can anyone provide some hints into how to do this using Language Injection(s)?
Also, for the rest of the tags, as a simple form of completion/validation, is it possible to specify a default XML schema (i.e. XSD) for the namespace? I mean, apart from explicit xmlns:foo tags, because our markup files represent fragments so we'd have to add quite a number of these on quite a lot of elements.
The following injection will highlight javascript in all <namespace:js> tags:

If Markdown is a superset of HTML, then why can't it do everything HTML can?

I'm trying to understand Markdown's relationship to HTML. If I understand correctly both are markup languages (an umbrella term describing languages that add formatting elements to plain-text documents). Markdown converts plain text to HTML.
My understanding is that Markdown is a superset of HTML:
Markdown is a popular markup language that is a superset of HTML.
I'm assuming that it's a strict or proper superset. Drawing a parallel from What does it mean when one language is a parallel superset of another?, I interpret that to mean that every valid HTML program is also a valid Markdown program (e.g. HTML is understood in a Jupyter Notebook Markdown cell), but that the converse is not true.
What seems conflicting to me is that if Markdown is a superset of HTML, then why is it that Markdown can't do everything HTML can (I would think the opposite to be true since a superset extends the language without removing or changing any of the existing features. Also, I would expect HTML to be a superset of Markdown since HTML is more expressive and more difficult to read by most humans.
Below is a diagram trying to mimic that in What does “Objective-C is a superset of C more strictly than C++” mean exactly?
That documentation is misleading. Markdown itself is not a superset of HTML. The documentation for the original Markdown project is pretty clear:
Markdown is not a replacement for HTML, or even close to it. Its syntax is very small, corresponding only to a very small subset of HTML tags. The idea is not to create a syntax that makes it easier to insert HTML tags. In my opinion, HTML tags are already easy to insert. The idea for Markdown is to make it easy to read, write, and edit prose. HTML is a publishing format; Markdown is a writing format. Thus, Markdown’s formatting syntax only addresses issues that can be conveyed in plain text.
Today there are several flavours of Markdown, many of which add features that were not present in the original version like tables and syntax-highlighted code blocks. This doesn't change the fundamental fact that Markdown covers a subset of HTML.
(Technically speaking, Markdown isn't a subset of HTML either. *, for example, has no special meaning in HTML. Unconverted Markdown documents might be well-formed HTML but the semantics are very different. But Markdown syntax maps to a subset of HTML tags.)
However, the very next paragraph in the original documentation says:
For any markup that is not covered by Markdown’s syntax, you simply use HTML itself. There’s no need to preface it or delimit it to indicate that you’re switching from Markdown to HTML; you just use the tags.
Since you can directly use HTML in Markdown it could be considered a superset of HTML. For example, this is valid Markdown:
# My awesome title
I <em>really</em> like coffee
If you pass an HTML document through a conforming Markdown processor it should come out the other side untouched. Being able to directly use HTML in Markdown is very similar to how one can directly use C in C++. This may be what the Jupyter documentation means.

What is the difference between html and xml?

Blogger blogs use XML, and Tumblr blogs use HTML, but they both do the same thing. What is the difference between XML and HTML and what are the pros and cons of using them?
HTML is a markup language for describing hypertext ("with links") documents.
XML is a generic markup language designed for using as a base for building custom markup languages.
They are different tools for different jobs.
When you write a template for either Blogger or Tumblr, you are using a template language. Blogger's template language happens to be built in XML. The template language is combined with your data to generate the HTML documents that are sent to the browser.
XML was developed to describe data and to focalize on what the data represent.
HTML was developed to display data about to focalize on the way that data looks.
HTML is about displaying data, XML is about describing information.
Reference
In an ideal world, HTML would be just one of many XML vocabularies. The only reason it isn't is history: (a) it was wild on the web before XML was formulated, and (b) it developed a culture where you could write any old garbage and the browsers would try and make sense of it, whereas XML insisted that you stick to the rules.
The W3C spent about ten years trying to make this vision happen, through the medium of XHTML, but in the end the browser vendors decided to go their own way.
XML was developed to describe data and to focalize on what the data represents.
Whereas HTML describes the structure of Web pages using markup.
In other words, HTML is used to display data, XML is used to store and transport data.

What is the difference between Template Engines and Preprocessors?

There are Template Engines and there are Preprocessors.
List of some Template Engines
Smarty
Twig
TinyButStrong
List of some Preprocessors
Haml
Slim
Jade / Pug
What exactly is the difference?
Haml, Slim, and Jade / Pug don't define themselves as preprocessors or distinct from template engines:
Haml is a markup language that’s used to cleanly and simply describe the HTML of any web document without the use of inline code. Haml functions as a replacement for inline page templating systems.
Slim is a template language...
Pug is a high performance template engine heavily influenced by Haml and implemented with JavaScript
A preprocessor takes input and changes it before it's fed to another program. A template engine might be said to be a type of preprocessor that's specific to documents. The choice of what to call any of these applications that output HTML is largely semantics.

What is the best way to embed HTML in an RSS feed?

I am using Django's RSS capabilities to build an RSS feed. The <description> of the RSS feed items contains HTML markup. Currently, I am just injecting the HTML markup into the feed using the following template:
{{ obj.post }}
Django, of course, translates special characters (<, >, &, etc.) to their respective HTML entities.
I know I could just output the HTML and wrap all the HTML code in <![CDATA[...]]> sections. This page says that either method is acceptable. If that's true, is there a good reason to pick one method over the other? And if I use example #2, is there a filter for Django to automatically wrap the HTML text in CDATA tags, or should I just change my template to:
<![CDATA[
{{ obj.post|safe }}
]]>
Edit
It seems that Django autoescapes special characters in RSS feeds (or any XML for that matter) no matter what, regardless of whether you pass it through the safe filter or not (the issue is discussed in this ticket). However, general answers are welcome.
When I run into issues like this with Django my first instinct is to run off and find a normal Python lib that does what I want. In this case PyRSS2Gen might be your saviour.
It'll probably require a bit more fannying around (because it'll be unaware of what Django objects are) but it should be raw enough to let you do as you wish.
And if it isn't, it's just a script. You can hack it apart to allow raw HTML if you please =)
Embedding HTML is CDATA has troubled me in the past. Hope RSS readers have evolved to handle such embeds.
Instead of writing your own RSS XML feed, consider using the Django syndication framework from django.contrib.syndication:
https://docs.djangoproject.com/en/dev/ref/contrib/syndication/