harvard-lil / h2o

H2O is a web app for creating and reading open educational resources, primarily in the legal field
https://opencasebook.org
GNU Affero General Public License v3.0
37 stars 30 forks source link

Make section headings searchable in "Search Inside" #1835

Closed lizadaly closed 1 year ago

lizadaly commented 1 year ago

Fixes #1832

Adds section title content to the "Search Inside" feature.

This was a little less straightforward than I'd assumed at first because a TextBlock and a section aren't the same kind of thing. Since the Section proxy class is DOA, this code only cares about ContentNodes with the right (usually null) resource type.

I assumed we'd want to group section results in with "Text Passages" so it looks like this (the first two results are sections):

image

I considered labelling the sections as such but it doesn't seem necessary. Clicking on the section title takes you to the section.

Also shortened this function mostly by making some function calls guaranteed to return empty string or empty list results so a number of if/else checks could be eliminated.