awk or sed: how to modify based on previous and next lines : <p>I have a file like below</p>

<pre><code>* jhasjdhjh

sample1

* oioieoirer

sample2

* jsdhfjhdf
 * ppppppp
sample3
 * iouiuiouo
</code></pre>

<p>I want it to be</p>

<pre><code>* jhasjdhjh

 * sample

* oioieoirer

 * sampel2

* jsdhfjhdf
 * ppppppp
     * sample3
 * iouiuiouo
</code></pre>

<p>So sample1, sample2 we want to add  <code>*</code>  (space asteric space) since the above line and below line have <code>*</code> (asteric space)</p>

<p>sample3 we want to add        * (5 spaces and asteric)   because the previous line has (space and asteric)</p>

<p>So I have to check the previous line and the next line based on their asteric and then i have to decide what to put on the current line.</p>
