-- Descriptions arrive as HTML. A heading is its own paragraph: the text after -- it must not run into it ("Amazon.com ReviewWhat is most notable..."). package.path = "koreader-plugin/bookorbit.koplugin/?.lua;" .. package.path package.loaded["document/documentregistry"] = {} package.loaded["util"] = {} package.loaded["ffi/util"] = { template = function(text) return text end } package.loaded["gettext"] = function(text) return text end local CatalogUtil = require("bookorbit_catalog_util") local function assertEqual(actual, expected, label) if actual ~= expected then error(string.format("%s: expected %q, got %q", label, tostring(expected), tostring(actual))) end end local html = "

of those wild days known as growing up.

Amazon.com Review

What is most notable about this novel.

" assertEqual(CatalogUtil.cleanDescriptionText(html), "of those wild days known as growing up.\n\nAmazon.com Review\n\nWhat is most notable about this novel.", "a heading sits between paragraphs, apart from both") assertEqual(CatalogUtil.cleanDescriptionText("

Title

Body"), "Title\n\nBody", "a heading with attributes is still a heading") assertEqual(CatalogUtil.cleanDescriptionText("

One

Two

"), "One\n\nTwo", "paragraphs are unchanged") print("bookorbit_description_clean_test.lua: ok")