What are the proper liquid tags for CODE and PRE

I am writing a lot of technical documentation and as such I use characters like {}*^%$#@!-+<>

That will be all over the place. So as an example

* <code>-cp-general:<codepage></code> where is either utf8 or a [[14-whatsnew.html#Languages | codepage number]]. NOTE: It should not be necessary to override this.
* <code>-<gamemode></code> [Specifies which game mode to use. <gamemode> can be any of the following: 'tes5vr', 'fo4vr', 'tes4', 'tes5', 'enderal', 'sse', 'fo3', 'fnv', 'fo4', 'fo76']
* <code>-C:<path></code> [path to use for cache files]
* <code>-R:<path><filename></code> [Custom xEdit Log Filename]

Just to name a few

If I add {% raw %} and {& endraw %} I end up with this for HTML

<p class="list-1">&bull;&nbsp; {% raw %}<code>-cp-general:<codepage></code>{% endraw %} where is either utf8 or a <a  href="14-whatsnew.html#Languages">codepage number</a>. NOTE: It should not be necessary to override this.</p>
<p class="list-1">&bull;&nbsp; {% raw %}<code>-<gamemode></code>{% endraw %} [Specifies which game mode to use. <gamemode> can be any of the following: 'tes5vr', 'fo4vr', 'tes4', 'tes5', 'enderal', 'sse', 'fo3', 'fnv', 'fo4', 'fo76']</p>
<p class="list-1">&bull;&nbsp; {% raw %}<code>-C:<path></code>{% endraw %} [path to use for cache files]</p>
<p class="list-1">&bull;&nbsp; {% raw %}<code>-R:<path><filename></code>{% endraw %} [Custom xEdit Log Filename]</p>

I would like to not have to hunt down all the <> and replace them with &lt;&gt;

Is there another code that would prevent those kinds of symbols from being hidden/excluded in this fashion?

For now I have just mass replaced the <> with &lt;&gt; so I can finish what I am doing but I’d like to know the proper way to do this without having to replace the text like that.

You need not use <code> tags directly.
Instead, enclose inline code in a pair of backticks. For example:

- `-cp-general:` where is either utf8 or a [codepage number](#link-href). NOTE: It should not be necessary to override this.
- `-cp:` or `-cp-trans:`

renders into

  • -cp-general: where is either utf8 or a codepage number. NOTE: It should not be necessary to override this.
  • -cp: or -cp-trans:

Liquid % raw % enclosure is only needed when the enclosed text contains sequences of either of {{,   }},   {%   or   %}

Disclaimer: I have no clue regarding the need for / relevance of XML tags <codepage>, <gamemode>, etc used in the doc…

This is not Liquid {{PAGETITLE=“Your Page Title”}} This is not XML -cp: where is one a valid code page from the following list:

“English” - 1252
“French” - 1252
“German” - 1252
“Italian” - 1252
“Polish” - 1250
“russian” - 1251
“spanish” - 1252

Instead, enclose inline code in a pair of backticks. For example:

From what I understand browsers and Jekyll do not process open and closing backtick ` symbols automatically. I don’t feel like trying it because I don’t feel I will have the desired output.

but markdown should - so a markdown doc in a jekyll site should work.

It isn’t clear how you are writing - as markdown or as html?

markdown in jekyll should work more or less the same as this discourse forum does.

I am creating the site with html and css and using jekyll to view the changes before I submit them to the github repository for GitHub to process for its github pages.

What seems to be confusing everyone is that when I say I have this desired outcome everyone presumes I am using markdown or liquid and now even XML.

I’m just putting syntax for a program I work on and a python script I have written. The syntax tells the user of the python script or the program what syntax to follow. No different then how the jekyll docs tell someone how to use Jekyll.

Once I say this is my html line

<p class="class><code>-cp:<filename></code><p>

Or

<p class="list-1"><code>{{PAGETITLE="Your page title"}}</code><p>

Assumptions are made and the response is don’t use liquid or XML that way, you don’t do that.

The program I work on requires greater and less than symbols as part of the syntax so I can’t leave it out.

The confusion seems to be that I am asking a simple question about how to force jekyll to ignore certain text in the html and then the responce adds to the confusion because the responses presume that I am hiding information. I’m not.

I am very simply saying this is my input and this is my output. The output isn’t the desired output, how do I achieve the desired result.

Here is the page where I am trying to write out the syntax for the program I work on

The text only displays how I want adding &gt;&lt; which I don’t want to have to find all the web page equivalents to symbolize commonly used symbols like #$%^&*@!<>/×+{}~ and replace them with &xx;

This is the python script documentation.

I keep having to find ways to get the html to display how I want and it shouldn’t matter what is in the html file. Parts of it shouldn’t be excluded once processed by the site builder.

most people use markdown, and it would do most/likely all of what you want much easier than writing out the html. Mostly when I help someone they are using markdown not html, so on my end or anyone else trying to help it can be unclear what you are doing, thus more questions to try and understand.

It is always helpful for us to see an actual source file and the rendered file so it is more clear.

Is there a reason to not use markdown? sorry, had to ask.

in your examples

<p class="class><code>-cp:<filename></code><p>

when you do that, what is the exact problem? I don’t see a rendered example that shows the exact issue.

Your first 2 screenshots look good to me, is there a problem in there? or are they examples of what you want? your 3rd and 4th posts don’t make sense to me so I don’t actually see the issue, though I think I sort of understand the question and my understanding is <code></code> should do what you want - make it so that odd characters don’t cause an issue.

I’m happy to try and help, keep in mind I am a volunteer and while I am experienced with jekyll I am not all knowing and generally don’t go pop your code into a test site to try and understand the issue - sometimes I do, but not usually.

to try and be clear on the raw/endraw - your example in the first post should not need the raw tag. The raw tag is to escape liquid tags only(?) - as anywhere jekyll sees {{ or }} or {% or %} it will assume it is liquid and needs to be processed and will throw an error or otherwise do something you don’t want.

On the final doc page you linked to I don’t see any of those character strings - or do you need those also?

This is so funny I just spent three hours writing up the answer to your question.

So before I start I want to thank you for taking the time to respond and I am appreciating that you understand that normally when you help others they are using markdown. I however can not work with the limitations of it because I want additional CSS that won’t happen automatically if I put in in a somefile.md file.

I have been using hacks to make this all work so if you look at the site HTML files they will only contain the syntax needed for the desired outcome.

I do really appreciate your time, I do appreciate ashmaroli’s responses so far, but the responses so far have been more of a critique of my methods rather then how to achieve the desired result.

Keep in mind that you won’t see some of these examples on my wbepages because it would be silly for me to leave them with the improper syntax just so you can see it.

The reason why I feel that some of my improper syntax isn’t needed is because my question is very simply what is the proper liquid tag for CODE and PRE. Because when used Jekyll does things I would not expect it to do.

Maybe I could say, what is the proper syntax for jekyll so that all characters in a code or pre block are displaied and not ignored.

Now in the following responses I’ll give some examples.

To start I am using HTML and CSS, so everything is in a .html file.

This Input:

<p>Testing Pre Block</p>
<pre>
def imageInline(maObject):
    var1 = maObject.group(0).strip()
    var1 = re.sub(r'{{inline:(.+?)}}', r'\1', var1)
    var1 = re.sub(r'\n', r'', var1)
    if '|' in var1:
        (max_width, file_name, alt_text) = [chunk.strip() for chunk in var1.split('|', 2)]
    return '{{% include image-inline.html max-width="{}" file="img/{}" alt="{}" %}}\n'.format(max_width, file_name, alt_text)
</pre>

Produces this error in GitBash

image

Notice the return line:

return '{{% include image-inline.html max-width="{}" file="img/{}" alt="{}" %}}\n'.format(max_width, file_name, alt_text)

That is the proper syntax to output to a file a single curly bracket as noted here on stackoverflow.

So if I am making a web page to tell someone that when using Python and you need to print out a single {} curly bracket I would need to put you need double curly brackets and if I show them it causes Jekyll to have a syntax error with Liquid.

This input will produce the desired output:

Testing Pre Block
{% raw %}<pre>
def imageInline(maObject):
    var1 = maObject.group(0).strip()
    var1 = re.sub(r'{{inline:(.+?)}}', r'\1', var1)
    var1 = re.sub(r'\n', r'', var1)
    if '|' in var1:
        (max_width, file_name, alt_text) = [chunk.strip() for chunk in var1.split('|', 2)]
    return '{{% include image-inline.html max-width="{}" file="img/{}" alt="{}" %}}\n'.format(max_width, file_name, alt_text)
</pre>{% endraw %}

So that is one example of an error from Jekyll.

Next example in an .html file:

Input

<p>Testing Text in an HTML document</p>
<code>{{PAGETITLE="xEdit Overview"}}</code>

Error

image

Output

image

This is what I meant in my previous post by hiding or excluding the text. The incorrect syntax isn’t even displayed.

Correct Input:

Testing Text in an HTML document

{% raw %}{{PAGETITLE="xEdit Overview"}}{% endraw %}

Desired Output

image

So also I was able to acheive the desired result.

This is what I have been mentioning I don’t want to have to do.

Alternate Input

<p>Testing Text in an HTML document</p>
<code>&#123;&#123;PAGETITLE="xEdit Overview"&#125;&#125;</code>

Alternate but desired output

image

As you read that you may think if you are adding {% raw %}{% endraw %} and getting the desired output then I don’t see what your concern is. That’s valid but you are asking for examples and I’m giving them.

The question for this post is what do I use so that anything in a code or pre block will display as is with any symbold contained between the code or pre block. Any symbol like from this list !@#$%^&*()-_+={}[];:’"` any and all of those should be displayed exactly as I put them between code or pre.

I thought {% raw %}{% endraw %} was the solution to my problem until I noticed what I will explain in the next example.

anywhere jekyll sees {{ or {% or their closing tags and it is not actual liquid code you have to use the raw tag to escape it, there is no other way to do it that I know of. Liquid will try to use if it is not wrapped in raw but it is not valid liquid so you get the error.

That is a specific use case, and those are the only 2 liquid code tags. Any other character sequences should work more as you intend I think.

So I would separate out the few examples that use those and then maybe you use raw on those but the other ones can be pre or code?

What prompted this question:

Input

<p>Testing Text in an HTML document</p>
<p class="list-1">&bull;&nbsp; {% raw %}<code>-cp-general:<codepage></code>{% endraw %} where is either utf8 or a <a  href="14-whatsnew.html#Languages">codepage number</a>. NOTE: It should not be necessary to override this.</p>
<p class="list-1">&bull;&nbsp; {% raw %}<code>-<gamemode></code>{% endraw %} Specifies which game mode to use. {% raw %}<code><gamemode></code>{% endraw %} can be any of the following: ['tes5vr', 'fo4vr', 'tes4', 'tes5', 'enderal', 'sse', 'fo3', 'fnv', 'fo4', 'fo76'] Example {% raw %}<code>-fo76</code>{% endraw %} for Fallout 76.</p>
<p class="list-1">&bull;&nbsp; {% raw %}<code>-C:<path></code>{% endraw %} [path to use for cache files]</p>
<p class="list-1">&bull;&nbsp; {% raw %}<code>-R:<path><filename></code>{% endraw %} [Custom xEdit Log Filename]</p>
<p class="empty">&nbsp;</p>
{% raw %}<pre>
Alternatively, the codepage for translatable strings can now be overridden by placing the text `<cp:xxxx>` somewhere in the description (in the file header) of the module. `xxxx` can be `utf8` or any valid codepage number, e.g. `1252`. codepages with less than 4 digits must use leading 0s, e.g. `<cp:0930>`.
</pre>{% endraw %}

Output:

It is really hard to see it but try to read the HTML and look for where is says {% raw %}<code><gamemode></code>{% endraw %} can be any of the following...

That is what happens when the text is excluded or hidden and it’s hard to notice. I am literally just throwing anything at Jekyll and hack the HTML to make this work.

Here is the syntax that will give me the desired result, however it is what I want to avoid. Again I don’t want to have to hunt down all the &xx; codes to display symbols in my HTML files.

<p>Testing Text in an HTML document</p>
<p class="list-1">&bull;&nbsp; <code>-cp-general:&lt;codepage&gt;</code> where is either utf8 or a <a  href="14-whatsnew.html#Languages">codepage number</a>. NOTE: It should not be necessary to override this.</p>
<p class="list-1">&bull;&nbsp; <code>-&lt;gamemode&gt;</code> Specifies which game mode to use. &lt;gamemode&gt; can be any of the following: ['tes5vr', 'fo4vr', 'tes4', 'tes5', 'enderal', 'sse', 'fo3', 'fnv', 'fo4', 'fo76'] Example <code>-fo76</code> for Fallout 76.</p>
<p class="list-1">&bull;&nbsp; <code>-C:&lt;path&gt;</code> path to use for cache files</p>
<p class="list-1">&bull;&nbsp; <code>-R:&lt;path&gt;&lt;filename&gt;</code> Custom xEdit Log Filename</p>
<p class="empty">&nbsp;</p>
<pre>
Alternatively, the &lt;codepage&gt; for translatable strings can now be overridden by placing the text `&lt;cp:xxxx&gt;` somewhere in the description (in the file header) of the module. `xxxx` can be `utf8` or any valid &lt;codepage&gt; number, e.g. `1252`. codepages with less than 4 digits must use leading 0s, e.g. `&lt;cp:0930&gt;`.
</pre>

Desired output:

What I am sayig is that I should not have to pass it all the little &gt;&lt; tags.

I should be able to provide this syntax and get the desired result

<p>Testing Text in an HTML document</p>
<p class="list-1">&bull;&nbsp; {% raw %}<code>-cp-general:<codepage></code>{% endraw %} where is either utf8 or a <a  href="14-whatsnew.html#Languages">codepage number</a>. NOTE: It should not be necessary to override this.</p>
<p class="list-1">&bull;&nbsp; {% raw %}<code>-<gamemode></code>{% endraw %} Specifies which game mode to use. {% raw %}<code><gamemode></code>{% endraw %} can be any of the following: ['tes5vr', 'fo4vr', 'tes4', 'tes5', 'enderal', 'sse', 'fo3', 'fnv', 'fo4', 'fo76'] Example {% raw %}<code>-fo76</code>{% endraw %} for Fallout 76.</p>
<p class="list-1">&bull;&nbsp; {% raw %}<code>-C:<path></code>{% endraw %} path to use for cache files</p>
<p class="list-1">&bull;&nbsp; {% raw %}<code>-R:<path><filename></code>{% endraw %} Custom xEdit Log Filename</p>
<p class="empty">&nbsp;</p>
{% raw %}<pre>
Alternatively, the {% raw %}<code><codepage></code>{% endraw %} for translatable strings can now be overridden by placing the text `{% raw %}<code><cp:xxxx></code>{% endraw %}` somewhere in the description (in the file header) of the module. `xxxx` can be `utf8` or any valid {% raw %}<code><codepage></code>{% endraw %} number, e.g. `1252`. codepages with less than 4 digits must use leading 0s, e.g. `{% raw %}<code><cp:0930></code>{% endraw %}`.
</pre>{% endraw %}

That should produce the desired output but it doesn’t. Hench my question, what is the proper liquid tag, or the proper syntax to achieve the desired result using the HTML shown immediately above this paragraph.

Which is:

anywhere jekyll sees {{ or {% or their closing tags and it is not actual liquid code you have to use the raw tag to escape it,

I had to edit my last example several times to make sure I had all the syntax properly explained.

My last response starting with “What prompted this question:” is what lead to the need to ask this question. Because while using {% raw %} and {% endraw %} works when there are {{ open and closing curly brackets, it is not working with <>.

That is a specific use case

That is a disappointing response also. Because if I were writing Python documentation to teach people how to use Python and I put the line:

return '{{% include image-inline.html max-width="{}" file="img/{}" alt="{}" %}}\n'.format(max_width, file_name, alt_text)

It won’t work without {% raw %}{% endraw %}

Python is not special use in my opinion. The documentation for my Python script and the documentation for xEdit is special use. So I do understand where you are coming from there.

I’m just trying to explaining how to use the Python script and the proper syntax for a program I contribute to and having the need to show open and closing <> and open and closing double {{. I’m told well “Shrug” just don’t do it that way.

It’s fine really. It’s disappointing but it’s fine. To me it’s a bug in the software to process the text that way but I do understand more coding goes into a project like Jekyll then people that don’t do any programming realize. You don’t see the value or wish to correct what you see as edge case or special use, but that I see as an oversight. It’s understandable, just disappointing.

maybe this will help:

the raw tag is purely to escape the 2 liquid tags. I think you are using it where it is not going to do what you want.

So maybe something like:

<code>
return '{% raw %}{{% {% endraw %}include image-inline.html max-width="{}" file="img/{}" alt="{}"{% raw %} %}}{% endraw %}\n'.format(max_width, file_name, alt_text)
</code>

or maybe just one raw tag? not sure which would be better

<code>
return '{% raw %}{{% include image-inline.html max-width="{}" file="img/{}" alt="{}"%}}{% endraw %}\n'.format(max_width, file_name, alt_text)
</code>

I googled a bit and there are other threads about using python with jekyll and having the same issue, mostly concluding with using the raw tag that I saw.

For this example:

<p class="list-1">&bull;&nbsp; <code>-cp-general:&lt;codepage&gt;</code> where is either utf8 or a <a  href="14-whatsnew.html#Languages">codepage number</a>. NOTE: It should not be necessary to override this.</p>

what is wrong with:

<code>-cp-general:<codepage></code> where is either utf8 or a [[14-whatsnew.html#Languages | codepage number]]. NOTE: It should not be necessary to override this.
<p class="list-1">&bull;&nbsp; {% raw %}<code>-cp-general:<codepage></code>{% endraw %} where is either utf8 or a <a href="14-whatsnew.html#Languages">codepage number</a>. NOTE: It should not be necessary to override this.</p>

in this example the raw tag has nothing to escape so why is it there?

which is back to the 2 different issues - one where the text inculdes the {{ or {%, I see sort of what you are having issues with these, but on this example what is the issue?

Jekyll has to know when to process liquid and when not to, the raw tags only purpose is to tell it not to process the stuff inbetween as liquid. What other way would there be to do this?

obviously in a perfect world the liquid tags would be unique to all other tags and then there would be no issue. Well, I’m sure something would be an issue.

Maybe it doesn’t show in the browser properly which is another indication of why I feel it’s broken.

Here is a screen shot:

That HTML Produces this undesired result:

image

it is supposed to look like this: