Skip to content

Commit

Permalink
Support show --tool option for markdown viewers.
Browse files Browse the repository at this point in the history
refs gh-62
  • Loading branch information
xwmx committed Sep 22, 2023
1 parent d9aabd7 commit 7407fd7
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions nb
Original file line number Diff line number Diff line change
Expand Up @@ -18827,27 +18827,30 @@ Can't show archives. Export archive and expand to edit.\\n"
{
cat "${_target_path}"
} | {
local _markdown_tool="${_tool:-${NB_MARKDOWN_TOOL:-}}"

if _contains "${_target_extension:-}" "markdown" "md" &&
_contains "${NB_MARKDOWN_TOOL:-}" \
_command_exists "${_markdown_tool:-}" &&
_contains "${_markdown_tool:-}" \
"bat" \
"glow" \
"mdcat" \
"mdless" \
"mdv"
then
if [[ "${NB_MARKDOWN_TOOL:-}" == "bat" ]]
if [[ "${_markdown_tool:-}" == "bat" ]]
then
bat --language "${_target_extension:-md}"
elif [[ "${NB_MARKDOWN_TOOL:-}" == "glow" ]]
elif [[ "${_markdown_tool:-}" == "glow" ]]
then
glow --pager
elif [[ "${NB_MARKDOWN_TOOL:-}" == "mdcat" ]]
elif [[ "${_markdown_tool:-}" == "mdcat" ]]
then
mdcat --paginate
elif [[ "${NB_MARKDOWN_TOOL:-}" == "mdless" ]]
elif [[ "${_markdown_tool:-}" == "mdless" ]]
then
mdless
elif [[ "${NB_MARKDOWN_TOOL:-}" == "mdv" ]]
elif [[ "${_markdown_tool:-}" == "mdv" ]]
then
mdv "${_target_path}" | _pager
fi
Expand Down

0 comments on commit 7407fd7

Please sign in to comment.