-
Notifications
You must be signed in to change notification settings - Fork 5
/
odt-smallcaps.lua
37 lines (34 loc) · 1.33 KB
/
odt-smallcaps.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
--
-- Turns smallcaps into span with custom character style, when converting
-- to ODT. This is necessary because LibreOffice default smallcaps is not true
-- smallcaps, but rather reduced capitalised letters.
--
-- Currently, it's necessary to create the style "Versalete" on a reference-doc
-- to this filter properly work. To turn on true smallcaps, add ":smcp" to the
-- name of the font. For instance, "Myriad Pro:smcp". It's ugly, but currently
-- it's the only option to true smallcaps in LibreOffice (Word doesn't even
-- have an option like this, it's always fake smallcaps).
--
-- Syntax:
-- <text:span text:style-name="Versalete">
-- TEXT TO BE TRUE SMALLCAPS
-- </text:span>
--
-- dependencies: util.lua, need to be in the same directory of this filter
-- author:
-- - name: José de Mattos Neto
-- - address: https://github.com/jzeneto
-- date: february 2018 (first version)
-- license: GPL version 3 or later
local smallcapsStyle = 'Versalete'
local path = require 'pandoc.path'
utilPath = path.directory(PANDOC_SCRIPT_FILE)
dofile(path.join{utilPath, 'util.lua'})
function SmallCaps (sc)
if FORMAT == 'odt' then
local startTag = '<text:span text:style-name=\"' .. smallcapsStyle .. '\">'
local endTag = '</text:span>'
sc.content = util.putTagsOnContent(sc.content, startTag, endTag)
return pandoc.Span(sc.content)
end
end