Skip to content

Commit

Permalink
Removing string indexing #32
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmysun committed Aug 26, 2024
1 parent f0c2603 commit 22fafca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion helpers/piping.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ piping() {
else
# logging_debug "Piping: ${@}";
pipes="$(printf " | %s" "${@}")";
pipes="${pipes:3}";
pipes=$(echo "$pipes" | cut -c 4-);
bash -c "${pipes}";
fi
}
Expand Down
18 changes: 9 additions & 9 deletions plugins/syntax_highlight/50_post_llm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,19 @@ if [ "x${TO_TTY}" = "xtrue" ]; then
elif echo "x${buffer}" | grep -E -q "^x#{1,}[[:blank:]]$" >/dev/null 2>&1; then
# logging_debug "Heading mode";
printf "%s" "${STYLE_RESET}${STYLE_PUNCTUATION}${buffer%?}${STYLE_RESET}${STYLE_HEADING}";
buffer="${buffer: -1}";
buffer=$(echo "${buffer}" | awk -F '' '{print $NF}');
IN_HEADING=true;
START_OF_CONTENT=true;
elif echo "x${buffer}" | grep -E -q "^x[[:digit:]]+\.[[:space:]]$" >/dev/null 2>&1; then
# logging_debug "Ordered list";
printf "%s" "${STYLE_RESET}${STYLE_LIST}${buffer%?}${STYLE_RESET}";
buffer="${buffer: -1}";
buffer=$(echo "${buffer}" | awk -F '' '{print $NF}');
IN_LIST=true;
START_OF_CONTENT=true;
elif [ "x${buffer}" = "x* " ] || [ "x${buffer}" = "x- " ] || [ "x${buffer}" = "x+ " ]; then
# logging_debug "Unordered list";
printf "%s" "${STYLE_RESET}${STYLE_LIST}${buffer%?}${STYLE_RESET}";
buffer="${buffer: -1}";
buffer=$(echo "${buffer}" | awk -F '' '{print $NF}');
IN_LIST=true;
START_OF_CONTENT=true;
elif [ "x${buffer}" = "x>" ]; then
Expand Down Expand Up @@ -228,7 +228,7 @@ if [ "x${TO_TTY}" = "xtrue" ]; then
IN_ITALIC=true;
printf "%s" "${STYLE_RESET}${STYLE_PUNCTUATION}${buffer%?}$(current_style)";
fi
buffer="${buffer: -1}";
buffer=$(echo "${buffer}" | awk -F '' '{print $NF}');
dirty=true;
elif echo "x${buffer}" | grep -E -q "^x\*\*[^\*]$|^x__[^_]$" >/dev/null 2>&1; then
if [ "x${IN_BOLD}" = "xtrue" ]; then
Expand All @@ -240,7 +240,7 @@ if [ "x${TO_TTY}" = "xtrue" ]; then
IN_BOLD=true;
printf "%s" "${STYLE_RESET}${STYLE_PUNCTUATION}${buffer%?}$(current_style)";
fi
buffer="${buffer: -1}";
buffer=$(echo "${buffer}" | awk -F '' '{print $NF}');
dirty=true;
elif echo "x${buffer}" | grep -E -q "^x\*[^\*]$|^x_[^_]$" >/dev/null 2>&1; then
if [ "x${IN_ITALIC}" = "xtrue" ]; then
Expand All @@ -252,7 +252,7 @@ if [ "x${TO_TTY}" = "xtrue" ]; then
IN_ITALIC=true;
printf "%s" "${STYLE_RESET}${STYLE_PUNCTUATION}${buffer%?}$(current_style)";
fi
buffer="${buffer: -1}";
buffer=$(echo "${buffer}" | awk -F '' '{print $NF}');
dirty=true;
elif echo "x${buffer}" | grep -E -q "^x~~[^~]$" >/dev/null 2>&1; then
if [ "x${IN_STRIKETHROUGH}" = "xtrue" ]; then
Expand All @@ -264,7 +264,7 @@ if [ "x${TO_TTY}" = "xtrue" ]; then
IN_STRIKETHROUGH=true;
printf "%s" "${STYLE_RESET}${STYLE_PUNCTUATION}${buffer%?}$(current_style)";
fi
buffer="${buffer: -1}";
buffer=$(echo "${buffer}" | awk -F '' '{print $NF}');
dirty=true;
elif [ "x${buffer}" = "x\`" ]; then
IN_CODE=true;
Expand All @@ -275,13 +275,13 @@ if [ "x${TO_TTY}" = "xtrue" ]; then
IN_LINK_TEXT=false;
# logging_debug "Exit link text mode missing URL";
printf "%s" "${STYLE_RESET}${STYLE_PUNCTUATION}${buffer%?}$(current_style)";
buffer="${buffer: -1}";
buffer=$(echo "${buffer}" | awk -F '' '{print $NF}');
dirty=true;
elif [ "x${IN_IMAGE_TEXT}" = "xtrue" ]; then
IN_LINK_TEXT=false;
# logging_debug "Exit link text mode missing URL";
printf "%s" "${STYLE_RESET}${STYLE_PUNCTUATION}${buffer%?}$(current_style)";
buffer="${buffer: -1}";
buffer=$(echo "${buffer}" | awk -F '' '{print $NF}');
dirty=true;
else
# logging_debug "']' in the wild";
Expand Down

0 comments on commit 22fafca

Please sign in to comment.