Handle doc urls enclosed in parens.
It seems this has become a common pattern in at least some of our libraries. Fixes https://gitlab.com/kicad/code/kicad/issues/7963
This commit is contained in:
parent
f24f0d93a5
commit
49b1aceb8b
|
@ -94,7 +94,32 @@ public:
|
||||||
// It is currently common practice to store a documentation link in the description.
|
// It is currently common practice to store a documentation link in the description.
|
||||||
int idx = desc.find( wxT( "http:" ) );
|
int idx = desc.find( wxT( "http:" ) );
|
||||||
|
|
||||||
|
if( idx < 0 )
|
||||||
|
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;
|
||||||
|
|
||||||
|
while( idx < (int) desc.size() )
|
||||||
|
{
|
||||||
|
char c = desc.at( idx++ );
|
||||||
|
|
||||||
|
if( c == '(' )
|
||||||
|
nesting++;
|
||||||
|
else if( c == ')' && --nesting < 0 )
|
||||||
|
break;
|
||||||
|
|
||||||
|
doc += c;
|
||||||
|
}
|
||||||
|
|
||||||
|
desc.Replace( doc, _( "doc url" ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
doc = desc.substr( (unsigned) idx );
|
doc = desc.substr( (unsigned) idx );
|
||||||
|
|
||||||
|
@ -104,6 +129,7 @@ public:
|
||||||
if( !desc.IsEmpty() && desc.Last() == ',' )
|
if( !desc.IsEmpty() && desc.Last() == ',' )
|
||||||
desc.RemoveLast( 1 );
|
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