Welcome Guest.   Make a donation to an author on the site September 18, 2014, 04:40:15 AM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Learn about the DonationCoder.com microdonation system (DonationCredits).
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: Parsing of Fortune Files  (Read 8980 times)
transitionality
Participant
*
Posts: 9

View Profile Give some DonationCredits to this forum member
« on: July 16, 2008, 07:18:35 AM »

I am having some trouble with the parsing of fortune files.

First off, I note that I like to have a blank line separating the quote from the speaker, as follows:

Quote
"The time you enjoy wasting is not wasted time."

-- Bertrand Russell

%

.....

However, Popup Wisdom displays such formatting as follows:

Quote
"The time you enjoy wasting is not wasted time."
-- Bertrand Russell

So I tried putting a space on the blank line separating the quote from the speaker.

Quote
"The time you enjoy wasting is not wasted time."
(there's one space here)
-- Bertrand Russell

%

.....

But Popup Wisdom displays such a quote as follows:

Quote
"The time you enjoy wasting is not wasted time."
 -- Bertrand Russell

In other words, it ignores the line with the single space on it, and concatenates the space with the content of the line following it, displaying the result on one line.

Now, I know that I can always try and convert my quotes file to Popup Wisdom's own format to get the precise formatting that I want, but that's a lot of work, especially for multi-line, oddly formatted quotes. I haven't figured out a way to automate the conversion. I'd much rather be able to use fortune format.

I'm also not sure if the above is buggy or expected behavior, not being intimately familiar with the fortune format specification. Nor am I sure if there is a way to get the behavior that I want using the fortune format.

I am open to ideas and suggestions. Thanks.
« Last Edit: July 16, 2008, 07:30:10 AM by transitionality » Logged
mouser
First Author
Administrator
*****
Posts: 33,357



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #1 on: July 16, 2008, 07:48:41 AM »

let me see if i can't fix this to respect newlines in fortune files that use the % format to separate items.
Logged
transitionality
Participant
*
Posts: 9

View Profile Give some DonationCredits to this forum member
« Reply #2 on: July 16, 2008, 07:56:29 AM »

Like I said, I'm not sure what the specification is. I wouldn't want to cause you to fall out of spec merely to convenience me. But if it is within spec, that would be great.
Logged
mouser
First Author
Administrator
*****
Posts: 33,357



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #3 on: July 16, 2008, 08:08:46 AM »

my memory is (and it's been a while since i worked on this), that popup wisdom knows how to read 2 kinds of fortune file formats.

one involves each quote on its own line.  in such a case youd have to use \n to indicate a newline -- no real option there.
the other format uses % signs to separate fortunes.  there is no reason that it shouldn't respect newlines in such a case.
Logged
transitionality
Participant
*
Posts: 9

View Profile Give some DonationCredits to this forum member
« Reply #4 on: July 16, 2008, 08:24:04 AM »

See here for some more detail, under "Cookie-Jar Format".

Apparently %% is a valid delimiter too, so maybe you could support that as well?
« Last Edit: July 16, 2008, 08:26:11 AM by transitionality » Logged
transitionality
Participant
*
Posts: 9

View Profile Give some DonationCredits to this forum member
« Reply #5 on: July 16, 2008, 11:59:45 AM »

Paying attention to this problem, I also notice a couple of other things.

* When a quote is displayed, a newline is appended to the bottom of it. Is this by design, or is it an oversight? When the quote is copied and pasted, the newline makes it different from the quote as copied and pasted from the quotes file. If the newline at the bottom is by design -- to put some space between the text and the buttons at the bottom -- perhaps it can be used for display purposes, but not appended to the copied text when the copy button is pressed.

* As quotes are parsed from a BSD-style fortunes file, it would be useful to ignore all whitespace from the % to the first non-whitespace character, and again, ignore all whitespace from the last non-whitespace character to the next %. That way,

Quote
%



"The time you enjoy wasting is not wasted time."

-- Bertrand Russell


%


gets parsed as

Quote
"The time you enjoy wasting is not wasted time."

-- Bertrand Russell

which is probably a sensible way to do it. There's a reference to this in the source I gave in the previous message, but it's a suggestion rather than a rule. What do people think?
« Last Edit: July 16, 2008, 12:03:00 PM by transitionality » Logged
mouser
First Author
Administrator
*****
Posts: 33,357



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #6 on: July 16, 2008, 12:59:41 PM »

easy to do and makes sense to me.
Logged
mouser
First Author
Administrator
*****
Posts: 33,357



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #7 on: July 18, 2008, 12:56:18 PM »

Can you try this new version and let me know if the issues have been fixed:
http://www.donationcoder....oads/PopUpWisdomSetup.exe

(see help file bottom for list of changes)
Logged
transitionality
Participant
*
Posts: 9

View Profile Give some DonationCredits to this forum member
« Reply #8 on: July 22, 2008, 02:45:45 AM »

I uninstalled the previous version and installed the latest version in a clean directory, so there would be no complications.

I created a fortune file with %% delimiters, and unfortunately it did not work. Every separate non-blank line was parsed as a separate quote, even lines containing the %% delimiter.

When I search-and-replaced the %% delimiters with the % delimiter, the program failed in a different way. The whitespace preceding and trailing the quote were ignored, as expected, but the newlines within the quotes were not respected except for the author line (starting with a dash), instead they were substituted with spaces. So:

[copy or print]

.....

%

"Do I contradict myself?
Very well then I contradict myself,
(I am large, I contain multitudes.)"

-- Walt Whitman, from _Song of Myself_

%

.....

got displayed as:

[copy or print]
"Do I contradict myself? Very well then I contradict myself, (I am large, I contain multitudes.)"
 -- Walt Whitman, from _Song of Myself_

(with one space at the beginning of the author line, substituting for the newline that was supposed to be before it)

Clearly, some things are amiss.

Edit: I think I figured out the problem. For %-using fortune files, within the quote, you're substituting a space for single newlines, but you are displaying newlines if two or more consecutive newlines are involved (except the very first newline gets substituted with a space again). Why you're doing it this way, I don't know. It's probably a bug.
« Last Edit: July 22, 2008, 02:59:46 AM by transitionality » Logged
mouser
First Author
Administrator
*****
Posts: 33,357



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #9 on: July 22, 2008, 06:20:09 AM »

i just uploaded a minor update.

it should fix the space at begining of line problem.

the conversion of normal newlines into spaces is by design since fortune files seem to be most often formatted with hard newlines for linebreaks which isn't appropriate for popup wisdom.

you have a couple of choices for forcing newlines in these files. you can manually put a \n where you want a newline, or you can start lines which should start on a new line with a space or you can put 2 newlines (or more) to indicate a break.
Logged
transitionality
Participant
*
Posts: 9

View Profile Give some DonationCredits to this forum member
« Reply #10 on: July 22, 2008, 01:16:29 PM »

Quote
you have a couple of choices for forcing newlines in these files. you can manually put a \n where you want a newline

if i were willing to do this, i would have used popupwisdom's own format

Quote
or you can start lines which should start on a new line with a space or you can put 2 newlines (or more) to indicate a break.

meh. none of this is wysiwyg. wouldn't it be nice to have a wysiwyg file format, that would be pleasant to read and work with, as well as being used as a data format?

i do appreciate the work you've put into compliance with the cookie-jar format, and i understand why it needs to work the way it does, but perhaps you can appreciate the feature request i defined above.

maybe you can define a new format, unique to popupwisdom, that is similar to the cookie-jar format but is wysiwyg. you get newlines and spaces and tabs if you put them, where you put them, and nowhere else, (except whitespace between content and delimiter is ignored, like you currently do with cookie-jar format). in this new and original file format, you would probably want to define a new delimiter different from % or %%. you could call it popup wisdom wysiwyg file format. it shouldn't be too much work on top of work you've already done, but i feel like it would be a useful and worthy addition.

what do people think about this?
« Last Edit: July 22, 2008, 01:52:47 PM by transitionality » Logged
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.036s | Server load: 0.16 ]