scrivener_html_semi v2.0.1 Scrivener.HTML.Parse View Source
Link to this section Summary
Functions
Return default options.
Returns the raw data in order to generate the proper HTML for pagination.
Link to this section Functions
Return default options.
Returns the raw data in order to generate the proper HTML for pagination.
Default options
Default options are supplied as following:
[distance: 5, previous: "<<", next: ">>", first: true, last: true, ellipsis: {:safe, "…"}]
distance
declares how many pages are shown. It is a positive integer.previous
andnext
declares text for previous and next buttons. Generally, they are string. Falsy values will remove them from output.first
andlast
declares whether show first or last page. Genrally, they are boolean values, but they can be strings, too.
Return value
Return value is a list of tuples. The tuple is in a {text, page_number}
format
where text
is intended to be the text of the link and page_number
is the
page number it should go to.
Examples
iex> parse(%Scrivener.Page{total_pages: 10, page_number: 5}, [])
[
{"<<", 4},
{1, 1},
{2, 2},
{3, 3},
{4, 4},
{5, 5},
{6, 6},
{7, 7},
{8, 8},
{9, 9},
{10, 10},
{">>", 6}
]
iex> parse(%Scrivener.Page{total_pages: 15, page_number: 8}, first: "←", last: "→")
[
{"<<", 7},
{"←", 1},
{:ellipsis, {:safe, "…"}},
{3, 3},
{4, 4},
{5, 5},
{6, 6},
{7, 7},
{8, 8},
{9, 9},
{10, 10},
{11, 11},
{12, 12},
{13, 13},
{:ellipsis, {:safe, "…"}},
{"→", 15},
{">>", 9}
]