Road-Length Encoding
JavaScript (ES6), 114
Using  template strings, the 5 linefeeds are significant are must be counted.
f=s=&gt;(b=(s=s.replace(/(\d+)(.)/g,(x,n,b)=&gt;(b&lt;'P'?'=':'- ').repeat(n).slice(0,n))).replace(/./g,'_'))+`
   

${s}

`+b