Preserving spacing and whitespace

B

burchill

I am writing a program that will convert guitar tablature text files
into html files.

The biggest stumbling block is that html doesn't preserve spacing of a
txt file. Is there a tag that will preserve the spacing of the text
inside it ?

Any help appreciated.
 
E

Els

burchill said:
I am writing a program that will convert guitar tablature
text files into html files.

The biggest stumbling block is that html doesn't preserve
spacing of a txt file. Is there a tag that will preserve
the spacing of the text inside it ?

<pre></pre>
 
T

The Doormouse

burchill said:
The biggest stumbling block is that html doesn't preserve spacing of a
txt file. Is there a tag that will preserve the spacing of the text
inside it ?

No, but you could try CSS or even SVG.

The Doormouse
 
J

Jukka K. Korpela

Deryck said:

Huh? The example is

<pre>

text file stuff here
complete with line breaks and things.

</pre>

and the page has little useful content - it has a very sloppy description
of the "HTML <PRE> tag", followed by user comments that range from mostly
pointless to absurd (including the use of invalid markup).

However, <pre> element _might_ be a solution, but it's best to learn to
use it from some nice tutorial or reference.

Moreover, this might even be a case for using Ruby markup. But I know
virtually nothing about guitars, so I can't really tell.
 
J

Jeffrey Silverman

No, but you could try CSS or even SVG.

The Doormouse

I'm sorry, Doormouse, but that advice doesn't even make sense, *or*
answser the question. SVG to preserve spacing in a text file??

I realize that at this point I appear to be merely pestering you for no
reason other than your lackluster response to my post in another, similar,
newsgroup.

But at this time I'd like to see you refrain from giving advice or
answering questions until you at least have a bit more correct
information. Your posts are often not correct, or just shy of
being quite correct. And you come close to trolling more often than not.

okay, later, have a nice day.
 
N

Neal

Huh? The example is

<pre>

text file stuff here
complete with line breaks and things.

</pre>

and the page has little useful content - it has a very sloppy description
of the "HTML <PRE> tag", followed by user comments that range from mostly
pointless to absurd (including the use of invalid markup).

However, <pre> element _might_ be a solution, but it's best to learn to
use it from some nice tutorial or reference.

I'm sure Jukka would have provided
http://www.w3.org/TR/html401/struct/text.html#edef-PRE had he had enough
time. Good thing I do.
 
D

Deryck

Jukka K. Korpela said:
Huh? The example is

<pre>

text file stuff here
complete with line breaks and things.

</pre>
Oh very well....the example is introduced to the reader as a solution to a
problem that involves a guitar tab in text format - which is pretty much
what the OP was trying to solve.

" Say you have a text file - perhaps you're a guitarist and you've got a
guitar tab in text format, or perhaps you have a text-based email document
you want to put quickly online. Do you have to go through all the bother of
adding <BR> and spacing it all out correctly?
"

Forgive me for not being more precise in my text that followed the link that
would solve the OP's problem.

Cheers

Deryck
 
T

Toby Inkster

Jukka said:
Moreover, this might even be a case for using Ruby markup. But I know
virtually nothing about guitars, so I can't really tell.

IIRC, Ruby only allows three lines of concurrant text. Guitar tabs need at
least 6 (one for each string, then perhaps a line for lyrics and maybe one
for chords)

<pre> is what the OP wants.
 
B

burchill

Toby said:
Jukka K. Korpela wrote:




IIRC, Ruby only allows three lines of concurrant text. Guitar tabs need at
least 6 (one for each string, then perhaps a line for lyrics and maybe one
for chords)

<pre> is what the OP wants.

Thanks all, PRE does indeed seem to work.
 
T

The Doormouse

Jeffrey Silverman said:
I'm sorry, Doormouse, but that advice doesn't even make sense, *or*
answser the question. SVG to preserve spacing in a text file??

I know, it looks confusing, but:

Illustrator can output SVG, which is ideal for line art (in other words,
your music sheets, text and notation) and -

