TSR
TSR

Reputation: 20607

Br Tag does not produce line break

Code:

import 'package:html/parser.dart';

class HtmlUtil {
  String? toPlainTxt(String htmlString) {
    final document = parse(htmlString);
    final parsedString = parse(document.body?.text).documentElement?.text;

    return parsedString;
  }
}

Input:

<p>Hello<br/><span style="color:#f00">This is colorful</span></p>

Output:

HelloThis is colorful

Expected:

Hello\nThis is colorful

Screenshot 2024-08-01 at 2 15 38 AM

What am I doing wrong?

Upvotes: 0

Views: 31

Answers (0)

Related Questions