Jump to content

Line Unbreaker


Recommended Posts

Posted (edited)

*poke*

 

Hello, moderators, please feel free to move this somewhere else if this is an inappropriate place for this :)

I swear that every forum has a different infrastructure that is armed with vicious, psychopathic, blood-sucking, Edward-loving cannibal-moderators that feast on new posters if their infrastructure is not followed @_@

 

Some sites, for example, Nifty, remove a lot of the formatting when works from non .pdf/html are uploaded. Notably, they insert a rather annoying line break about 75 columns in. If you wanted to change the appearance of your work (editing) and you don't have a backup, or you are a reader who wants to change fonts or what have you, upon copying and pasting the normal nifty text you get this or something like it if you try to change font size or whatever...

Before

 

And if you try to reduce the size of the front, alas, you'll still notice ugly line breaks... if you read from notepad... it looks fine (somewhat)... but not really.

I found many solutions to this annoyance, everything from perl to python to Microsquash Word's find and replace feature (which is kind of boinked imo). The best solution however was JS.

After going to text fixer and reviewing their JS, I removed the "junk" and made the line unbreaking as neat and tidy as possible.

This is what the text can look like after line unbreaking. ignore the special bookmarks *shifty*

 

This is accomplished through NALUBR, guess what it stands for? :o

 

*unshifty*

 

NALUBR is easy to use, it requires Java and a java compatible browser (most people already have this). It is packaged in a zip in the above download link... extract it somewhere and run the .htm file and a popup will popup :P

Don't worry, there are no viruses -_- nor do I redirect you any websites, I provided the code below if you are one of those computer mysophobes.

 

The browser window will then have two boxes, one is the input box, where you input your messed up text. Hit the pretty button and copy and paste to your text document. The advanced button is for those who wish to remove paragraphs too... which ends in a jarbled text orgy that only Ron Jeremy would appreciate... while there are times where this is useful, use the recommended feature.

 

:)

 

While Gay Authors does not need this feature... (no annoying line breaks! yay!) some sites do. I hope somebody finds this useful. I hope to expand NALUBR to something a lot more useful in the feature, but alas (who am I... a pirate?), being a gay undergraduate wannabe physicist doesn't allot a huge amount of time (alright, fine, a gay undergraduate wannabe pirate physicist).

 

For those interested in the code,

 

 

<html>
	<head>
		<title>Nifty Archives Line Unbreaker</title>
			<script type="text/javascript" src="remove-line-breaks.php_files/remove-line-breaks.js">
			</script>
	</head>
	<body>

	<form method="post" action="remove-line-breaks.php" class="online-tools">

<h2>Nifty Archive Line Unbreaker</h2>
		<p class="flat"><input id="paragraphs"  name="paragraphs" value="yes" checked="checked"  type="radio">Recommended</p>
		<p class="flat"><input id="noparagraphs" name="paragraphs" value="no" type="radio">Advanced</p>
		<p>
		<textarea id="oldText" name="oldText" rows="8" cols="60"></textarea>
		</p>
		<p>
		<input name="Remove-Line-Breaks" value="Remove Line Breaks"  onclick="javascript:removeBreaks()" class="frmbtn" type="button">
		</p>
		<p>
		<textarea id="newText" name="newText" rows="8" cols="60"  onclick="javascript:this.form.newText.focus();this.form.newText.select();"></textarea>  
		</p>
	</form>
</html>

 

 

 

function removeBreaks(){

var para = document.getElementById("paragraphs").checked;
var nopara = document.getElementById("noparagraphs").checked;
var noBreaksText = document.getElementById("oldText").value;

noBreaksText = noBreaksText.replace(/(\r\n|\n|\r)/gm,"<1br />");

re1 = /<1br \/><1br \/>/gi;
re1a = /<1br \/><1br \/><1br \/>/gi;

if(nopara == 1 || nopara ==  true){
noBreaksText = noBreaksText.replace(re1," ");
}else{
noBreaksText = noBreaksText.replace(re1a,"<1br /><2br />");
noBreaksText = noBreaksText.replace(re1,"<2br />");
}

re2 = /\<1br \/>/gi;
noBreaksText = noBreaksText.replace(re2, " ");

re3 = /\s+/g;
noBreaksText = noBreaksText.replace(re3," ");

re4 = /<2br \/>/gi;
noBreaksText = noBreaksText.replace(re4,"\n\n");
document.getElementById("newText").value = noBreaksText;
}

 

 

*end poke*

Edited by Cerest

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...