Commit 6d1133de by Eric Coissac

Add a new methode XML_tag_attr_data

parent 9ad42bd3
......@@ -716,6 +716,12 @@ count is reached.
XML_tag_data <TAG> <VALUES>
```
#### XML_tag_attr_data
```{shell}
XML_tag_attr_data <TAG> <ATTRIBUTE 1> <VALUE 1> -- <VALUES>
```
#### XML_empty_tag
```{shell}
......
......@@ -39,14 +39,24 @@ function XML_push() {
local tag=$1
shift
local attribs="$*"
local attribs=( $(echo "$*") )
__LECABASH__XML_pad__ $(stacksize __LECABASH__markup__)
echo -n "<${tag}"
if [[ -z "${attribs}" ]] ; then
echo ">"
else
echo " ${attribs}>"
n=${#attribs[@]}
((n/=2))
if (( n > 0 )) ; then
for (( i=0; i<n; i+=1 )) ; do
k=$((i*2))
l=$((k+1))
echo -n " ${attribs[$k]}=\"${attribs[$l]}\""
shift
shift
done
fi
echo ">"
pushvalue __LECABASH__markup__ "${tag}"
}
......@@ -69,6 +79,38 @@ function XML_tag_data() {
}
function XML_tag_attr_data() {
local tag=$1
shift
local attribs=( $(echo "$*") )
__LECABASH__XML_pad__ $(stacksize __LECABASH__markup__)
echo -n "<${tag}"
n=${#attribs[@]}
((n/=2))
if (( n > 0 )) ; then
for (( i=0; i<n; i+=1 )) ; do
k=$((i*2))
l=$((k+1))
if [[ "${attribs[$k]}" != "--" ]] ; then
echo -n " ${attribs[$k]}=\"${attribs[$l]}\""
shift
else
i="$n"
fi
shift
done
fi
echo ">$*</${tag}>"
}
function XML_empty_tag() {
local tag=$1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment