pandoc-lua-filters/test/test-functions.lua
2022-10-29 19:47:05 +02:00

37 lines
1.2 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)
== '\\tcrfenum{{mylabel}}')
assert(make_raw_content_tex(refs, 'page', false)
== '\\tcrfenum[noprefix]{{mylabel}}')
assert(make_raw_content_tex(refs, 'note', true)
== '\\tcrfenum[note]{{mylabel}}')
assert(make_raw_content_tex(refs, 'note', false)
== '\\tcrfenum[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)
== '\\tcrfenum{{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)
== '\\tcrfenum{{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)
== '\\tcrfenum{{first}{rangebeg to rangeend}}')