Voltage gain of an Emitter Follower
With simple algebra, from \$(5.317)\$ you get:
$$
v_\pi=\frac{v_{out}}{R_E}\frac{r_\pi}{g_mr_\pi+1}
$$
Now:
$$
\beta\triangleq\frac{i_c}{i_b}\\
i_b=\frac{v_\pi}{r_\pi}\\
i_c=g_mv_\pi\\
\implies \beta=g_mv_\pi\frac{r_\pi}{v_\pi}=g_mr_\pi
$$
And plugging this result in the first equation you get \$(5.318)\$:
$$
v_\pi=\frac{v_{out}}{R_E}\frac{r_\pi}{\beta+1}
$$