I'm having a problem on my printer-friendly pages that include "a name" tags. My guess is the RegEx is confusing "a name" with "a href".

I've gone through my HTML and made sure there aren't problems with the markup. It's XHMTL valid.

Normal page: http://juice.altiris.com/node/279
Printer-friendly page: http://juice.altiris.com/node/279/print

Thanks.

Kevin

-----------------------------------
http://www.webwiseone.com
It's all about community.

CommentFileSizeAuthor
#4 print_aname.patch822 byteskmillecam
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

GN’s picture

I'm also having problems with "a name" followed by "a href" (Drupal 4.7.3, print.module 1.6.2.7).

<a name="bookmark01"></a>Chapter 1.<br>
Bla-bla-bla... 
<a href="http://www.example.com">www.example.com</a>. And so on.

With this example, any text between "a name" and "a href" tags (Chapter 1. Bla-bla-bla...) is not displayed in the print view -- seems like print.module cannot understand bookmarks.

the greenman’s picture

It seems like the best way to solve this is to tweak the url regular expression slightly. (I have not got a clean copy of print.module right now to make a patch)

The main thing to change is the ".*" after the initial A tag. If this gets replaced with "[^>]*", it seems to work fine.

So a manual patch (approx line 239):

Replace
$pattern = "@]*)([^>]*)>(.+?)@ise";
with
$pattern = "@]*?href=([\']?[\"]?)([^\"|^\'|^|^>]*)([^>]*)>(.+?)@ise";

the greenman’s picture

Hmm. Let me escape that:

<code>
  Replace: 
   $pattern = "@<a.*?href=([\']?[\"]?)([^\"|^\'|^|^>]*)([^>]*)>(.+?)</a>@ise";
  With: 
   $pattern = "@<a[^>]*?href=([\']?[\"]?)([^\"|^\'|^|^>]*)([^>]*)>(.+?)</a>@ise";

kmillecam’s picture

FileSize
822 bytes

I've created a patch based on the greenman's change.

kmillecam’s picture

Status: Active » Needs review
jmcclelland’s picture

Version: 4.6.x-1.x-dev » 4.7.x-1.x-dev

The included patch works for me on 4.7.4 with the latest version of the print module. Thanks!

ekrispin’s picture

Version: 4.7.x-1.x-dev » 5.x-1.1
Status: Needs review » Needs work

I have the very same problem in 5.1 also

ekrispin’s picture

I have the very same problem in 5.1 also

ekrispin’s picture

I have the very same problem in 5.1 also

ekrispin’s picture

I have the very same problem in 5.1 also

scooper@drupal.org’s picture

I just installed the 5.1 version and had the same problem. However, the patch contributed on Nov. 20, 2006 fixed it. Just open print.module in a text editor, and replace $pattern with the code given above.Thanks for sharing that patch!

jcnventura’s picture

Status: Needs work » Closed (fixed)

Patch applied to HEAD

felipensp’s picture

My suggestion:
'@\s]+)\s*[\x22\x27]?[^>]*>([^<]+)<\/a>@eis'

Only 2 groups capturing.

felipensp’s picture

Ops...

'@<a(?:(?!href=).)+href=[\x22\x27]?\s*([^\x22\x27>\s]+)\s*[\x22\x27]?[^>]*>([^<]+)<\/a>@eis'

jcnventura’s picture

Thanks for your suggestion. However the code in the 5.x branch is now completely different..

To be able to navigate around "a alt="href=" href="the_url", I had to abandon that simple pattern matching and develop a more robust algorithm.

Try the new 5.x-2.n versions and tell me what you think of them.