clic.migrate.region_preview: Mark up regions in text with ANSI colour codes

clic.migrate.region_preview.colourise_book(book, regions_to_highlight)

Based on algorithm in client/lib/corpora_utils

clic.migrate.region_preview.region_preview(cur, book_content=[''], highlight=['chapter.sentence', 'quote.quote', 'quote.suspension.short', 'quote.suspension.long', 'chapter.title', 'metadata.title', 'metadata.author'])

Endpoint that will mark up incoming text. This is temporary, and will be removed when a full UI is available.

Example:

curl -v --form 'book_content=@alice.txt' \
    http://.../api/region/preview? | less -RFi
clic.migrate.region_preview.script_region_preview()

Given a .txt file and any region.csv file, output a version with tags coloured. Usage:

# Highlight default regions within alice
./server/bin/region_preview corpora/ChiLit/alice.txt

# Highlight just quote.quote regions
./server/bin/region_preview corpora/ChiLit/alice.txt quote.quote

# Highlight tokens in book
./server/bin/region_preview corpora/ChiLit/alice.txt tokens