Adding ' beside newsfield makes surrounding text disappear

All notes and input on 2.0 Development are herein. <ul><li>Feature requests</li>
<li>Bug Reports</li>
<li>Beta Testing Feedback</li>
<li>Open Dev Discussion</li></ul>

Moderator: Coranto Moderator Team

Adding ' beside newsfield makes surrounding text disappear

Postby FitnessJunkie » Sun Aug 22, 2004 3:17 am

This can be moved as I'm not sure it's a bug. Just an ... oddity. ; )

If you have newsfields in a style and put a ' immediately beside
it, in the built HTML page you won't see the field contents, the ',
or what's immediately after the '. At least this is the case using
styles as templates as I do.

For instance, if you have THIS in your style:

Code: Select all
See <Field: CustomField_Jane>'s bio.


It'll come out in the built page as THIS:

Code: Select all
See bio.


The only way to make it appear similar to how it should is to
escape (put a forward slash before) the '. For instance, put this
in your style instead:

Code: Select all
See <Field: CustomField_Jane>/'s bio.


Then it'll print in the built page as:

Code: Select all
See Jane Doe/'s bio.


Don't know if anyone else does or will experience this, but
just in case, it's a useful workaround for your reference. (I
use Coranto 1.22.1, Maginot, and several other add-ons.)
Namaste,
FitnessJunkie
User avatar
FitnessJunkie
 
Posts: 95
Joined: Tue Feb 24, 2004 9:11 pm

Re: Adding ' beside newsfield makes surrounding text disappe

Postby Parahead » Sun Aug 22, 2004 8:07 am

FitnessJunkie wrote:This can be moved as I'm not sure it's a bug. Just an ... oddity. ; )
I consider this to be a bug...

FitnessJunkie wrote:If you have newsfields in a style and put a ' immediately beside it, in the built HTML page you won't see the field contents, the ', or what's immediately after the '. At least this is the case using styles as templates as I do.

For instance, if you have THIS in your style:
Code: Select all
See <Field: CustomField_Jane>'s bio.

It'll come out in the built page as THIS:
Code: Select all
See bio.
The thing is that when Coranto parses the style into Perl, this will look like this:
Code: Select all
$newshtml .= qq~See $CustomField_Jane's bio.~;
which means that the variable $CustomField_Jane's is empty, resulting in your output. The same thing will happen when you put *any* character that is considered valid in a Perl variable name directly after a Field-tag in the style (a-z A-Z 0-9 _ : '). Normaly you are not affected by this, since you often put another tag or a space directly after a Field-tag in the style, so this is not a common problem but still annoying and a real bug!

FitnessJunkie wrote:The only way to make it appear similar to how it should is to escape (put a forward slash before) the '. For instance, put this in your style instead:
Code: Select all
See <Field: CustomField_Jane>/'s bio.

Then it'll print in the built page as:
Code: Select all
See Jane Doe/'s bio.
There is an even better solution, change the / to a \ instead and you will see the text as you intended it to look...
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Re: Adding ' beside newsfield makes surrounding text disappe

Postby LoneOwl » Mon Aug 23, 2004 3:19 pm

Parahead wrote:
FitnessJunkie wrote:If you have newsfields in a style and put a ' immediately beside it, in the built HTML page you won't see the field contents, the ', or what's immediately after the '. At least this is the case using styles as templates as I do.

For instance, if you have THIS in your style:
Code: Select all
See <Field: CustomField_Jane>'s bio.

It'll come out in the built page as THIS:
Code: Select all
See bio.
The thing is that when Coranto parses the style into Perl, this will look like this:
Code: Select all
$newshtml .= qq~See $CustomField_Jane's bio.~;
which means that the variable $CustomField_Jane's is empty, resulting in your output. The same thing will happen when you put *any* character that is considered valid in a Perl variable name directly after a Field-tag in the style (a-z A-Z 0-9 _ : '). Normaly you are not affected by this, since you often put another tag or a space directly after a Field-tag in the style, so this is not a common problem but still annoying and a real bug!
More precisely, it's looking for the variable s, in package CustomField_Jane.
Parahead wrote:
FitnessJunkie wrote:The only way to make it appear similar to how it should is to escape (put a forward slash before) the '. For instance, put this in your style instead:
Code: Select all
See <Field: CustomField_Jane>/'s bio.

