petitparser question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

petitparser question

Sebastian Heidbrink-2
Hi!

I watched Tudor's looong tutorial on PetitParser and I still can't find
a solution for one of my inputs.

I would like to parse a file that includes HTML templates but it is no
HTML file!.
Since there is no PPHTMLParser and the XMLHTMLParser extends the import
by missing pieces, I decided to write my own PPParser.

I have trouble with nested parts now.
How would I parse something like this?:
.....
.....
   <template>
     <style>
       :host {
         display: block;
       }
     </style>
     <ul>
       <template items="{{items}}">
         <li><span >{{item}}</span></li>
       </template>
     </ul>
   </template>
....
....


template is the node I am interested in but how can I keep trac on which
level I am and if I may expect another /template tag or not?

The file also includes other information and could have more than just
one part with "templates".

Is the "indent" support something I should have a look at?

Doru! Thank you for this great presentation! Exeptt for this problem it
included solutions on all my needs!

Thank you!
Sebastian
_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: petitparser question

Sebastian Heidbrink-2
Okay got it!

(templateStart trim, ((#any asParser starLazy: templateEnd) flatten
trim, templateEnd trim) star ) flatten

Sebastian

Am 19.11.2015 um 08:48 schrieb Sebastian Heidbrink:

> Hi!
>
> I watched Tudor's looong tutorial on PetitParser and I still can't
> find a solution for one of my inputs.
>
> I would like to parse a file that includes HTML templates but it is no
> HTML file!.
> Since there is no PPHTMLParser and the XMLHTMLParser extends the
> import by missing pieces, I decided to write my own PPParser.
>
> I have trouble with nested parts now.
> How would I parse something like this?:
> .....
> .....
>   <template>
>     <style>
>       :host {
>         display: block;
>       }
>     </style>
>     <ul>
>       <template items="{{items}}">
>         <li><span >{{item}}</span></li>
>       </template>
>     </ul>
>   </template>
> ....
> ....
>
>
> template is the node I am interested in but how can I keep trac on
> which level I am and if I may expect another /template tag or not?
>
> The file also includes other information and could have more than just
> one part with "templates".
>
> Is the "indent" support something I should have a look at?
>
> Doru! Thank you for this great presentation! Exeptt for this problem
> it included solutions on all my needs!
>
> Thank you!
> Sebastian
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.list.inf.unibe.ch/listinfo/moose-dev
>

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev