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

Command preprocessing with quote not working (e.g. with the jq library) #201

Open
pringshia opened this issue Nov 19, 2022 · 6 comments · May be fixed by #271
Open

Command preprocessing with quote not working (e.g. with the jq library) #201

pringshia opened this issue Nov 19, 2022 · 6 comments · May be fixed by #271

Comments

@pringshia
Copy link

pringshia commented Nov 19, 2022

Describe the bug
I'm using the jq library to format some JSON.

Here's what my markdown file looks like:

# Testing JSON formatting

```
~~~jq '.'
[{"q": "test"}]
~~~
```

Here's the command being run on the command line, to ensure it works as expected:

$ echo '[{"q": "test"}]' | jq '.'
[
  {
    "q": "test"
  }
]

Expected behavior
I'm expecting the code block to show the output of what I see when I run the command above in the command line.

I've verified that the file has chmod +x permissions and other commands work.

Screenshots
Just getting an empty code block. I've verified that the file has chmod +x permissions and other commands work.

CleanShot 2022-11-19 at 15 02 13

Desktop (please complete the following information):

  • OS: Apple MBP, M1 Max
@pringshia
Copy link
Author

I did some more testing and it seems that slides isn't happy with the quote (') in the command. Is there any workaround for this?

@pringshia pringshia changed the title Unable to get command preprocessing to work with the jq library Command preprocessing with quote not working (e.g. with the jq library) Nov 19, 2022
@maaslalani
Copy link
Owner

image

Are you able to remove the ' from the command?

# JQ

~~~jq .
[{"foo": "bar"}]
~~~

@pringshia
Copy link
Author

pringshia commented Nov 19, 2022

In this case dropping the quotes does work, thank you 🙂

Another "workaround" in the case where quotes might be necessary in someone's command for whatever reason: creating a script.sh file with the full command and then just calling that from the presentation *.md file.

# JQ

~~~sh script.sh
[{"foo": "bar"}]
~~~

and the created script.sh would look something like:

jq ".[0].q"

@maaslalani
Copy link
Owner

maaslalani commented Nov 19, 2022

image

For syntax highlighting:

# JQ

```json
~~~jq .
[{"foo": "bar"}]
~~~
```

@maaslalani
Copy link
Owner

I think I know why the quotes do not work, as we have a similar problem with pipes: #148.

I think the solution can be that slides can make a temporary shell script file for the command and execute that if it contains quotes or pipes.

@pringshia
Copy link
Author

@maaslalani That sounds like an elegant solution! Thanks for this library, having lots of fun playing around with it.

@gramosg gramosg linked a pull request Nov 1, 2023 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants