-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom-filter.lua
More file actions
57 lines (48 loc) · 1.45 KB
/
custom-filter.lua
File metadata and controls
57 lines (48 loc) · 1.45 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
-- Function to remove Div blocks and any unnecessary custom attributes
function Div(el)
-- Remove all div blocks
return pandoc.Null
end
-- Function to remove Span blocks (common in metadata)
function Span(el)
return pandoc.Null
end
-- Remove any unwanted attributes from elements
function removeAttributes(el)
if el.attr then
el.attr = pandoc.Attr() -- Removes attributes but keeps content
end
return el
end
-- Customize Headers to simple Markdown-style
function Header(el)
local level = el.level
local hashes = string.rep("#", level)
return pandoc.Para({pandoc.Str(hashes .. " "), pandoc.Str(pandoc.utils.stringify(el))})
end
-- Keep Links in Markdown format, but remove extra attributes
function Link(el)
return removeAttributes(el)
end
-- Preserve Superscripts in HTML
function Superscript(el)
return pandoc.RawInline('html', '<sup>' .. pandoc.utils.stringify(el) .. '</sup>')
end
-- Process paragraphs and remove attributes
function Para(el)
return removeAttributes(el)
end
-- Remove unnecessary block elements like "RawBlock"
function RawBlock(el)
-- Remove raw content like article tags, section tags, and other metadata
return pandoc.Null
end
-- Remove inline raw content like images, icons, and extra metadata
function RawInline(el)
-- Strip out inline raw content like images and metadata
return pandoc.Null
end
-- Remove unnecessary image elements
function Image(el)
return pandoc.Null
end