• Resolved Johannes Jülg

    (@timse201)


    Is it possible to exclude some phrases for auto description? e.g. if you write an article to describe something and want to write an introduction to restrict it or to give a warning. so you only need to copy paste this with a marker to exclude it.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Johannes Jülg

    (@timse201)

    a table of contents for paginated articles could be another example

    Plugin Author Sybre Waaijer

    (@cybr)

    Howdy!

    TSF’s description generator can parse HTML. Here’s a complete list of altered or even ignored elements: https://tsf.fyi/kb/a/65#stripped-html-tags.

    The <aside> HTML element is most applicable in both examples you gave, but I see I added that to the “kept” list… I’ll have that set to “removed” in the next major update (ETA unknown). Thanks for sharing your use case.

    Until then, you’ll have to strip those sentences filtering the content from the_seo_framework_fetched_description_excerpt. For example:

    add_filter( 'the_seo_framework_fetched_description_excerpt', function( $excerpt ) {
    
    	$excerpt = str_replace(
    		[
    			'First sentence',
    			'A different set of words',
    		],
    		'',
    		$excerpt
    	);
    	return $excerpt;
    } );

    I hope this helps ?? Cheers!

    Thread Starter Johannes Jülg

    (@timse201)

    thanks for reply and all the hard work

    I have moved these phrases to aside and the table of contents to nav.
    It seems like space has a higher priority than strip. If there is another tag like ul inside, nav is not ignored.

    Plugin Author Sybre Waaijer

    (@cybr)

    Hi again!

    clear (strip) has a higher priority than space (I still need to proofread the article I shared).

    At least, that’s how the code should work.

    Do you notice it differently? If so, please share the HTML you tested. If you find your HTML private, please send it confidentially via https://tsf.fyi/contact. Thanks!

    Plugin Author Sybre Waaijer

    (@cybr)

    Hello ??

    Thank you for the email and example HTML; it helped me isolate a bug in TSF’s description generator. The “parser” I created couldn’t distinguish nested elements that needed exclusion and stopped processing those tags entirely. So <nav><anyelement></nav> could not be detected as a navigational element, but <nav>text</nav> could.

    I noticed you are confident adjusting code. If you’d like to test a provisionary bugfix, this line must be exchanged with the following code:

    $_regex   = sprintf( '<(%s)\b[^<]*>((?:[^<]*(?:<(?!\/?\1\b)[^<]*)*|(?R))*)<\/\1>', implode( '|', $fill_query ) );
    

    It’s not optimized for performance yet, so it might change before I roll out the fix.

    • This reply was modified 2 years, 5 months ago by Sybre Waaijer. Reason: Fixed another bug that couldn't parse unregistered HTML tags
    Plugin Author Sybre Waaijer

    (@cybr)

    I optimized the code further so your site won’t crash when a HTML tag remains unclosed. If you wish to edit the code, please use the following instead of the code in my previous reply:

    $_regex   = sprintf( '<(%s)\b[^<]*>((?:[^<]*(?:<(?!\/?\1\b)[^<]*)*|(?R)|(*ACCEPT))*)<\/\1>', implode( '|', $fill_query ) );
    

    I have no ETA on the public release of this bug fix yet.

    Thread Starter Johannes Jülg

    (@timse201)

    Thanks, it works

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘exclude text for auto description’ is closed to new replies.