html - 如何在 EPUB 文件中的每个句子或文本行的末尾插入特定的 HTML 标记?
问题描述
我想在EPUB的源代码中插入这个HTML分页符:在标签<span style="page-break-after: always" />
中包含的每一行代码,<pre>
标签中的标题<h>
或标签中的句子之后<p>
,以便在阅读时显示每一句或每一行代码一次在屏幕上显示一个,如下所示:
Chapter 1 (user navigates to next page)
This is a story about something. (user navigates to next page)
And it involves computer programs: (user navigates to next page)
let x = y + 3 (user navigates to next page)
我相信我必须解压缩 .epub 文件并遍历解压缩目录中的所有文件。我必须导航到任何标签<h>
,<pre>
并且<p>
。我可以在换行符和句子上的这些标签之间拆分文本,并NLTK.sent_tokenize
在每个拆分之间插入上面的分页符标签,像这样吗?
这样:
<p>The APIs for Cocoa and its associated frameworks are written in Objective-C or its underlying base language, C. Messages that you send to Cocoa using Swift are being translated for you into Objective-C. Objects that you send and receive back and forth across the Swift/Objective-C bridge are Objective-C objects. Some objects that you send from Swift to Objective-C are even being translated for you into other object types, or into nonobject types.<a data-type="indexterm" data-primary="Objective-C" data-seealso="bridged types" id="idxobjectivecappendix"/></p>
变成这样:
<p>The APIs for Cocoa and its associated frameworks are written in Objective-C or its underlying base language, C. <span style="page-break-after: always" /> Messages that you send to Cocoa using Swift are being translated for you into Objective-C. <span style="page-break-after: always" /> Objects that you send and receive back and forth across the Swift/Objective-C bridge are Objective-C objects. <span style="page-break-after: always" /> Some objects that you send from Swift to Objective-C are even being translated for you into other object types, or into nonobject types. <span style="page-break-after: always" /> <a data-type="indexterm" data-primary="Objective-C" data-seealso="bridged types" id="idxobjectivecappendix"/></p>
或者是否有必要这样做:
<p>The APIs for Cocoa and its associated frameworks are written in Objective-C or its underlying base language, C. </p> <span style="page-break-after: always" /> <p> Messages that you send to Cocoa using Swift are being translated for you into Objective-C. </p> <span style="page-break-after: always" /> <p> Objects that you send and receive back and forth across the Swift/Objective-C bridge are Objective-C objects. </p> <span style="page-break-after: always" />
(ETC。)
谁能提供一个达到预期效果的脚本?非常感谢。
解决方案
推荐阅读
- ios - Swift Fortune Wheel 变色问题
- node.js - VsCode远程连接在远程服务器上创建节点进程?
- python - 如何创建组列
- reactjs - 我需要导入什么才能在 FullCalendar 中使用主题?
- iframe - 为什么 iframe 中的 unqork 应用程序无法从 Chrome 隐身模式启动
- android - 为每个 Recyclerview 独立添加 Shimmer
- powershell - MSI 安装命令在本地工作,但不能通过 PowerShell 远程处理
- sql - 选择 case when then 有多个值
- json - 是否可以向 django rest api 发送请求以运行脚本?
- opencv - 从 SuperPixels 获取多边形顶点(轮廓)