您好 我需要编写一个bash脚本,将文件中的文本(txt,odt,doc等)更改为原始的html代码。它应该改变:
将空行分为段落(< p>< / p>)
带下划线的文本到标题中(< h>那个文本< / h>
答案 0 :(得分:1)
尝试创建一个openoffice宏,之后将通过命令行调用,例如 http://itnewsworld.blogspot.com/2008/01/converting-office-to-openoffice-batch.html 通过这种方式,您可以处理和生成OpenOffice支持的所有格式。
例如:
filename="a.odt"
oowriter -invisible "macro:///Standard.ModuleName.MacroName(filename)"
答案 1 :(得分:0)
您所描述的实际上是一种轻量级标记语言,实际上是多个existing markup languages的子集,例如markdown,reStructuredTest,AsciiDoc和{{3 }}
考虑使用其中一个现有工具将其中一个转换为html。
例如,在我的openSUSE框中:
安装:
sudo zypper install python-markdown
input.txt中:
this is a title
---------------
Here is one paragraph,
that continues in the next line.
And this is a new paragraph,
because of a blank line.
使用:
markdown input.txt
输出:
<h2>this is a title</h2>
<p>Here is one paragraph,
that continues in the next line.</p>
<p>And this is a new paragraph,
because of a blank line.</p>