Is there anyway to modify the main scene DIV and script using hype export?

(Carlos Eduardo) #1

I’m using a custom hype export that I wrote on top of one of the ones that tumult makes available, and I’m trying to modify these lines using it. How would I go about that?

(Jonathan Deutsch) #2

It depends on the modifications you want to make.

If you look at the SampleExportScript we in fact have code to make modifications to the HTML; the insert_at_head_start, insert_at_head_end, insert_at_body_start, and insert_at_body_end values are inserted into the exported .html file. You can see this in the perform_html_additions () function - the method we use is regular expressions to search for a specific bit of text, and then do an insertion… ex:

	import re
	if insert_at_head_start != None:
		head_start ="<head.*?>", index_contents, re.IGNORECASE).end()
		index_contents = index_contents[:head_start] + insert_at_head_start + index_contents[head_start:]

It is ultimately a text parsing and insertion coding job; there’s a whole variety of techniques one could use, and they are also semi-dependent on the programming language. I used regular expressions for this because it is quick and easy to find the various tags for insertion, but there’s a whole school of thought that this isn’t a great way to modify structured HTML. The spectrum runs from simple find and replace to HTML tree parsing… so the right tool depends on the job.