If I was going to display music sheets on the internet, my first thought
would be to lay out the design in Illustrator. Cut and paste the original
file direct into Illy. From Illy, I could output a SVG graphic of the
musical sheet. Illy can also output HTML instead - or GIF files, or both.
Whatever. Or, make a PDF using Illy. The PDF will certainly keep the
spacing.

Now you have three options for maintaining the spacing from just one
original using a simple cut and paste operation. Plus, the results will
But at this time I'd like to see you refrain from giving advice or
answering questions until you at least have a bit more correct
information.

Please review my response above. I have delivered three graphical
solutions for turning a text document into perfect output.
Your posts are often not correct, or just shy of
being quite correct.

My posts are often not what you expect. :)

Use <pre> if you want, but it's so crude ...

The Doormouse
 
T

The Doormouse

Another solution is to generate the SVG dynamically. Since SVG is really
just XML, a good programmer might be able to do this.

SVG requires a plugin to use, though.

Almost everyone can view PDF's.

The Doormouse
 
R

rf

The said:
Another solution is to generate the SVG dynamically. Since SVG is really
just XML, a good programmer might be able to do this.

Have you ever *looked* at a guitar tab? Most people who write them use
notepad or a similar text editor. They are strictly monospaced ascii files.
There is no "music" as such in them, no staffs, no clefs, no notes, no
rests. There *are* bars though. They are designed specifically to represent
music in ascii, sort of like ascii art. As such they print very nicely. How
does SVG adapt to printing?
SVG requires a plugin to use, though.
Yes.

Almost everyone can view PDF's.

Not without the plug in, which is required to view PDFs.

*Everyone* can view <pre> elements. Even people with text browsers.
 
T

The Doormouse

rf said:
Have you ever *looked* at a guitar tab?

Once, "Puff The Magic Dragon" on two sheets, bought at a music store. It's
a very sad song, one of my favorites.

All I have ever seen is store-bought sheet music, and made the reasonable
assumption that he would be generating something similar in HTML using the
text file as a guide.

After a 30-second search on the internet I found what hand-typed guitar
tabs look like. The tabulature that I saw was spaced using "-" signs.

Now I see what you guys are trying to suggest as a solution and why you are
all so incredulous at my suggestions. I would like to make "art", like
professional sheet music. You all just want something that resembles the
text file format.

My suggestion would be prettier, yours are more functional.

*shrug*

FWIW, Harmonica notation is its own beast, too. Haven't touched one in
years.

The Doormouse
 
N

Neal

My suggestion would be prettier, yours are more functional.

And functional is well in the spirit of semantic HTML, where the
presentation is separate from the content. Aside from the ASCII-style
tabs, the best way to do it is images.

As a professional musician, I wish there was a really convenient way to
display notation in HTML. Sadly, that's likely not to be possible in my
lifetime, unless all musicians can get a Finale-like plugin to view a
notated page.
 
R

rf

The said:
After a 30-second search on the internet I found what hand-typed guitar
tabs look like. The tabulature that I saw was spaced using "-" signs.

Now I see what you guys are trying to suggest as a solution and why you are
all so incredulous at my suggestions. I would like to make "art", like
professional sheet music. You all just want something that resembles the
text file format.

Yep. That's the idea.

It looks odd the first time you see one, nothing like "real" music. However,
after a bit of practice it is as easy to read as real music. Easier in some
ways. Those numbers in a vertical column "look" like chords more than a real
music chord does. It is virtually a "picture" of the guitar music in three
dimensions: across the frets; up the neck; and time. Real music is only two
dimensional: the notes of the chromatic scale: and time.

It's useless for anything other than guitar though (or other such stringed
instruments).
 
W

WebcastMaker

FWIW, Harmonica notation is its own beast, too. Haven't touched one in
years.

Cross-harp. The only way to play harmonica. No training needed, but
you instantly sound like a pro...
 
J

Jeffrey Silverman

I know, it looks confusing, but:

Illustrator can output SVG, which is ideal for line art (in other words,
your music sheets, text and notation) and -

If I was going to display music sheets on the internet, my first thought
would be to lay out the design in Illustrator. Cut and paste the original
file direct into Illy. From Illy, I could output a SVG graphic of the
musical sheet. Illy can also output HTML instead - or GIF files, or both.
Whatever. Or, make a PDF using Illy. The PDF will certainly keep the
spacing.

Now you have three options for maintaining the spacing from just one
original using a simple cut and paste operation. Plus, the results will
be visually superior to <pre>, although <pre> will work.

While I agree that SVG is a potentially good format, it has even less
general support than, say, PNG.

Why are you so big on SVG? You are contradicting yourself. No, really,
you are. SVG is promising, but so was VRML (at least, acc. to the
proponents of VRML). Where is VRML?

Also, can Illustrator *import* SVG? It seems to me that for SVG to become
truly feasible as a vector format, then the premier vector illustration
program, Adobe Illustrator (which I happen to think kicks ass and is the
*only* reason I keep a Windows partition around) ought to be able to
*read* SVG files. Admittedly, last time I checked was Illustrator 9,
which, AFAIK, could not read SVG files. How about 10? Or that new one,
whatever it is called -- QP? XL? DM? I dunno, some set of letters, I think.

Although truthfully, if I were going to create sheet music for the Web, I
would never use Illustrator! I would use a sheet music creation tool of
which there are several, and which also export PDF format sheet music.

Allright, later...
 
T

The Doormouse

Jeffrey Silverman said:
While I agree that SVG is a potentially good format, it has even less
general support than, say, PNG.

Why are you so big on SVG? You are contradicting yourself. No,
really, you are.
*sigh*

SVG is promising, but so was VRML (at least, acc. to
the proponents of VRML). Where is VRML?

My biggest objection to PNG is that you can get very similar
functionality from more common, 100% universal formats. The only vector
based alternative to SVG is SWF (Flash). I would have suggested SWF,
except that it also requires a plugin. More people may have that plugin,
so SWF would work, too.

So you see, you perceived a contradiction because I did not support PNG -
but the circumstances are different. If you know of a plugin-free, vector
based format that is not SWF nor SVG, and is 100% universal like JPEG or
GIF, then please share.

I am "big on SVG" because it is XML-based and open source. You could/can
script SVG on the fly. Its usage will only grow. Adobe supplies the best
free SVG plugin for the most common browser (IE6).

I am not sure if Javascript could be used to make an SVG graphic that
displayed the guitar tabs based on text input, but it might.
Also, can Illustrator *import* SVG?

Yes, but not all SVG files.
See the Illy CS feature description.
Although truthfully, if I were going to create sheet music for the
Web, I would never use Illustrator! I would use a sheet music creation
tool of which there are several, and which also export PDF format
sheet music.

Soemtiems trying to find a free tool is more trouble than it is worth. If
you had Illy, and could not find soemthing cheap ... Illy looks good for
the task.

The Doormouse
 
J

Jeffrey Silverman

My biggest objection to PNG is that you can get very similar functionality
from more common, 100% universal formats. The only vector based
alternative to SVG is SWF (Flash). I would have suggested SWF, except that
it also requires a plugin. More people may have that plugin, so SWF would
work, too.

Not to reopen this can-of-worms thread again, but your perceived support
for PNG format is wrong. PNG is *widely* supported!!

http://www.libpng.org/pub/png/pngapps.html

You can use PNG images for all images on all websites and most surfers
will not know the difference! The *only* not-widely-supported feature is
alpha transparency.

Yes, but not all SVG files.
See the Illy CS feature description.


Soemtiems trying to find a free tool is more trouble than it is worth. If
you had Illy, and could not find soemthing cheap ... Illy looks good for
the task.

I never said "free" tool. I said "sheet music creation tool". Illustrator
is a very poor choice for laying out sheet music!
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top