cs50/compare50

Move fragment slicing to .js

Jelleas opened this issue · 0 comments

The final step of compare50 is render:

def render(pass_to_results, dest):

This takes in a collection of Compare50Results

class Compare50Result:

And produces the rendered views.

However HTML does not allow for overlapping elements, and the regions (spans) of the file that match may very well overlap. To combat this problem, the RenderTask slices the code up into fragments like so:

image

class _FragmentSlicer:

In switching to dynamic rendering, this task needs to happen in JavaScript instead. Something like:

function create_fragments(code, spans) => fragments