Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Remove 'Output' string #11

Closed
igormcoelho opened this issue Aug 7, 2020 · 4 comments · Fixed by #12
Closed

Remove 'Output' string #11

igormcoelho opened this issue Aug 7, 2020 · 4 comments · Fixed by #12

Comments

@igormcoelho
Copy link
Contributor

congratulations for this useful filter @shoeffner ... I've been using it a lot on https://github.com/igormcoelho/ilectures-pandoc project!

I guess 'Output' string is highly undesired... on my local file I just removed it. Do you think it's useful in any situation? If that's useful for something, maybe a flag to remove it would be quite nice.

Just to mention that my use-cases involve generating side images, that are directly embedded on pandoc output... Other issues with 'Output' is that it refers to English, but my output is not English :)

@shoeffner
Copy link
Owner

shoeffner commented Aug 8, 2020 via email

@igormcoelho
Copy link
Contributor Author

Thanks for the attention @shoeffner , I can propose the PR :) Congratulations again.

@igormcoelho
Copy link
Contributor Author

Some examples (on vscode markdown-preview-enhanced):
image

Output on pdf beamer:
image

Source on markdown (four options and extra slash to prevent github preview):

\```{.python .exec cmd='codes/run_python3.sh'} 
print("Hello World!")
\```

\```{.python .exec cmd='codes/run_python3.sh' output_label='Saída:'} 
print("Olá Mundo! (with portuguese label)")
\```

\```{.python .exec cmd='codes/run_python3.sh' output_label=''} 
print("Hello World! (no label)")
\```

\```{.python .exec cmd='codes/run_python3.sh' output_label='' .hide} 
print("Output with source hidden and no label above")
\```

@igormcoelho
Copy link
Contributor Author

Just to register my crazy run_python3.sh script, that makes it possible to have same behavior on vscode plugin markdown-preview-enhanced and this one here... maybe some day in the future, one of both could change, I don't know which hahaha
Anyway:

#!/bin/bash

#echo "Arguments: $# -> $@"

CMD=/usr/bin/python3

if [ $# -eq 0 ]; then
   echo "" # nothing to do
else
  #echo "ARG0: $0"
  #echo "ARG1: $1"
  #if [ -z "$1" ]; then echo "EMPTY"
  #fi
  #echo "ARG2: $2"
  # check if last argument is file
  if [ ! -f "${@: -1}" ]; then
    #echo "INVOKING $CMD FOR CODE: $@"
    echo "$@" | $CMD  # just 'echo' all
  elif [ -z "$1" ]; then
    #echo "EMPTY CODE! JUST RUN: $CMD ${@:2}"
    $CMD "${@:2}" # skip first empty argument
  else
    #echo "INVOKING $CMD ${@:1:$(($#-1))} FOR FILE: ${@: -1}"
    cat "${@: -1}"  | $CMD "${@:1:$(($#-1))}" # all but last
  fi
fi

#"${@:1:$(($#-1))}"
#`dirname $0`/cat_echo.sh "$@" | /usr/bin/python3

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants