Various bugfixes

Specs: 181 total, 119 pass (with 7 overridden), 55 fail, 7 skip
This commit is contained in:
Tyler Akins 2023-04-23 10:04:59 -05:00
parent 1d4e186486
commit 0617b2ed35
No known key found for this signature in database
GPG Key ID: 8F3B8C432F4393BD

30
mo
View File

@ -517,7 +517,7 @@ mo::parseBlock() {
mo::tokensToString moTokensString "${moTokens[@]:1}" mo::tokensToString moTokensString "${moTokens[@]:1}"
mo::debug "Parsing block: $moTokensString" mo::debug "Parsing block: $moTokensString"
if mo::standaloneCheck "$MO_STANDALONE_CONTENT"; then if mo::standaloneCheck; then
mo::standaloneProcess mo::standaloneProcess
fi fi
@ -670,7 +670,7 @@ mo::parseBlockValue() {
# #
# Returns nothing # Returns nothing
mo::parsePartial() { mo::parsePartial() {
local moFilename moResult moIndentation moN moR local moFilename moResult moIndentation moN moR moTemp moT
MO_UNPARSED=${MO_UNPARSED:1} MO_UNPARSED=${MO_UNPARSED:1}
mo::trimUnparsed mo::trimUnparsed
@ -678,11 +678,19 @@ mo::parsePartial() {
MO_UNPARSED="${MO_UNPARSED#*"$MO_CLOSE_DELIMITER"}" MO_UNPARSED="${MO_UNPARSED#*"$MO_CLOSE_DELIMITER"}"
moIndentation="" moIndentation=""
if mo::standaloneCheck "$MO_STANDALONE_CONTENT"; then if mo::standaloneCheck; then
moN=$'\n' moN=$'\n'
moR=$'\r' moR=$'\r'
moT=$'\t'
moIndentation="$moN${MO_PARSED//"$moR"/"$moN"}" moIndentation="$moN${MO_PARSED//"$moR"/"$moN"}"
moIndentation=${moIndentation##*"$moN"} moIndentation=${moIndentation##*"$moN"}
moTemp=${moIndentation// }
moTemp=${moTemp//"$moT"}
if [[ -n "$moTemp" ]]; then
moIndentation=
fi
mo::debug "Adding indentation to partial: '$moIndentation'" mo::debug "Adding indentation to partial: '$moIndentation'"
mo::standaloneProcess mo::standaloneProcess
fi fi
@ -706,7 +714,7 @@ mo::parsePartial() {
# Delimiters are reset when loading a new partial # Delimiters are reset when loading a new partial
MO_OPEN_DELIMITER="{{" MO_OPEN_DELIMITER="{{"
MO_CLOSE_DELIMITER="}}" MO_CLOSE_DELIMITER="}}"
MO_STANDALONE_CONTENT="" MO_STANDALONE_CONTENT=$'\n'
mo::parse moPartialParsed "$moPartialContent" mo::parse moPartialParsed "$moPartialContent"
# Fix bash handling of subshells and keep trailing whitespace. # Fix bash handling of subshells and keep trailing whitespace.
@ -732,7 +740,7 @@ mo::parseComment() {
MO_UNPARSED=${MO_UNPARSED#*"$MO_CLOSE_DELIMITER"} MO_UNPARSED=${MO_UNPARSED#*"$MO_CLOSE_DELIMITER"}
mo::debug "Parsing comment" mo::debug "Parsing comment"
if mo::standaloneCheck "$MO_STANDALONE_CONTENT"; then if mo::standaloneCheck; then
mo::standaloneProcess mo::standaloneProcess
fi fi
} }
@ -753,7 +761,7 @@ mo::parseDelimiter() {
MO_UNPARSED=${MO_UNPARSED#*="$MO_CLOSE_DELIMITER"} MO_UNPARSED=${MO_UNPARSED#*="$MO_CLOSE_DELIMITER"}
mo::debug "Parsing delimiters: $moOpen $moClose" mo::debug "Parsing delimiters: $moOpen $moClose"
if mo::standaloneCheck "$MO_STANDALONE_CONTENT"; then if mo::standaloneCheck; then
mo::standaloneProcess mo::standaloneProcess
fi fi
@ -1240,7 +1248,7 @@ mo::evaluateFunction() {
# it on a line. There must be a new line before and there must be a newline # it on a line. There must be a new line before and there must be a newline
# after or the end of a string # after or the end of a string
# #
# $1 - The content before the tag. # No arguments.
# #
# Returns 0 if this is a standalone tag, 1 otherwise. # Returns 0 if this is a standalone tag, 1 otherwise.
mo::standaloneCheck() { mo::standaloneCheck() {
@ -1251,7 +1259,7 @@ mo::standaloneCheck() {
moT=$'\t' moT=$'\t'
# Check the content before # Check the content before
moContent=${1//"$moR"/"$moN"} moContent=${MO_STANDALONE_CONTENT//"$moR"/"$moN"}
# By default, signal to the next check that this one failed # By default, signal to the next check that this one failed
MO_STANDALONE_CONTENT="" MO_STANDALONE_CONTENT=""
@ -1344,12 +1352,14 @@ mo::indentLines() {
mo::debug "Not applying indentation, empty indentation" mo::debug "Not applying indentation, empty indentation"
local "$1" && mo::indirect "$1" "$moContent" local "$1" && mo::indirect "$1" "$moContent"
return
fi fi
if [[ -z "$moContent" ]]; then if [[ -z "$moContent" ]]; then
mo::debug "Not applying indentation, empty contents" mo::debug "Not applying indentation, empty contents"
local "$1" && mo::indirect "$1" "$moContent" local "$1" && mo::indirect "$1" "$moContent"
return
fi fi
moResult= moResult=
@ -1504,7 +1514,9 @@ mo::getContentUntilClose() {
fi fi
done done
if mo::standaloneCheck "$moResult"; then MO_STANDALONE_CONTENT="$MO_STANDALONE_CONTENT$moResult"
if mo::standaloneCheck; then
moResultTemp=$MO_PARSED moResultTemp=$MO_PARSED
MO_PARSED=$moResult MO_PARSED=$moResult
mo::standaloneProcess mo::standaloneProcess