Justify and/or Hyphenate Plain Text

R

Roy Schestowitz

This may be somewhat unrelated to this group, but I can't think of where
else it fits. Is it possible to take text such as the text I am composing
at the very moment and then, given some value of width, fit it to a rect-
angular block where both justification (using space insertion) and hyphe-
nation (a la LaTeX) are determined wisely? I can think of possible
issues such as spellchecking and indexing, but they don't appear to deter
me much.

Many thanks,

Roy
 
T

Toby Inkster

Roy said:
Is it possible to take text such as the text I am composing at the very
moment and then, given some value of width, fit it to a rectangular
block where both justification (using space insertion) and hyphenation
(a la LaTeX) are determined wisely?

In text/plain or text/html?
 
R

Roy Schestowitz

__/ [Toby Inkster] on Sunday 16 October 2005 19:07 \__
In text/plain or text/html?

Just text would do. If I was ever to use that, it would serve UseNet
postings. I simply seek a small (and of course free as in beer) tool that
can do the simple task. Space insertion is simple, so hyphenation would be
a plus...

Many thanks in advance if you can suggest something, Toby. If nothing
exists, I might have to write my own, but I would rather not.

Roy
 
R

rossz

Roy said:
This may be somewhat unrelated to this group, but I can't think of where
else it fits. Is it possible to take text such as the text I am composing
at the very moment and then, given some value of width, fit it to a rect-
angular block where both justification (using space insertion) and hyphe-
nation (a la LaTeX) are determined wisely? I can think of possible
issues such as spellchecking and indexing, but they don't appear to deter
me much.

Automagically, not really. You can manually insert the soft hyphen
(­) into your document. IE and Opera support it, Firefox as of 1.04
does not. I have not tested it on a recent version of Firefox.

It is conceivable to write a script (perl or php) that takes text input
and spits it out with soft hyphens embedded. I remember there being
some basic rules for hyphenation, with a small list of exceptions for
words that did not fit into the rules.
 
R

rossz

rossz said:
Automagically, not really. You can manually insert the soft hyphen
(­) into your document. IE and Opera support it, Firefox as of 1.04
does not. I have not tested it on a recent version of Firefox.

I just did a test. Soft hyphens are still not supported in Firefox 1.0.7.
 
R

Roy Schestowitz

__/ [rossz] on Monday 17 October 2005 06:58 \__
Automagically, not really. You can manually insert the soft hyphen
(­) into your document. IE and Opera support it, Firefox as of 1.04
does not. I have not tested it on a recent version of Firefox.

It is conceivable to write a script (perl or php) that takes text input
and spits it out with soft hyphens embedded. I remember there being
some basic rules for hyphenation, with a small list of exceptions for
words that did not fit into the rules.

===

I just did a test. Soft hyphens are still not supported in Firefox 1.0.7.

I am sorry to be such a disappointment, but perhaps I was not explicit
enough as to what I was trying to apply this to and what I sought to
achieve. I imagined that the subject line would be a good clarification,
but the context (newsgroup) evaded me.

I am hoping to be able to apply this method to text such as that which I
write in this very message, i.e. simple and plain ASCII. I want to have a
little tool that will take as input this text and give me something that
appears nicer in terms of layout.

Roy
 
T

Toby Inkster

Roy said:
Many thanks in advance if you can suggest something, Toby. If nothing
exists, I might have to write my own, but I would rather not.

For a moment I though /usr/bin/fmt might do it, but it appears not.

I think you may have to write your own script, but most of the tricky
stuff has already been done for you. Perl's Text::Hyphenate followed by
Text::Format ought to do it.
 
J

Jukka K. Korpela

Roy Schestowitz said:
I am sorry to be such a disappointment, but perhaps I was not explicit
enough as to what I was trying to apply this to and what I sought to
achieve. I imagined that the subject line would be a good
clarification, but the context (newsgroup) evaded me.

Well, your question was completely off-topic. Many people in alt.html
understand this as a catchall group, but that's rather unconstructive.
A group for anything isn't suitable for anything.
I am hoping to be able to apply this method to text such as that which
I write in this very message, i.e. simple and plain ASCII.

So why don't you try and find a group that discusses such matters? The
group comp.text comes into my mind. Of course, you would need to explain
your problem and situation clearly there, in order to get useful answers.
You haven't even told anything about the environment (BSD or System V
UNIX?).
I want to
have a little tool that will take as input this text and give me
something that appears nicer in terms of layout.

You would need to define "little", "nicer", and "layout". But there are
surely programs that do such things - they have existed for decades, long
before HTML was invented. Justification of plain text was found to be bad
idea long ago, but surely there is software for it.
 
R

Roy Schestowitz

__/ [Jukka K. Korpela] on Monday 17 October 2005 12:21 \__
Well, your question was completely off-topic. Many people in alt.html
understand this as a catchall group, but that's rather unconstructive.
A group for anything isn't suitable for anything.


You're quite right, but I see this newsgroup as somewhat of a community with
content composition skills. I don't just see it as a very narrow and
focused group where posts can end up reaching a point of complete halt. But
overall, I agree, I should have been more selective.

So why don't you try and find a group that discusses such matters? The
group comp.text comes into my mind. Of course, you would need to explain
your problem and situation clearly there, in order to get useful answers.
You haven't even told anything about the environment (BSD or System V
UNIX?).


What I had in mine is just some simple C (or equiv.) function that I can
compile regardless of the platform. Introduction of the O/S did not appear
to me as a necessity.

You would need to define "little", "nicer", and "layout". But there are
surely programs that do such things - they have existed for decades, long
before HTML was invented. Justification of plain text was found to be bad
idea long ago, but surely there is software for it.


Thanks, I'll carry on looking.

Roy
 
R

Roy Schestowitz

__/ [Roy Schestowitz] on Sunday 16 October 2005 18:57 \__
This may be somewhat unrelated to this group, but I can't think of where
else it fits. Is it possible to take text such as the text I am composing
at the very moment and then, given some value of width, fit it to a rect-
angular block where both justification (using space insertion) and hyphe-
nation (a la LaTeX) are determined wisely? I can think of possible
issues such as spellchecking and indexing, but they don't appear to deter
me much.

Many thanks,

Roy


Got it!! Works beautifully too and use the TeX modules...

Project homepage: http://freshmeat.net/projects/paradj/

First test run:

roy@BAINE:~/Desktop/paradj> echo 'lskdfhsjdfbjsdbfsdhfidsjfodshfds nfi
dysou;f udsidf hjdsfkdsfvbids fisyd fiuds fuyds fguods fgousd djs hfuds
fugds hfuhsd fvjsd foidsfgodsu fioshg fds if' >1

roy@BAINE:~/Desktop/paradj> perl paradj.pl --width=40 -h -r 1
lskdfhsjdfbjsdbfsdhfidsjfodshfds nfi
dysou;f udsidf hjdsfkdsfvbids fisyd fi-
uds fuyds fguods fgousd djs hfuds fugds
hfuhsd fvjsd foidsfgodsu fioshg fds if

Thanks for your input, Toby. You had me look a little more closely into
Perl.

There are also Python equivalent(s):

tp://freshmeat.net/projects/pyhnj/


Roy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top