Then it'll print in the built page as:
Code: Select all
See Jane Doe/'s bio.
There is an even better solution, change the / to a \ instead and you will see the text as you intended it to look...
The quick and simple fix is for the style to part <Field: Variable> into ${Variable} instead of $Variable.
User avatar
LoneOwl
 
Posts: 1465
Joined: Sun Mar 10, 2002 2:57 am
Location: That one place, you know?

Re: Adding ' beside newsfield makes surrounding text disappe

Postby Parahead » Mon Aug 23, 2004 6:43 pm

LoneOwl wrote:More precisely, it's looking for the variable s, in package CustomField_Jane.
Correct, I just did not want to make it *too* technical... ;-)

LoneOwl wrote:
Parahead wrote:There is an even better solution, change the / to a \ instead and you will see the text as you intended it to look...
The quick and simple fix is for the style to part <Field: Variable> into ${Variable} instead of $Variable.
I was just giving FitnessJunkie a solution she could use of her own in the style without having to wait for a fix in the core, but I fully agree that a more long-term solution would be to implement your suggestion in the StyleToPerl sub! :-D
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby FitnessJunkie » Mon Aug 23, 2004 7:23 pm

Oh -- cool. Thank you for the (better ; )) fix!
Namaste,
FitnessJunkie
User avatar
FitnessJunkie
 
Posts: 95
Joined: Tue Feb 24, 2004 9:11 pm

Postby LoneOwl » Tue Aug 24, 2004 6:13 am

Using the ${Variable} really is best... Of course there is a hidden feature that most people don't know about that follows the same idea. For instance, doing
Code: Select all
$a = "abcdefghijklmnopqrstuvwxyz";
print "The alphabet is $a.\nThe alphabet in rot13 is @{[do { ($rot13 = $a) =~ tr/a-zA-Z/n-za-mN-ZA-M/;$rot13}]}.\n";
How many of you perl coders out there knew you could embed function calls into a string and have it interpolate? Anyway.... It's a quick fix so I'd expect it in the next release. Two characters in a few lines of code shouldn't take long.
User avatar
LoneOwl
 
Posts: 1465
Joined: Sun Mar 10, 2002 2:57 am
Location: That one place, you know?

Putting ANY text after a field code makes things disappear..

Postby FitnessJunkie » Sun Sep 05, 2004 1:06 am

Well, the bug is a little bigger than I first realized. Looks like putting
ANY text AFTER a field code will cause both the code and the text not
to display in built news.

For instance, THIS (having HTML code beside the field) will display
the custom field just fine:
Code: Select all
<table><tr><td><Field: CustomField_PP_Title></td></tr></table>


And THIS will display both the CustomField AND the "text" beside it:
Code: Select all
<table><tr><td>text<Field: CustomField_PP_Title></td></tr></table>


But THIS won't display either the CustomField OR the "text" beside it:
Code: Select all
<table><tr><td><Field: CustomField_PP_Title>text</td></tr></table>


I originally thought it was having a ' next to the field that caused
this bug, but it's ANY text. HTML code surrounding and touching a
field doesn't seem to matter (which is why I never discovered
problems with this before), and text touching BEFORE a field code
doesn't matter.

It's only TEXT displayed AFTER the field code (and touching it).
Just a little clarification, in case it was needed.
Namaste,
FitnessJunkie
User avatar
FitnessJunkie
 
Posts: 95
Joined: Tue Feb 24, 2004 9:11 pm

Re: Putting ANY text after a field code makes things disappe

Postby Parahead » Sun Sep 05, 2004 3:34 pm

