samedi 28 mars 2015

Automatically Mark Up HTML Text

I am hoping to find a way to automatically mark up an HTML document based on text matches. I have a directory containing several hundred short HTML documents, the contents of which are individually included (via PHP) in a base_document.html depending on the value of a variable taken from the URL, as so:



<?php include $_GET['id'] . ".html";?>


If the included HTML document contains a specific word, e.g. "dangerous," I would like to automatically format it with a particular markup; for example:



<strong>dangerous</strong>


Is there already a particular library or function in PHP, JavaScript, and/or CSS that provides this kind of functionality? Or would I need to write my own code to achieve my purpose?


Edit: There would be a long list of target words and associated markups, so I assume I would need to refer to a custom dictionary residing in either a file or database. E.g.,



"dangerous",bold
"important",style:color=red
"hungry",em
"hot",strong

Aucun commentaire:

Enregistrer un commentaire