"
" " + _( "Documentation" ) + " | "
" __TEXT__ | "
"
" );
if( !aLibId.IsValid() )
return wxEmptyString;
const DESIGN_BLOCK* db = nullptr;
try
{
db = m_libs->GetEnumeratedDesignBlock( aLibId.GetLibNickname(), aLibId.GetLibItemName() );
}
catch( const IO_ERROR& ioe )
{
wxLogError( _( "Error loading design block %s from library '%s'." ) + wxS( "\n%s" ),
aLibId.GetLibItemName().wx_str(), aLibId.GetLibNickname().wx_str(),
ioe.What() );
return wxEmptyString;
}
wxString html = DescriptionFormat;
if( db )
{
wxString name = aLibId.GetLibItemName();
wxString desc = db->GetLibDescription();
wxString keywords = db->GetKeywords();
wxString doc;
// It is currently common practice to store a documentation link in the description.
size_t idx = desc.find( wxT( "http:" ) );
if( idx == wxString::npos )
idx = desc.find( wxT( "https:" ) );
if( idx != wxString::npos )
{
int nesting = 0;
for( auto chit = desc.begin() + idx; chit != desc.end(); ++chit )
{
int ch = *chit;
// Break on invalid URI characters
if( ch <= 0x20 || ch >= 0x7F || ch == '"' )
break;
// Check for nesting parentheses, e.g. (Body style from: https://this.url/part.pdf)
if( ch == '(' )
++nesting;
else if( ch == ')' && --nesting < 0 )
break;
doc += ch;
}
// Trim trailing punctuation
static wxString punct = wxS( ".,:;" );
if( punct.find( doc.Last() ) != wxString::npos )
doc = doc.Left( doc.Length() - 1 );
}
wxString esc_desc = EscapeHTML( UnescapeString( desc ) );
// Add line breaks
esc_desc.Replace( wxS( "\n" ), wxS( "