MathHubInfo / Legacy-planetary

Legacy: Planetary System is a math-enabled Web 3.0 information portal.
http://trac.mathweb.org/planetary/
79 stars 25 forks source link

search result truncations aren't rendering correctly in MathML #376

Open holtzermann17 opened 11 years ago

holtzermann17 commented 11 years ago

Browsing in Chromium e.g. on this page: http://planetmath.org/search/site/Sierpi%C5%84ski%20gasket

Reveals some errors with the truncation:

The limiting <a property="http://alpha.planetmath.org/ns/linksTo" href="http://alpha.planetmath.org/node/31635">set</a> as
<math id="p1.1.m5.1" class="ltx_Math" alttext="n\rightarrow\infty" display="inline" xref="p1.1.m5.1.cmml"><semantics id="p1.1.m5.1a" xref="p1.1.m5.1.cmml"><mrow id="p1.1.m5.1.4" xref="p1.1.m5.1.4.cmml"><mi id="p1.1.m5.1.1" xref="p1.1.m5.1.1.cmml">n</mi><mo id="p1.1.m5.1.2" xref="p1.1.m5.1.2.cmml">→</mo><mi mathvariant="normal" id="p1.1.m5.1.3" xref="p1.1.m5.1.3.cmml">∞</mi></mrow><annotation-xml id="p1.1.m5.1.cmml" encoding="MathML-Content" xref="p1.1.m5.1"><apply id="p1.1.m5.1.4.cmml" xref="p1.1.m5.1.4"><ci id="p1.1.m5.1.2.cmml" xref="p1.1.m5.1.2">normal-→</ci><ci id="p1.1.m5.1.1.cmml" xref="p1.1.m5.1.1">n</ci><infinity id="p1.1.m5.1.3.cmml" xref="p1.1.m5.1.3"/></apply></annotation-xml><annotation id="p1.1.m5.1b" encoding="application/x-tex"...</annotation></semantics></math></p></div></section></p>

In particular, <annotation id="p1.1.m5.1b" encoding="application/x-tex"...</annotation> is just wrong -- it's a bit surprising that Firefox figures out how to handle this.


I think I've fixed this in the code on PM - instead of just searching for the final `, it will search for the final>`. I haven't pushed this b/c I have a lot of work to do to merge everything, but I'll get to that soon.

  if (!$exact) {
    // ...search the last occurance of space or > (and prefer to cut at >)
    $spacepos = strrpos($truncate, ' ');
    $ketpos = strrpos($truncate, '>')+1;
    if (isset($spacepos)) {
      if(isset($ketpos)){
    $truncate = substr($truncate, 0, max(array($spacepos,$ketpos)));
      } else {
    $truncate = substr($truncate, 0, $spacepos);
      }
    }
  }
dginev commented 10 years ago

My obligatory "don't parse XML with regexes or you WILL face bugs" comment.

Right way to implement this:

Is there a specification of what, how and when you're summarizing? I am not familiar with the feature. If it is a search-related feature I am guessing it is distributed and documented together with the Search module?