Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Liquid preprocessor not applied to included AsciiDoc files #166

Open
lschmelzeisen opened this issue Sep 24, 2017 · 8 comments
Open

Liquid preprocessor not applied to included AsciiDoc files #166

lschmelzeisen opened this issue Sep 24, 2017 · 8 comments
Assignees

Comments

@lschmelzeisen
Copy link

According to the documentation, one should be able to set :page-liquid: to have the Liquid preprocessor be applied to AsciiDoc files. Currently, it seems like this is not applied to AsciiDoc files included from other files.

The reason for this is probably that Liquid is being run before the content is being passed to the AsciiDoc processor.

Steps to reproduce:

  1. Clone jekyll-asciidoc-quickstart

  2. Replace index.adoc by the following content:

    = Liquid in AsciiDoc Includes Test
    :showtitle:
    :page-liquid:
    
    {% for i in (1..3) %}
    {{ i }}
    {% endfor %}
    
    include::_myinclude.adoc[]
  3. Add file _myinclude.adoc to the root of the project with following content:

    {% for i in (1..3) %}
    {{ i }}
    {% endfor %}
  4. run jekyll serve (or equivalent) in the root of project

  5. visit the page generated by jekyll

Expected output

1
2
3
1
2
3

Observed output:

1
2
3
{% for i in (1..3) %} {{ i }} {% endfor %}
@mojavelinux
Copy link
Member

Hmm. Something definitely does not seem right here. Thanks for reporting. I'll dig into it and see what's going on.

@mojavelinux
Copy link
Member

The problem is that the liquid filter is applied to the raw source, before the AsciiDoc plugin gets involved. That step doesn't know anything about AsciiDoc includes, so it only looks at the flat source. Then Asciidoctor comes in and converts the content. Only then is the include file folded in, but Asciidoctor doesn't know anything about liquid. That's why the liquid tags are not processed in the include file.

There was never a test for this scenario, which is why it got overlooked.

In order to solve this, we'd need to introduce a custom IncludeProcessor that applies the liquid filter on the included content. At the moment, that has side effects, so it needs to be handled carefully.

@mojavelinux mojavelinux self-assigned this Oct 3, 2017
@sitesref
Copy link

sitesref commented Feb 1, 2018

Hello :)

So, if I got it well, it means it's not currently possible to make Liquid-specific instructions (like cycle for example) work in an .ADOC file ? We have to choose one of those two scenarios for each page:

  1. Either begin the file with the classical AOC header (with layout etc), and give up Liquid instructions ;
  2. Either begin the file with the :page-liquid: instruction, making the Liquid-specific code work, but disabling the ADOC header and some (if not all) ADOC features.

Just want to be sure I understood quite well the current situation. Thanks :)

@mojavelinux
Copy link
Member

This limitation is only scoped to include files. You can use liquid markup in the primary AsciiDoc document.

The limitation is not based on how you define the page data (i.e., front matter). It applies to all AsciiDoc files. The problem is, Jekyll has already run the Liquid engine before Asciidoctor has a chance to process includes. In order to add support for Liquid markup in included files, we'd have to implement a custom include processor, but that currently has other side effects.

@mojavelinux
Copy link
Member

If we get the following issue fixed in Asciidoctor core, then it would open the door for adding liquid processing to include files: asciidoctor/asciidoctor#571

(I need that feature for another use case, so it's very likely I'll implement it soon).

@rkratky
Copy link

rkratky commented Aug 14, 2019

@mojavelinux, any update on this? I have a project site that uses includes heavily, and this is blocker for us :(

@mojavelinux
Copy link
Member

Nope, sorry.

@ydirson
Copy link

ydirson commented Apr 30, 2020

An easy workaround is to use liquid-level include: {% include stuff.adoc %}

phiz71 added a commit to gravitee-io/gravitee-docs that referenced this issue Sep 30, 2022
- help to avoid missing link in readme
- will help to workaround this bug asciidoctor/jekyll-asciidoc#166
phiz71 added a commit to gravitee-io/gravitee-docs that referenced this issue Oct 4, 2022
- help to avoid missing link in readme
- will help to workaround this bug asciidoctor/jekyll-asciidoc#166
phiz71 added a commit to gravitee-io/gravitee-docs that referenced this issue Oct 21, 2022
- help to avoid missing link in readme
- will help to workaround this bug asciidoctor/jekyll-asciidoc#166
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants