Fulib v0.1.18 Fulib.String.HTMLFormat View Source
Link to this section Summary
Link to this section Functions
Link to this function
convert_node_to_plain_text(arg, plain, opts) View Source
Link to this function
escape(text) View Source
Link to this function
format_list_item(plain, attrs, opts) View Source
Link to this function
format_list_level(children, spec \\ {0, 0, ""}) View Source
Link to this function
forward_to_body(binary) View Source
Link to this function
to_plain(html, opts \\ []) View Source
转换html文件为纯文本格式
参数:
html-html内容或html文件的路径。opts-一些配置参数,见下:is_path-指定html参数是否为文件路径,默认为:否。img_replace-指定遇到图片时替换的内容,默认为:[图片]。hr_replace-指定遇到<hr>标签时的替换内容,默认为:-。hr_count-指定<hr>标签替换长度,默认为:31。li_level_replace-指定<li>标签缩进,默认为:" ",即两个空格。li_trailing-指定<li>标签前缀,默认为:"* "。out_path-指定处理结果写入文件的地址,为空则不写。
Example
iex> html = "<hr>
...> <ul>
...> <li><img src='img.png'></li>
...> <li>一级第二个li标签</li>
...> </ul>"
iex> opts = [
...> is_path: false,
...> img_replace: "[图片]",
...> hr_replase: "-",
...> hr_count: 31,
...> li_level_replase: " ",
...> li_trailing: "* "
...> ]
iex> to_plain(html, opts)
-------------------------------
* [图片]
* 一级第二个li标签
Link to this function