-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b222819
commit 7ce7f11
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
local M = {} | ||
|
||
-- this extension covnerts links, tables of contents and other dynamic content in the ODT format to plain text | ||
|
||
local filter = require "make4ht-domfilter" | ||
|
||
-- this extension only works for the ODT format | ||
M.test = function(format) | ||
return format=="odt" | ||
end | ||
|
||
local function nodynamiccontent(dom) | ||
for _,link in ipairs(dom:query_selector("text|a")) do | ||
-- change links to spans | ||
link._name = "text:span" | ||
-- remove attributes | ||
link._attr = {} | ||
|
||
end | ||
for _, bibliography in ipairs(dom:query_selector("text|bibliography")) do | ||
-- remove links from bibliography | ||
-- use div instead of bibliography | ||
bibliography._name = "text:div" | ||
-- remove bibliography-source elements | ||
for _, source in ipairs(bibliography:query_selector("text:bibliography-source")) do | ||
source:remove_node() | ||
end | ||
for _, index in ipairs(bibliography:query_selector("text|index-body")) do | ||
-- use div instead of bibliography-entry | ||
index._name = "text:div" | ||
end | ||
|
||
end | ||
for _, toc in ipairs(dom:query_selector("text|table-of-content")) do | ||
-- remove links from toc | ||
-- use div instead of table-of-contents | ||
toc._name = "text:div" | ||
for _, entry in ipairs(toc:query_selector("text|index-body, text|index-title")) do | ||
-- use div instead of table-of-contents-entry | ||
entry._name = "text:div" | ||
end | ||
end | ||
return dom | ||
end | ||
|
||
M.modify_build = function(make) | ||
local process = filter({nodynamiccontent}, "nodynamiccontent") | ||
Make:match("4oo$",process) | ||
return make | ||
end | ||
|
||
return M |