Here is the file I call from a cron to generate the HTML
<?php
require( '<your WP path>/wp-load.php' );
#### Generate the Header ###
ob_start();
get_header();
$header = ob_get_contents();
ob_end_clean();
$header = preg_replace('/<!*DOCTYPE(.*?)<\/head>/si', "",$header);
$header = preg_replace('/<body(.*?)>/si', "",$header);
$header = preg_replace('/<!--[ ]*Start[ ]*Advertisement[ ]*1[ ]*-->(.*?)<!--[ ]*end[ ]*advertisement[ ]*1[ ]*-->/si', '{myadvertisements[zone_1]}', $header);
//<!-- Start Advertisement 1 -->
//'/<!--[ ]*START[ ]*NO[ ]*PRINT[ ]*-->(.*?)<!--[ ]*END[ ]*NO[ ]*PRINT[ ]*-->/si'
$patterns[0] = '/class="/';
$patterns[1] = '/id="/';
$patterns[2] = "/class='/";
$replacements = array();
$replacements[2] = 'class="wp';
$replacements[1] = 'id="wp';
$replacements[0] = "class='wp";
$header = preg_replace($patterns, $replacements, $header);
$header = preg_replace('/class="wpcat-item cat/', 'class="wpcat-item wpcat', $header);
$header .= '<div id="wpcontent">';
file_put_contents("<whatever path you want>/header.html", $header);
############################
#### Generate the sidebar #####
ob_start();
dynamic_sidebar('right-sidebar');
$sidebar = ob_get_contents();
ob_end_clean();
$patterns[0] = '/class="/';
$patterns[1] = '/id="/';
$patterns[2] = "/class='/";
$replacements = array();
$replacements[2] = 'class="wp';
$replacements[1] = 'id="wp';
$replacements[0] = "class='wp";
$sidebar = preg_replace($patterns, $replacements, $sidebar);
$sidebar = str_replace('href="#', 'href="#wp', $sidebar);
$sidebar = preg_replace('/<!--[ ]*Start[ ]*Advertisement[ ]*5[ ]*-->(.*?)<!--[ ]*end[ ]*advertisement[ ]*5[ ]*-->/si', '{myadvertisements[zone_5]}', $sidebar);
$sidebar = preg_replace('/<!--[ ]*Start[ ]*Advertisement[ ]*6[ ]*-->(.*?)<!--[ ]*end[ ]*advertisement[ ]*6[ ]*-->/si', '{myadvertisements[zone_6]}', $sidebar);
$sidebar = preg_replace('/<!--[ ]*Start[ ]*Advertisement[ ]*4[ ]*-->(.*?)<!--[ ]*end[ ]*advertisement[ ]*4[ ]*-->/si', '{myadvertisements[zone_4]}', $sidebar);
$sidebar = preg_replace('/<!--[ ]*Start[ ]*Advertisement[ ]*9[ ]*-->(.*?)<!--[ ]*end[ ]*advertisement[ ]*9[ ]*-->/si', '{myadvertisements[zone_9]}', $sidebar);
file_put_contents("<whatever path you want>/sidebar.html", $sidebar);
Please note the myadvertisement stuff isn't going to be relevant to any of you unless you have some custom code I have. Basically I have more code that includes myadvertisement adverts into my wordpress site so I can manage the adverts from a single location and they stay dynamic rather than being static.
So either null that out or come up with similar code, its too custom for me to release at this point.
Just call this either when you make a change in wordpress (easy code to write) or call it say once an hour or twice a day depending on how often you make theme and menu changes. Or alternatively call it directly.
This will generate you a header footer and sidebar code, you may need to add in some code to re-add any require JS though.
Then you can either use the dynamic header and footer plugin or write your own, I will try to drop the code in here late when I have a chance
Oh also What it does is change all of the wordpress CSS to be prepended with "wp-" so I then have a CSS file which I have included into my mybb theme, which is essentially and exact copy of my WP theme with a few things removed, simply because I wanted a different font on forums etc.
So you will need to do the same. you then need to change all of the CSS to be wp-whatever
then you should be good to go. You can automate that as well but I have lost the code that I used to do that