diff --git a/index.html b/index.html index 7860b8b..01328de 100644 --- a/index.html +++ b/index.html @@ -318,7 +318,7 @@ Point(x=1, y=2
  • Every class is a subclass and a superclass of itself.
  • >>> type('a'), 'a'.__class__, str
    -(<class 'str'>, <class 'str'>, <class 'str'>)
    +(<class 'str'>, <class 'str'>, <class 'str'>)
     

    Some types do not have builtin names, so they must be imported:

    from types import FunctionType, MethodType, LambdaType, GeneratorType
    @@ -770,10 +770,9 @@ creature  = Creature()
     class C(A, B): pass
     

    MRO determines the order in which parent classes are traversed when searching for a method:

    -
    >>> C.mro()
    -[<class 'C'>, <class 'A'>, <class 'B'>, <class 'object'>]
    -
    +[<class 'C'>, <class 'A'>, <class 'B'>, <class 'object'>] +

    Copy

    from copy import copy, deepcopy
     <object> = copy(<object>)
    diff --git a/parse.js b/parse.js
    index 61d1e3e..9ef0ccb 100755
    --- a/parse.js
    +++ b/parse.js
    @@ -30,8 +30,6 @@ const TOC =
       '}\n' +
       '
    \n'; -const MRO = - '
    >>> C.mro()\n[<class \'C\'>, <class \'A\'>, <class \'B\'>, <class \'object\'>]\n
    \n' function main() { const html = getMd(); @@ -94,23 +92,23 @@ function unindentBanner() { } function highlightCode() { - setApache('') - setApache('') - setApache('
    ') - setApache('') - setApache('') - setApache('') + setApaches(['', '', '
    ', '', '', '']); $('code').not('.python').not('.text').not('.bash').not('.apache').addClass('python'); $('code').each(function(index) { hljs.highlightBlock(this); }); - $('#copy').prev().remove() - const nodes = $.parseHTML(MRO); - $('#copy').before(nodes); + fixClasses() } -function setApache(codeContents) { - $(`code:contains(${codeContents})`).addClass('apache'); +function setApaches(elements) { + for (el of elements) { + $(`code:contains(${el})`).addClass('apache'); + } +} + +function fixClasses() { + // Changes class="hljs-keyword" to class="hljs-title" of 'class' keyword. + $('.hljs-class').filter(':contains(class \')').find(':first-child').removeClass('hljs-keyword').addClass('hljs-title') } function readFile(filename) {