VisualSystemsCorp / vsc_quill_delta_to_html

MIT License
18 stars 13 forks source link

Trim content #30

Open loveoverflowdev opened 16 hours ago

loveoverflowdev commented 16 hours ago

How can I strip or trim HTML content to remove
tags and whitespace at the beginning and end?

dsyrstad commented 14 hours ago

@loveoverflowdev There are several ways to manipulate the generated html depending on what you want to do. There are a number of configuration options that can help with this - see README.md and https://github.com/VisualSystemsCorp/vsc_quill_delta_to_html/blob/9c4b1ca8306d8772001caa997d7aa8fc0435e677/lib/src/quill_delta_to_html_converter.dart#L16

You can also parse the generated html using https://pub.dev/packages/html, manipulate the DOM, and then regenerate the html string.

If you want to add tags or whitespace around the generated html, it is a string, so you can simply add text to it. See https://github.com/VisualSystemsCorp/vsc_quill_delta_to_html/blob/9c4b1ca8306d8772001caa997d7aa8fc0435e677/example/lib/main.dart#L269 and https://github.com/VisualSystemsCorp/vsc_quill_delta_to_html/blob/9c4b1ca8306d8772001caa997d7aa8fc0435e677/example/lib/main.dart#L309 for examples.