Glossary terms in syntax cause unrendered HTML

Please report bugs here!

Moderator: Thorsten

Post Reply
ChrisA
Posts: 12
Joined: Wed Jan 01, 2014 1:59 pm

Glossary terms in syntax cause unrendered HTML

Post by ChrisA » Sun Jan 05, 2014 2:17 pm

Hi all,

When using the code box feature in an FAQ, any glossary terms are converted into a tool-tip ( abbr ). Once the page is running, the syntax is wrapped in code tags by the syntax highlighter. These cause the abbr tags to be displayed on screen:
Bootloader>? <abbr rel="tooltip" data-original-title="Central processing unit">CPU</abbr> stats
Arduino explorer stk500V2 by MLS
Compiled on = Sep 9 2010
<abbr rel="tooltip" data-original-title="Central processing unit">CPU</abbr> Type = ATmega2560
__AVR_ARCH__ = 6
GCC Version = 4.3.3
AVR LibC Ver = 1.6.7
<abbr rel="tooltip" data-original-title="Central processing unit">CPU</abbr> signature= 1E9801
Low fuse = FF
High fuse = D8
Ext fuse = FD
Lock fuse = FF
Bootloader>
To solve this problem ( as a temporary fix ) I have used javascript to remove the tooltips from certain tags like headings, table headers, links, and pre (code box). This also solves the problem of jumping titles from this post: Glossary term in FAQ title causes jumping text

In Artikel.tpl, above the second last line ( anywhere above: SyntaxHighlighter.all(); ), add in this javascript code:

Code: Select all

$( 'pre, h2, thead, a' ).find( 'abbr' ).replaceWith( function (){ return $( this ).text(); } ); 
Additionally to remove repeated glossary terms anywhere in the article I use this code:

Code: Select all

$( 'abbr' ).each( function( i, e ){
	
	$( "abbr[ data-original-title='" + $( e ).attr( 'data-original-title' ) + "']" ).each(
		function( i, e ){ if( i > 0 ) $( e ).replaceWith( function (){ return $( this ).text(); } ); }
	)}
);
In the statement if( i > 0 ) increase the 0 to the number of repeats allowed - 1,

if( i > 0 ) == only one occurrence.
if( i > 1 ) == 1 repeat.
if( i > 2 ) == and so on...

These are only a few hacks to get the desired result. I'm having a look at inc/PMF/glossary.php to see where I could suggest some changes.

Thorsten
Posts: 14730
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Glossary terms in syntax cause unrendered HTML

Post by Thorsten » Mon Jan 06, 2014 8:55 am

Hi,

you're right, the check if the glossary term is in e.g. a <pre> tag is missing. I'll add it.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist

ChrisA
Posts: 12
Joined: Wed Jan 01, 2014 1:59 pm

Re: Glossary terms in syntax cause unrendered HTML

Post by ChrisA » Mon Jan 06, 2014 9:45 am

If its not too much trouble, could you add the feature using an editable list ( that is safe from upgrade ), maybe a php file for direct editing, or an entry method in the web GUI which uses the database.

Cheers, Chris.

Thorsten
Posts: 14730
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Glossary terms in syntax cause unrendered HTML

Post by Thorsten » Mon Jan 06, 2014 10:15 am

Hi,

still thinking about how to implement it in PMF_Glossary::insertItemsIntoContent()

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist

Post Reply