From b377e5d122be15711365cc01155aacb093b1dd22 Mon Sep 17 00:00:00 2001 From: William Melody Date: Mon, 5 Feb 2024 23:24:46 -0800 Subject: [PATCH] Run `pandoc` from the `` directory when present. refs gh-283 --- nb | 5 +++++ test/export.bats | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/nb b/nb index 9048b30ee..c87e4ab3d 100755 --- a/nb +++ b/nb @@ -2797,6 +2797,11 @@ _pandoc() { [[ -n "${1:-}" ]] && _pandoc_arguments+=("${@}") + if [[ -n "${_path:-}" ]] + then + cd "${_path%/*}" + fi + if _command_exists "iconv" && { ((_read_from_standard_input)) || _file_is_text "${_path:-}" } diff --git a/test/export.bats b/test/export.bats index e457947fc..d9dc9e3ac 100644 --- a/test/export.bats +++ b/test/export.bats @@ -2,6 +2,39 @@ load test_helper +# embedded resources ########################################################## + +@test "'export' with reference to image in same directory embeds image." { + { + "${_NB}" init + "${_NB}" add \ + --content "# Export Example${_NEWLINE}${_NEWLINE}![](nb.png)" \ + --filename "Example File.md" + + "${_NB}" import "${NB_TEST_BASE_PATH}/fixtures/nb.png" + + + [[ -f "${NB_DIR}/home/Example File.md" ]] + [[ -f "${NB_DIR}/home/nb.png" ]] + } + + run "${_NB}" export pandoc 1 --embed-resources <<< "y${_NEWLINE}" + + printf "\${status}: '%s'\\n" "${status}" + printf "\${output}: '%s'\\n" "${output}" + + [[ "${output}" =~ \\Export Example +

+HEREDOC + ) +} + # existing file ############################################################### @test "'export' with file at export path prompts user to confirm overwrite." {