FitnessJunkie wrote:It's only TEXT displayed AFTER the field code (and touching it). Just a little clarification, in case it was needed.
Thank you for digging into this a bit deeper but this has already been mentioned, maybe in more "technical" terms though: ;-)
Parahead wrote:The same thing will happen when you put *any* character that is considered valid in a Perl variable name directly after a Field-tag in the style (a-z A-Z 0-9 _ : ').

If you would like to fix this problem more permanently I would suggest using LoneOwl's solution. Open up the file cradmin.pl, and search for the line:
Code: Select all
$style =~ s/<Field: ([a-zA-Z0-9_]+)>/\$$1/g;

Replace that line with this:
Code: Select all
$style =~ s/<Field: ([a-zA-Z0-9_]+)>/\${$1}/g;

As a sidenote I can mention that I have sent an updated version of 1.30.3 to cerberos76 with a bunch of fixes and updates, including this one.
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby Lumberjack » Mon Jun 13, 2005 2:24 pm

Is it possible to also do:
Code: Select all
<Field: {Variable}>
Lumberjack
 
Posts: 555
Joined: Wed Jan 10, 2007 7:22 pm
Location: Oxford, UK

Postby Parahead » Mon Jun 13, 2005 8:53 pm

Lumberjack wrote:Is it possible to also do:
Code: Select all
<Field: {Variable}>
Coranto 1.24's code in StyleToPerl:
Code: Select all
# Replace <Field: Name> with $Name
$style =~ s/<Field: ([a-zA-Z0-9_]+)>/\$1/g;
So I would say no...

This issue is fixed in the development version though...
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby Lumberjack » Mon Jun 13, 2005 10:02 pm

That's funny though, because of this:
Edit Style Page wrote:You can include a whole range of Coranto variables/fields into your Style using this format: <Field: {FieldName}> or <Field: {variablename}>.

I think that was put in by FaceLift though.
Lumberjack
 
Posts: 555
Joined: Wed Jan 10, 2007 7:22 pm
Location: Oxford, UK

Postby Parahead » Tue Jun 14, 2005 6:31 am

Lumberjack wrote:That's funny though, because of this:
Edit Style Page wrote:You can include a whole range of Coranto variables/fields into your Style using this format: <Field: {FieldName}> or <Field: {variablename}>.

I think that was put in by FaceLift though.
I can't see this text in a clean Coranto installation, not on the style page or at the tagsdocs linked to from the style page, so I guess you are right with it being FaceLift introducing this text?

It isn't the first time curly {} and square [] brackets in technical documentation causes problem to the reader, I know some users are having a hard time understanding the Multipart documentation because of that. Normally (but not allways) when reading docs, the square brackets indicate stuff that is optional and curly brackets things that should be replaced with a real value and is mandatory. That doesn't go without saying, but is how it is. If you would have removed the curly brackets above, I can assure you that we would have people reporting problems with "<Field: FieldName> does not produce any output, why is that?"... So regardless how you write docs, people *will* missunderstand it... ;-) The issue isn't helped since we don't have a guide for how to write technical documentation to Coranto and how to represent certain stuff, like this, which makes each addon author write stuff in is own prefered way. Actually such a document would be a good idea to produce, it would make life easier for all of us?
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby Lumberjack » Tue Jun 14, 2005 3:32 pm

I would suggest in this case, to avoid any confusion with perl coders like us, that the FieldName be put in bold or italics (or maybe coloured) to signify that it should be replaced with something else.
Lumberjack
 
Posts: 555
Joined: Wed Jan 10, 2007 7:22 pm
Location: Oxford, UK

Postby Parahead » Thu Jul 14, 2005 8:48 am

Lumberjack wrote:I would suggest in this case, to avoid any confusion with perl coders like us, that the FieldName be put in bold or italics (or maybe coloured) to signify that it should be replaced with something else.
Yes, that could be one approach. It doesn't work for text in a readme.txt file though... ;-)

I think that regardless how it is presented it is important that we use *one* method, so that regardless if it is person X or Y that write the documentation for an addon information such as the above is used in similar manner. Such a "styleguide" for producing documentation and how to represent stuff doesn't exist though... Dale Ray started something similar some time ago about what should be included in a addon doc, but maybe that could be extended to a template and include guidelines for stuff like this? I don't know if the documentation project thread includes info on this matter as well?

If you (or anyone else) have the time and motivation to produce an embryo for a documentation guide, I don't think anyone would try and stop you... ;-)
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden


Return to Coranto 2.0 Development

Who is online

Users browsing this forum: No registered users and 0 guests