= Exercise 5.12
// Refs:
:url-base: https://github.com/fenegroni/TGPL-exercise-solutions
:workflow: workflows/Exercise 5.12
:action: actions/workflows/ch5ex12.yml
:url-workflow: {url-base}/{workflow}
:url-action: {url-base}/{action}
:badge-exercise: image:{url-workflow}/badge.svg?branch=main[link={url-action}]
{badge-exercise}
The `startElement` and `endElement` functions in
`gopl.io/ch5/outline2` (_Section 5.5_)
share a global variable, `depth`.
Turn them into anonymous functions that share a variable
local to the `outline` function.
== Test
We first write the test for outline to validate
the original implementation from the book works.
Then we make the code testable.
We factor out the URL processing part of `outline` into `outlineURL`,
and test again.
Finally, we move `startElement`, `endElement` and `depth` into `outline`.