diff --git a/nb b/nb index 1fec7d1e2..a82fd6e25 100755 --- a/nb +++ b/nb @@ -2761,6 +2761,9 @@ _pandoc() { --standard-input) _read_from_standard_input=1 ;; + -*) + _pandoc_arguments+=("${1:-}") + ;; *) _path="${1:-}" ;; @@ -2768,7 +2771,7 @@ _pandoc() { shift - [[ -n "${1:-}" ]] && _pandoc_arguments=("${@}") + [[ -n "${1:-}" ]] && _pandoc_arguments+=("${@}") if _command_exists "iconv" && { ((_read_from_standard_input)) || _file_is_text "${_path:-}" @@ -15137,15 +15140,15 @@ _export() { if [[ -n "${_args[*]:-}" ]] then _pandoc \ + "${_notebook_path}/${_relative_path}" \ -o "${_target_path}" \ --standalone \ - "${_notebook_path}/${_relative_path}" \ "${_args[@]:-}" else - _pandoc \ - -o "${_target_path}" \ - --standalone \ - "${_notebook_path}/${_relative_path}" + _pandoc \ + "${_notebook_path}/${_relative_path}" \ + -o "${_target_path}" \ + --standalone fi else cp "${_notebook_path}/${_relative_path}" "${_target_path}" diff --git a/test/export.bats b/test/export.bats index d7f47c600..1f4cd1948 100644 --- a/test/export.bats +++ b/test/export.bats @@ -157,7 +157,7 @@ load test_helper [[ "${output}" =~ sample.md ]] } -@test "'export' with valid and with different file type converts." { +@test "'export' with valid and to HTML file type converts." { { "${_NB}" init "${_NB}" add "# Export Example" @@ -176,6 +176,28 @@ load test_helper [[ "${output}" =~ example.html ]] } +@test "'export' with valid and to PDF file type converts." { + { + "${_NB}" init + "${_NB}" add --title "Export Example" + } + + run "${_NB}" export 1 "${_TMP_DIR}/example.pdf" + + printf "\${status}: '%s'\\n" "${status}" + printf "\${output}: '%s'\\n" "${output}" + + [[ -e "${_TMP_DIR}/example.pdf" ]] + [[ "$(file "${_TMP_DIR}/example.pdf")" =~ PDF\ document ]] + + # Prints output + + [[ "${lines[0]}" =~ \ +^Exported:\ .*\[.*1.*\].*\ .*export_example\.md.*\ \"Export\ Example\"$ ]] + [[ "${lines[1]}" =~ \ +^To:\ \ \ \ \ \ \ \ .*${_TMP_DIR}/example.pdf.*$ ]] +} + # `notebook` ################################################################## @test "'export notebook' with valid and exports." {