Testing out: prettify.js

Clear[getAuthorsForPaper];
stringCleanupRules = {"ü" -> "u", "Henry Tye" -> "Tye, Henry"};
getAuthorsForPaper[recid_] :=
    Module[ {header =
       "http://inspirehep.net/search?ln=en&ln=en&p=refersto%3Arecid%3A" <>
         ToString[recid] <>
        "&of=xe&action_search=Search&sf=&so=d&rm=&rg=250", firstBatch,
      cnt = 0, numRecs, data, allAuthors, countAuthors, t},
        t = AbsoluteTiming[
           data = {Import[header <> "&sc=0", "XML"]};][[1]];
        numRecs =
         StringSplit[data[[1, 1, -1, -1]], " "][[-1]] // ToExpression;
        StylePrint[
         "Looks like " <> ToString[numRecs] <> " cites. You've got a " <>
          ToString[Round[(numRecs - 250)*t/250/6]/10.] <>
          " minute wait to finish downloading."];
        While[numRecs > (cnt += 250),
         data = Append[data,
            Import[header <> "&jrec=" <> ToString[cnt + 1], "XML"]];];
        allAuthors = (StringSplit[#,
                 ","][[1]] & /@ (Reap[# /.
                   XMLElement["author", a___] :>
                    Sow[StringReplace[#, stringCleanupRules] & /@ {a}]] //
           Last // Flatten)) & /@ data // Flatten;
        countAuthors = (allAuthors // Tally);
        Map[Style[#[[1]], {FontSize ->
             14 + #[[2]] - Mean[countAuthors[[All, 2]]],
            ColorData["CMYKColors"][#[[2]]/Max[countAuthors[[All, 2]]]],
            Bold}] &, countAuthors // Sort]
    ]

compare with Gist include and default rendering:

Leave a Comment

(Please read comment policy before posting.)

Your email address will not be published. Required fields are marked *

Loading...