Zola: Shortcodes getting wrapped in <pre> on next branch

Created on 16 Nov 2018  Â·  8Comments  Â·  Source: getzola/zola

Something may have changed in the shortcode syntax, but according to the shortcode docs in the next branch, I don't think so.

All of my shortcodes are being wrapped in <pre></pre> blocks when running on the latest next branch. Both inline and body types.

An example shortcode:

<figure>
     {% if width %}
     <img src="/images/{{ src }}" alt="{{ caption }}" width="{{ width }}" />
     {% else %}
     <img src="/images/{{ src }}" alt="{{ caption }}" />
     {% endif %}
     <figcaption>{{ caption }}</figcaption>
</figure>

call:

{{ figure(src="spherecluster.png", caption="Some spheres.") }

output:

<figure>
<pre style="background-color:#2b2c2f;"><span style="color:#cccece;">&lt;img src="/images/spherecluster.png" alt="Some spheres." /&gt;
</span><span style="color:#cccece;">
</span><span style="color:#cccece;">&lt;figcaption&gt;Some spheres.&lt;/figcaption&gt;
</span></pre></figure>

Is this something wrong on my end, an overlooked change, or a bug to be investigated?

bug

Most helpful comment

Ah perfect I knew I was forgetting to handle something.
This is because markdown interprets the indented lines as code and try to highlight them, which it shouldn't really as it is in a figure tag

Needs to be fixed before release

All 8 comments

Ah perfect I knew I was forgetting to handle something.
This is because markdown interprets the indented lines as code and try to highlight them, which it shouldn't really as it is in a figure tag

Needs to be fixed before release

Cool. Can confirm that's definitely the issue - if I remove any indentation then everything renders as expected.

Can you try the next branch again? It should be working now

This fixes the inline example above, as well as the body type shortcodes provided there is no whitespace before them.

{{ figure(src="spherecluster.png", caption="Some spheres.") }

works as expected, whilst

    {{ figure(src="spherecluster.png", caption="Some spheres.") }

still wraps. Not too sure if this is something that just needs to be documented as 'shortcodes should not be indented', or if this can also be taken into account.


Additionally, but perhaps unrelated? I get this panic when running zola serve and swapping between the above two examples.

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', libcore/option.rs:355:21
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at libstd/sys_common/backtrace.rs:59
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:476
   5: std::panicking::continue_panic_fmt
             at libstd/panicking.rs:390
   6: rust_begin_unwind
             at libstd/panicking.rs:325
   7: core::panicking::panic_fmt
             at libcore/panicking.rs:77
   8: core::panicking::panic
             at libcore/panicking.rs:52
   9: library::taxonomies::SerializedTaxonomyItem::from_item
  10: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  11: library::taxonomies::Taxonomy::to_serialized
  12: templates::global_fns::make_get_taxonomy
  13: site::Site::register_tera_global_fns
  14: rebuild::handle_page_editing
  15: rebuild::after_content_change
  16: zola::cmd::serve::serve
  17: zola::main
  18: std::rt::lang_start::{{closure}}
  19: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  20: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:102
  21: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:398
             at libstd/rt.rs:58
  22: main
  23: __libc_start_main
  24: _start

My taxonomies for reference, since that's where it seems to be having an issue, is just:

taxonomies = [
    {name = "tags"},
]

and the entry in which I'm doing this testing is

[taxonomies]                                                                                                                                                          
tags = ["Geometry"]

This seems to be the unwrap in question, if I've traced it correctly.

I'll have a look at the indented version tomorrow but don't really see a
way to make it work right now.
Thanks for the panic report, should be an easy fix if anyone wants to try.

On Fri, 16 Nov 2018, 19:30 Tim DuBois <[email protected] wrote:

This fixes the inline example above, as well as the body type shortcodes
provided there is no whitespace before them.

{{ figure(src="spherecluster.png", caption="Some spheres.") }

works as expected, whilst

{{ figure(src="spherecluster.png", caption="Some spheres.") }

still wraps. Not too sure if this is something that just needs to be
documented as 'shortcodes should not be indented', or if this can also be

taken into account.

Additionally, but perhaps unrelated? I get this panic when running zola
serve and swapping between the above two examples.

thread 'main' panicked at 'called Option::unwrap() on a None value', libcore/option.rs:355:21
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::_print
at libstd/sys_common/backtrace.rs:71
2: std::panicking::default_hook::{{closure}}
at libstd/sys_common/backtrace.rs:59
at libstd/panicking.rs:211
3: std::panicking::default_hook
at libstd/panicking.rs:227
4: std::panicking::rust_panic_with_hook
at libstd/panicking.rs:476
5: std::panicking::continue_panic_fmt
at libstd/panicking.rs:390
6: rust_begin_unwind
at libstd/panicking.rs:325
7: core::panicking::panic_fmt
at libcore/panicking.rs:77
8: core::panicking::panic
at libcore/panicking.rs:52
9: library::taxonomies::SerializedTaxonomyItem::from_item
10: as alloc::vec::SpecExtend>::from_iter
11: library::taxonomies::Taxonomy::to_serialized
12: templates::global_fns::make_get_taxonomy
13: site::Site::register_tera_global_fns
14: rebuild::handle_page_editing
15: rebuild::after_content_change
16: zola::cmd::serve::serve
17: zola::main
18: std::rt::lang_start::{{closure}}
19: std::panicking::try::do_call
at libstd/rt.rs:59
at libstd/panicking.rs:310
20: __rust_maybe_catch_panic
at libpanic_unwind/lib.rs:102
21: std::rt::lang_start_internal
at libstd/panicking.rs:289
at libstd/panic.rs:398
at libstd/rt.rs:58
22: main
23: __libc_start_main
24: _start

My taxonomies for reference, since that's where it seems to be having an
issue, is just:

taxonomies = [
{name = "tags"},
]

and the entry in which I'm doing this testing is

[taxonomies] tags = ["Geometry"]

This
https://github.com/Keats/gutenberg/blob/next/components/templates/src/global_fns/mod.rs#L133
seems to be the unwrap in question, if I've traced it correctly.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/Keats/gutenberg/issues/522#issuecomment-439484026,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AApho8dGI1CMBaQhwND5vIQ6j4gWZVy4ks5uvwRDgaJpZM4YmdXU
.

No problems. I can adjust a few things I have accordingly. Really not a big deal.

May have some time to take a look myself tomorrow at the panic.

Sorry, I had a look to see whether it would be a complicated issue or not but it ended up being a 3 lines fix so I just pushed it to next.
I'll take more beta-testing though :p

The taxonomy panic: yep, that fix sorted it.
Thanks.

Was this page helpful?
0 / 5 - 0 ratings