Skip to content
This repository was archived by the owner on Oct 28, 2022. It is now read-only.

Commit 14bf599

Browse files
committed
Fix newline formatting and make textarea 300px when clicked
1 parent 1d34fc5 commit 14bf599

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

javascript.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ sf.init = function() {
175175
// A somewhat messy solution, but it is fine.
176176
if (event.target.parentElement.children[0].id !== "formatter") {
177177
event.target.parentElement.prepend(sf.formatter);
178+
event.target.style.height = "250px";
178179
sf.formatter.style.width = event.target.offsetWidth + "px";
179180
event.target.style.resize = "auto";
180181
}
@@ -282,7 +283,8 @@ sf.parse = function(text) {
282283
}
283284

284285
// Format trailing breaklines and spaces
285-
text = text.replace(/^(\n| )+/gm, "");
286+
text = text.replace(/(\n)+^/m, ""); // Remove start newlines
287+
text = text.trim("\n"); // Trim last newlines
286288

287289
text = sf.parseMD(text);
288290

0 commit comments

Comments
 (0)