scrivener_html_semi v3.0.1 Scrivener.HTML.Parse View Source

Link to this section Summary

Link to this section Functions

Link to this function

add_last(list, last, total_pages)

View Source

Return default options.

Link to this function

get_page_range(page_number, total_pages, range, left_distance, right_distance)

View Source
Link to this function

parse(page, options \\ [])

View Source

Returns the raw data in order to generate the proper HTML for pagination.

Default options

Default options are supplied as following:

[range: 5, prev: "PREV", next: "NEXT", first?: true, last?: true, ellipsis: {:safe, "…"}]
  • :range declares how many pages are shown. It should be an integer greater than or equal to 3.
  • :prev and :next declares text for previous and next buttons. Generally, they are string. Falsy values will remove them from output.
  • :first? and last? declares whether to show first / last page and corresponding ellipsis.
  • :ellipsis declares the text shown as ellipsis.

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}, [])
[
  {"PREV", 4},
  {1, 1},
  {:ellipsis, {:safe, "…"}},
  {4, 4},
  {5, 5},
  {6, 6},
  {:ellipsis, {:safe, "…"}},
  {10, 10},
  {"NEXT", 6}
]