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

Zola hangs when highlighting a "bad" code block #1241

Closed
r-bar opened this issue Nov 17, 2020 · 2 comments
Closed

Zola hangs when highlighting a "bad" code block #1241

r-bar opened this issue Nov 17, 2020 · 2 comments

Comments

@r-bar
Copy link

r-bar commented Nov 17, 2020

Bug Report

Environment

OS: Linux x86_64
Zola version: 0.12.2

Expected Behavior

Given a "nodejs console style" javascript example in a content markdown file I expect the site to render when I run zola build or zola serve.

Alternative better behaviors:

  • raise an error indicating it is unable to highlight the code block
  • render the code block with no highlighting applied

There should be no content input that can cause Zola to hang.

Current Behavior

The site builder hangs

Steps to reproduce

Given this code block embedded in a markdown file:

\```javascript
> function capitalize(text) { ... }
> let shoutingMatch = chatMessages.map(capitalize);
> console.log(shoutingMatch);
[
  ...
]
\```

(backticks escaped to not interfere with the github issue rendering)

Running any command that causes zola to render the site (build or serve, check seems unaffected) causes Zola to hang until interrupted with ctrl-c.

Workarounds:

Removing the leading > characters from each line of code, or removing the javascript syntax specifier from the markdown fence allows the document to be compiled again. If there is only a single line of code with a leading > will Zola compile without hanging even with the javascript fence.

@Keats
Copy link
Collaborator

Keats commented Nov 17, 2020

I know, there's an issue with the JS syntax :/

Try using ts, it should be better.

@lud
Copy link

lud commented Dec 17, 2020

Hi,

I think I found the same bug, so I'll let my test case if it can help to fix the bug.

This code block compiles without problems:

```js
function logAfter(value, timeout) {
    return new Promise(ok => setTimeout(ok, timeout)).then(() => console.log(value))
}
```

This one makes zola hang:

```js
function logAfter(value, timeout) {
    return new Promise(ok => setTimeout(ok, timeout))
      .then(() => console.log(value))
}
```

The difference is a single line break + indent before .then.

@Keats Keats closed this as completed in fc8b406 Jan 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants