Apply style to the first line after \ n

1

I have a textarea that would receive a text. The style application will be minimal, so I did not want to use some editor like CKEditor, for example. I believe the easiest way to work is to apply a style to the item /n

I'll be getting text like this:

Iwouldlikeittolooklikethis:

    
asked by anonymous 26.01.2015 / 15:04

1 answer

3

You may be using CSS ::first-line Selector

Example:

div::first-line {
        font-weight: bold;
    }
    <div>
    Lorem ipsum dolor sit amet,consectetur adipiscing elit. <br />
    Vestibulum erat velit, aliquet at mattis a, tristique ac mauris. <br />
    Quisque et neque quis lectus consequat ornare ut eu augue. <br />
    Praesent sapien massa, <br />
    </div>

    <div>
    Faucibus sed viverra a, ultrices eget velit. <br />
    Aliquam euismod ante eu est tempor posuere. <br />
    Duis semper sodales ligula, et lacinia libero iaculis ac. <br />
    Duis at elementum diam. Sed lectus justo, <br />
    Malesuada eget scelerisque vitae, ullamcorper eget enim. <br />
    Nulla vitae turpis luctus, consectetur velit non, mattis lorem. <br />
    </div>

Assuming that the text with \n looks like this:

    Lorem ipsum dolor sit amet,consectetur adipiscing elit. \n
    Vestibulum erat velit, aliquet at mattis a, tristique ac mauris. \n
    Quisque et neque quis lectus consequat ornare ut eu augue. \n
    Praesent sapien massa, \n \n
    Faucibus sed viverra a, ultrices eget velit.\n
    Aliquam euismod ante eu est tempor posuere. \n
    Duis semper sodales ligula, et lacinia libero iaculis ac.\n
    Duis at elementum diam. Sed lectus justo, \n
    Malesuada eget scelerisque vitae, ullamcorper eget enim.\n
    Nulla vitae turpis luctus, consectetur velit non, mattis lorem.\n

You will have to treat \n .

if(!String.IsNullOrEmpty(texto)){
     texto = texto.Insert(0, "<div>");
     texto = texto.Replace("\n \n", "</div><div>");
     texto = texto.Insert(texto.Length, "</div>");
     texto = texto.Replace("\n", "<br />");
}

Example

    
26.01.2015 / 15:34