diff options
Diffstat (limited to 'app/assets/javascripts/static_site_editor/services/formatter.js')
-rw-r--r-- | app/assets/javascripts/static_site_editor/services/formatter.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/assets/javascripts/static_site_editor/services/formatter.js b/app/assets/javascripts/static_site_editor/services/formatter.js new file mode 100644 index 00000000000..92d5e8a5df8 --- /dev/null +++ b/app/assets/javascripts/static_site_editor/services/formatter.js @@ -0,0 +1,14 @@ +const removeOrphanedBrTags = source => { + /* Until the underlying Squire editor of Toast UI Editor resolves duplicate `<br>` tags, this + `replace` solution will clear out orphaned `<br>` tags that it generates. Additionally, + it cleans up orphaned `<br>` tags in the source markdown document that should be new lines. + https://gitlab.com/gitlab-org/gitlab/-/issues/227602#note_380765330 + */ + return source.replace(/\n^<br>$/gm, ''); +}; + +const format = source => { + return removeOrphanedBrTags(source); +}; + +export default format; |