Skip to content

Commit

Permalink
Run pandoc from the <path> directory when present.
Browse files Browse the repository at this point in the history
refs gh-283
  • Loading branch information
xwmx committed Feb 6, 2024
1 parent 9c36d06 commit b377e5d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
5 changes: 5 additions & 0 deletions nb
Original file line number Diff line number Diff line change
Expand Up @@ -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:-}"
}
Expand Down
33 changes: 33 additions & 0 deletions test/export.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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}" =~ \<p\>\<img\ src=\"data:image/png\;base64,iVBORw0KGgoAAAA ]]

run ! diff \
<(printf "%s\\n" "${output}") \
<(cat <<HEREDOC
[WARNING] Could not fetch resource nb.png
<h1 id="export-example">Export Example</h1>
<p><img src="nb.png" /></p>
HEREDOC
)
}

# existing file ###############################################################

@test "'export' with file at export path prompts user to confirm overwrite." {
Expand Down

0 comments on commit b377e5d

Please sign in to comment.