pandoc-lua-filters/test/test-functions.lua
2022-11-06 21:51:12 +01:00

37 lines
1.3 KiB
Lua

local refs
refs = parse_references_enum('mylabel')
assert(#refs == 1)
assert(refs[1].anchor == 'mylabel')
assert(not refs[1].end_of_range)
assert(make_raw_content_tex(refs, 'page', true)
== '\\crossrefenum{{mylabel}}')
assert(make_raw_content_tex(refs, 'page', false)
== '\\crossrefenum[noprefix]{{mylabel}}')
assert(make_raw_content_tex(refs, 'note', true)
== '\\crossrefenum[note]{{mylabel}}')
assert(make_raw_content_tex(refs, 'note', false)
== '\\crossrefenum[note][noprefix]{{mylabel}}')
refs = parse_references_enum('rangebeg>rangeend')
assert(#refs == 1)
assert(refs[1].anchor == 'rangebeg')
assert(refs[1].end_of_range == 'rangeend')
assert(make_raw_content_tex(refs, 'page', true)
== '\\crossrefenum{{rangebeg to rangeend}}')
refs = parse_references_enum('first, second')
assert(#refs == 2)
assert(refs[1].anchor == 'first')
assert(refs[2].anchor == 'second')
assert(make_raw_content_tex(refs, 'page', true)
== '\\crossrefenum{{first}{second}}')
refs = parse_references_enum('first, rangebeg>rangeend')
assert(#refs == 2)
assert(refs[1].anchor == 'first')
assert(refs[2].anchor == 'rangebeg')
assert(refs[2].end_of_range == 'rangeend')
assert(make_raw_content_tex(refs, 'page', true)
== '\\crossrefenum{{first}{rangebeg to rangeend}}')