Handle updated document description format
parentheses are rarely if ever used independently, so trim the unmatched
ones regardless of whether we find the starting parenthesis in the
description
Fixes https://gitlab.com/kicad/code/kicad/issues/11403
(cherry picked from commit be7e9d300e
)
This commit is contained in:
parent
d600fd3498
commit
b6e7bf4768
|
@ -99,38 +99,28 @@ public:
|
||||||
idx = desc.find( wxT( "https:" ) );
|
idx = desc.find( wxT( "https:" ) );
|
||||||
|
|
||||||
if( idx >= 0 )
|
if( idx >= 0 )
|
||||||
{
|
|
||||||
// And, sadly, it appears to have also become customary to bury the url inside
|
|
||||||
// parentheses.
|
|
||||||
if( idx >= 1 && desc.at( idx - 1 ) == '(' )
|
|
||||||
{
|
{
|
||||||
int nesting = 0;
|
int nesting = 0;
|
||||||
|
|
||||||
while( idx < (int) desc.size() )
|
for( auto chit = desc.begin() + idx; chit != desc.end(); ++chit )
|
||||||
{
|
{
|
||||||
char c = desc.at( idx++ );
|
int ch = *chit;
|
||||||
|
|
||||||
if( c == '(' )
|
// Break on invalid URI characters
|
||||||
nesting++;
|
if( ch <= 0x20 || ch >= 0x7F || ch == '"' )
|
||||||
else if( c == ')' && --nesting < 0 )
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
doc += c;
|
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
desc.Replace( doc, _( "doc url" ) );
|
desc.Replace( doc, _( "doc url" ) );
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
doc = desc.substr( (unsigned) idx );
|
|
||||||
|
|
||||||
desc = desc.substr( 0, (unsigned) idx );
|
|
||||||
desc = desc.Trim( true );
|
|
||||||
|
|
||||||
if( !desc.IsEmpty() && desc.Last() == ',' )
|
|
||||||
desc.RemoveLast( 1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_html.Replace( "__NAME__", EscapeHTML( name ) );
|
m_html.Replace( "__NAME__", EscapeHTML( name ) );
|
||||||
m_html.Replace( "__DESC__", EscapeHTML( desc ) );
|
m_html.Replace( "__DESC__", EscapeHTML( desc ) );
|
||||||
|
|
Loading…
Reference in New Issue