2323
2424#include " InterSpec_config.h"
2525
26+ #include < regex>
2627#include < string>
2728#include < fstream>
2829#include < sstream>
@@ -339,9 +340,23 @@ void MoreNuclideInfoDisplay::setNuclide( const SandiaDecay::Nuclide *const nuc,
339340 const auto more_info_db = MoreNucInfoDb::instance ();
340341 if ( more_info_db )
341342 {
343+ #ifndef NDEBUG
344+ #warning "Reseting MoreNucInfoDb for iterating purposes - remove this!"
345+ cerr << " Reseting MoreNucInfoDb for iterating purposes - remove this!" << endl;
346+ MoreNucInfoDb::remove_global_instance ();
347+ #endif
348+
342349 const NucInfo *const more_info = more_info_db->info ( nuc );
343350
344- if ( more_info )
351+ if ( !more_info )
352+ {
353+ // We need to fill these conditions out, incase we are setting a nuclide that doesnt have
354+ // them, but the previously displayed nuclide did.
355+ tmplt.setCondition ( " if-has-more-info" , false );
356+ tmplt.setCondition ( " if-has-related" , false );
357+ tmplt.bindWidget ( " related-nucs" , nullptr );
358+ tmplt.bindString ( " more-info" , " " , Wt::TextFormat::XHTMLText );
359+ }else
345360 {
346361 tmplt.setCondition ( " if-has-related" , !more_info->m_associated .empty () );
347362 if ( !more_info->m_associated .empty () )
@@ -353,9 +368,9 @@ void MoreNuclideInfoDisplay::setNuclide( const SandiaDecay::Nuclide *const nuc,
353368 for ( size_t i = 0 ; i < more_info->m_associated .size (); ++i )
354369 {
355370 const SandiaDecay::Nuclide *associated = db->nuclide ( more_info->m_associated [i] );
371+ WContainerWidget *li = new WContainerWidget ( associatedList );
356372 if ( associated )
357373 {
358- WContainerWidget *li = new WContainerWidget ( associatedList );
359374 WAnchor *anchor = new WAnchor ( li );
360375 anchor->setText ( more_info->m_associated [i] );
361376 anchor->clicked ().connect ( boost::bind ( &MoreNuclideInfoDisplay::setNuclide, this , associated, history ) );
@@ -365,8 +380,7 @@ void MoreNuclideInfoDisplay::setNuclide( const SandiaDecay::Nuclide *const nuc,
365380 t->addStyleClass ( " HalfLife" );
366381 }else
367382 {
368- WText *txtw = new WText ( more_info->m_associated [i], associatedList );
369- txtw->setInline ( false );
383+ new WText ( more_info->m_associated [i], li );
370384 }
371385 }
372386
@@ -380,11 +394,16 @@ void MoreNuclideInfoDisplay::setNuclide( const SandiaDecay::Nuclide *const nuc,
380394 SpecUtils::ireplace_all ( notes, " \r " , " " );
381395 vector<string> more_info_lines;
382396
397+ // Replace things like <li>Some List Item</li>
398+ // to <li>Some List Item</li>
399+ std::regex tag_regex ( " <([a-zA-Z/ ]{1,4})>" );
400+ notes = std::regex_replace ( notes, tag_regex," <$1>" );
401+
383402 boost::algorithm::split ( more_info_lines, notes,
384403 boost::algorithm::is_any_of ( " \n " ),
385404 boost::algorithm::token_compress_off );
386-
387- notes = " <p >" ;
405+
406+ notes = " <div class= \" MoreNucInfoSubSec \" >" ;
388407 for ( size_t i = 0 ; i < more_info_lines.size (); ++i )
389408 {
390409 string line = more_info_lines[i];
@@ -394,7 +413,7 @@ void MoreNuclideInfoDisplay::setNuclide( const SandiaDecay::Nuclide *const nuc,
394413
395414 if ( line.empty () )
396415 {
397- notes += " </p><p >" ;
416+ notes += " </div><div class= \" MoreNucInfoSubSec \" >" ;
398417
399418 // Skip all the next empty lines
400419 for ( ; (i + 1 ) < more_info_lines.size (); ++i )
@@ -407,7 +426,7 @@ void MoreNuclideInfoDisplay::setNuclide( const SandiaDecay::Nuclide *const nuc,
407426 }// if( line.empty() )
408427 }// for( size_t i = 0; i < more_info_lines.size(); ++i )
409428
410- notes += " </p >" ;
429+ notes += " </div >" ;
411430 tmplt.bindString ( " more-info" , notes, Wt::TextFormat::XHTMLText );
412431 }// if( more_info )
413432 }// if( more_info_db )
@@ -443,4 +462,4 @@ MoreNuclideInfoWindow::MoreNuclideInfoWindow( const SandiaDecay::Nuclide *const
443462{
444463 m_display = new MoreNuclideInfoDisplay ( nuc, contents () );
445464 addButton ( " Close" );
446- }// MoreNuclideInfoWindow
465+ }// MoreNuclideInfoWindow
0 commit comments