File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -536,9 +536,19 @@ func (p *TripleAggregateToWikiPageConverter) convertUriToWikiTitle(uri string, u
536536 // Clean up strange characters
537537 factTitle = str .Replace (factTitle , "[" , "(" , - 1 )
538538 factTitle = str .Replace (factTitle , "]" , ")" , - 1 )
539-
540539 factTitle = html .EscapeString (factTitle )
541540
541+ // Limit to max 255 chars (due to MediaWiki limitaiton)
542+ titleIsShortened := false
543+ for len (factTitle ) >= 250 {
544+ factTitle = removeLastWord (factTitle )
545+ titleIsShortened = true
546+ }
547+
548+ if titleIsShortened {
549+ factTitle += " ..."
550+ }
551+
542552 if uriType == URITypePredicate {
543553 pageTitle = "Property:" + factTitle
544554 } else if uriType == URITypeClass {
@@ -921,3 +931,9 @@ func stringInSlice(a string, list []string) bool {
921931 }
922932 return false
923933}
934+
935+ func removeLastWord (inStr string ) string {
936+ bits := str .Split (inStr , " " )
937+ outStr := str .Join (append (bits [:len (bits )- 1 ]), " " )
938+ return outStr
939+ }
You can’t perform that action at this time.
0 commit comments