jaspervdj / patat

Terminal-based presentations using Pandoc
GNU General Public License v2.0
2.42k stars 60 forks source link

Code block replace not working with tee when writing stdin to a file #133

Closed stark71 closed 1 year ago

stark71 commented 1 year ago

When using the tee command to write the standard input to a file in addition to being piped to a command in a code block, the code block's replace functionality doesn't work as expected.

patat:
  eval:
    tee:
      command: tee /tmp/some && do_something_with.sh /tmp/some && echo Done!
      fragment: false
      replace: true
---
# My slide

```tee
Some content
` ``
jaspervdj commented 1 year ago

The following works for me:

---
patat:
  eval:
    tee:
      command: tee ~/foo && cat ~/foo && echo done!
      fragment: false
      replace: true
...

# My slide

```tee
Some content

```

What is not working as expected? What output are you seeing?

stark71 commented 1 year ago

Thanks for your response, and for your great project.

Reading your example I just realized my error. In your example "Some content" is rendered twice, one for tee and another for cat, I forgot that tee also writes the stdin in the stdout, that's why I was getting "Some content" and "done!" and not only "done!"

Apologies.