Python tutorial: Splitting method to solve overlapping position problem
<p>My goal is to split the overlapping positions for use in HTML. For example, I have this text: </p>
<blockquote>
<p>One Two Three</p>
</blockquote>
<p>I want the second and third words to be bold, and the first two words to be italicized. We get this result:</p>
<pre class="brush:php;toolbar:false;">[
{ "start": 4, "end": 13, "markup": "BOLD" },
{ "start": 0, "end": 7, "markup": "ITALIC" }
]</pre>
<p>If we wish to apply HTML tags by position, we get this result: </p>
<pre class="brush:php;toolbar:false;"><bold>One <em>Two</bold> Three</em></pre>
<p>See the overlap? <code><em></code>the opening tag is interrupted by the <code></bold></code>closing tag. It should look like this:</p>
<pre class="brush:php;toolbar:false;"><bold>one<em>two</em></bold><em>three</em></ pre>
<p>and location: </p>
<pre class="brush:php;toolbar:false;">[
{ "start": 4, "end": 7, "markup": "BOLD" },
{ "start": 7, "end": 13, "markup": "BOLD" },
{ "start": 0, "end": 7, "markup": "ITALIC" }
]</pre>
<p>P.S. Don't worry about the original position changing after applying the markup. I wrote a good solution. </p>
<p>I tried to implement some solutions but it seems to be a difficult task for me. </p>