Create a filter or Parse HTML files with PHP in moodle

Create a filter or Parse HTML files with PHP in moodle

by Abel Pau -
Number of replies: 2
Hello everybody,

I've been searching for an Html Parser with PHP languaje, but its is impossible.

The original problem is create a filter that given an xhtml (or html) file is be able to transform some tags to another (amb the content of these). For example I would like to transform "<math>A</math>"  into "<img src=B>A</img>".

So, I think that a filter is a good way (because I don't want to change the original html and the filters dont' do it). To create a filter I've created a PHP file named filter.php and I've put it in the correct place to be readed from moodle admin filters.

Inside this PHP code I can read all the html file. I only need, then, do the transformation here. Then, I need...
IN: html file with some tags
OUT: the same html file with the modified tags.

To do this, I would have to parser all the html file, and capture the tags and their content to transform it.
MY QUESTION IS: Are there any tool that do this and that can be integrated in moodle?

Thanks a lot in advance.
Abel.
Average of ratings: -
In reply to Abel Pau

Re: Create a filter or Parse HTML files with PHP in moodle

by N Hansen -
Abel-This sounds like something I am would like to do. I am thinking of putting a php include in my header to be activated by the following string <?php echo Wikihiero($text); ?>. I was thinking it would be good to have a filter that would work something like this:

<glyph>A1-B1-C1</glyph>

And replace the <glyph> with <?php echo

And replace the </glyph> with  ); ?>

With the output being some html code which will render a table with pictures in it in place of the original text between the tags.

Have you seen Eloy's custom linker?
That allegedly does something similar but although I have installed and activated on my site, I haven't gotten it to work.

In any case, I'm going to be having Janne Mikkonnen do some work in integrating the scripts I need into my site next month, and if it can be done and I don't figure it out myself before then, I am going to have him write a filter like this for me. Let me know if you have any success before then as I can pass any ideas you have on to him then. If not, I'll let you know what works out for me in the end.
In reply to N Hansen

Re: Create a filter or Parse HTML files with PHP in moodle

by Mayank Jain -
Hi

I am working with Moodle: Voice project and I am looking for something similar as to what Abel has explained in his question. I need to process html page to extract all links tags from it.

Kindly let me know how it can be done with some existing tool for HTML parsing or may be if it can be done using filter developed by Abel ?