I think the regex method may be the best answer. I guess there is no way of 
getting at the index subscript from elements()?

On Tuesday, 24 April 2012 01:02:14 UTC+1, Anthony wrote:
>
> I'm not sure there's an easy way to delete or replace server-side DOM 
> components using the .elements() method of searching (you can do it with 
> index subscripting, but that doesn't help unless you know exactly where the 
> elements are in the DOM). But since this is a fairly constrained problem, 
> can't you just leave the HTML as a string and do a regex replace on the 
> <br> elements -- you're not parsing and manipulating the entire DOM, you're 
> just replacing one specific string?
>
> Anthony
>
> On Monday, April 23, 2012 6:36:54 PM UTC-4, simon wrote:
>>
>> I want to create a template in Microsoft Word, save it as filtered html, 
>> fill it with data using web2py, and then output it as a PDF file. Why? So 
>> my secretary can create the template without having to look at that HTML 
>> stuff!
>>
>> Unfortunately Microsoft puts some of the pagebreaks in BR tags which may 
>> work in IE but not in Chrome. I could parse the html and change the tags if 
>> that were easy but I cannot see how to do it in web2py and I don't want to 
>> import some other parser just for this. Otherwise I will just use the 
>> workaround which is to add the breaks to paragraph settings rather than 
>> doing ctrl-enter.
>>
>> On Monday, 23 April 2012 19:11:23 UTC+1, Wikus van de Merwe wrote:
>>>
>>> So you have an HTML code as input and would like to change some tags to 
>>> some others ones. But why? You should never had the need to build the HTML 
>>> page from another HTML page in web2py. You should rather simply combine the 
>>> data and a view. In your example, the view could be this:
>>>
>>> pages.css
>>> ---------------
>>> .page {
>>>     page-break-after: always;
>>> }
>>>
>>> pages.html
>>> ----------------
>>> {{ for page in pages: }}
>>>      {{=DIV(page.content, _class="page")}}
>>>
>>> And if you really need to process the HTML, you should use an HTML 
>>> parser e.g. lxml or html5lib.
>>>
>>>

Reply via email to