golang / gddo

Go Doc Dot Org
https://godoc.org
BSD 3-Clause "New" or "Revised" License
1.1k stars 266 forks source link

Greek character in function name makes Example unexpandable. #570

Open ohir opened 6 years ago

ohir commented 6 years ago

I used "small iota" greek character in names of example functions. Those Examples do expand and collapse if served from local godoc (i.e. godoc -http :53210), but served via godoc.org can NOT be expanded. Eg. name ExampleSnap_formatterιFactory().

At first reload topmost example will expand (but not fold). Others with iota do not expand at all.

See: https://godoc.org/github.com/ohir/bpbadgodoc [PoB copy of the bitpeek repo]

jackwilsdon commented 5 years ago

So it looks like this is caused by Bootstrap's getTargetFromTrigger function, which takes the href value from the link and passes it to jQuery's selector function;

function getTargetFromTrigger($trigger) {
  var href
  var target = $trigger.attr('data-target')
    || (href = $trigger.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7

  return $(target)
}

The issue is that href is actually percent-encoded, and that ends up creating an invalid selector (which jQuery throws an error because of). This is done by Go's html/template package, as can be seen in this example.

It looks like we can instead use data-target, which won't be percent-encoded by template/html and will be accepted by Bootstrap.