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

Extra syntax conflict #1309

Closed
tatref opened this issue Jan 14, 2021 · 7 comments
Closed

Extra syntax conflict #1309

tatref opened this issue Jan 14, 2021 · 7 comments
Labels
bug done in pr Already done in a PR

Comments

@tatref
Copy link

tatref commented Jan 14, 2021

Bug Report

When defining extra_syntaxes in config.toml, standard highlighters no longer work.

Environment

Zola version: 0.13, also tested master and next branches (2021-01-14).

This was working with the next branch some days ago (not sure about the exact date though..)

Step to reproduce

Test article. py3 is a standard language. shell-session is a custom language, defined in syntaxes/shell-session.sublime-syntax

+++
title = "highlight"
slug = "highlight"

date = 2099-01-01

draft = true

[taxonomies]
tags = ["test"]
+++

```py3
python = "python"
```

```shell-session
$ echo shell
```

1st test case: here I set extra_syntaxes in cargo.toml:

[markdown]
extra_syntaxes = ["syntaxes"]
highlight_code = true

Result:
image

Note that the python code is node highlighted, that's the issue

2nd test case: extra_syntaxes is commented:

[markdown]
#extra_syntaxes = ["syntaxes"]
highlight_code = true

image

The python code is now properly highlighted.

If you want to reproduce, here is the shell-session.sublime-syntax (disclaimer: it's just a quick and dirty hack...)

%YAML 1.2
---
file_extensions:
  - shell-session
scope: source.test

contexts:
  main:
    - match: "^((?:\\(.*?\\) )?[^ ]*(?:\\$|#|>))( .*)?"
    #           ^^^^^^^^^^^^^^ python venv
    #                          ^^^^ user@hostname
    #                               ^^^^^^^^^^^^ last prompt character
    #                                           ^^^^^ command
      captures:
        1: constant.prompt
        2: keyword.command
@Keats Keats added the bug label Jan 15, 2021
@Keats
Copy link
Collaborator

Keats commented Jan 15, 2021

Looks like the extra -> default syntax fallback is not working well

@southerntofu
Copy link
Contributor

@tatref what do you think of this patch instead?

I think the logical error was there: when there are some extra syntaxes, only those were looked up, not the theme.

@southerntofu
Copy link
Contributor

unrelated, but there seems to be some hardcoded config.markdown.extra_syntaxes which could lead to unexpected issues like #1299. i'd be happy to fix those hardcoded paths (until removal of config.extra_syntaxes) on my branch there if it can help

@tatref
Copy link
Author

tatref commented Jan 15, 2021

Yes, your patch is semantically more correct.

Something else related to highlighting: what do you think about emitting warnings is the language is not found? (so if fallback to plaintext)

@southerntofu
Copy link
Contributor

Yes (...) emitting warnings

Ok i opened #1312 with such warnings. What do you think?

unrelated, but there seems to be some hardcoded

My bad it looks OK actually :)

@Keats Keats added the done in pr Already done in a PR label Feb 2, 2021
@tomholford
Copy link

tomholford commented Apr 3, 2021

Was able to checkout and build the next branch and successfully serve a site that has an extra_syntaxes key in the config 👍

edit:
@Keats Are there any plans to ship next as 0.13.1 or 0.14.0?

yaymukund pushed a commit to yaymukund/yaymukund-blog that referenced this issue Jun 4, 2021
Needed to add syntaxes to syntaxes/ because apparently using
extra_syntaxes results in the default syntaxes not working anymore:

getzola/zola#1309
yaymukund pushed a commit to yaymukund/yaymukund-blog that referenced this issue Jun 4, 2021
Needed to add syntaxes to syntaxes/ because apparently using
extra_syntaxes results in the default syntaxes not working anymore:

getzola/zola#1309
thezeroalpha added a commit to thezeroalpha/lectures.alex.balgavy.eu that referenced this issue Jun 9, 2021
Defining `extra_syntaxes` in the config causes default syntaxes to stop
working, see getzola/zola#1309. Fixed
temporarily by copying in the syntax files I use, will revert on a new
release from Zola.
@Chaostheorie
Copy link

@tomholford see #1529

@Keats Keats closed this as completed in 14366da Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug done in pr Already done in a PR
Projects
None yet
Development

No branches or pull requests

5 participants