Giter Site home page Giter Site logo

lakedoc's Introduction

Welcome to Lakedoc

查看Demo · 报告Bug · 提出新特性

Language Contributors Forks Stargazers Issues MIT License

目录


模块介绍

本模块基于 beautifulsoup4 所开发,在本地把 Lake 文档转换为指定格式的内容

<!doctype lake>  

遗憾的是,当前仅支持 Markdown 格式(精力有限),其余常用格式可以后续逐渐开发(欢迎各位开源社区的朋友们参与贡献)。

PS:因为该模块并不是网络爬虫工具,所以数据源请自行寻找

模块特性

  • 支持markdown 格式:已经适配大多数的文档,已采集简单到复杂的 Lake Document 共计测试 29 篇,还原度极高;
  • 允许上层开发者自定义转换器注册转换器使用转换器等等一些更高级的行为;
  • 使用非常简单,为上层提供一个接口 convert,入口函数进行伪重载,让使用更加方便。

图片未加载

快速入门

请根据你的 Python 环境选择合适的模块安装命令。大多数情况下,下方的命令通用:

pip install lakedoc

安装失败时,请自行利用搜索引擎查阅解决方案。当然也可以在 issues **同解决,通常检查镜像源依赖版本等常见问题。

在安装后,你可以使用如下的方式进行接口调用:

import lakedoc

# lakedoc.test_markdown()  # 可以测试是否有效

# 假设 ./test_data/content1.html 是源文件,./test_data/test1.md 是保存路径
read_path = './test_data/content1.html'
save_path = './test_data/test1.md'

# 仅读取路径
print(lakedoc.convert(read_path))
# 转换路径内容并保存
lakedoc.convert(read_path, save_path)

# 仅转换内容
with open(read_path, 'r', encoding='utf-8') as fr:
     html = fr.read()
print(lakedoc.convert(html, is_file=False))
# 转换内容并保存
lakedoc.convert(html, save_path, is_file=False)

# 设置的并不是文件名,而是最顶行(首行)添加 `# xxxxxxx`
lakedoc.convert(read_path, save_path, title='# 🚛 超详细Redis7.X 安装以及快速入门加常见面试题讲解')

# 保存的路径既可以是指向文件,也可以是一个已存在的目录!
# 存储目录时,使用时间戳命名,默认文件后缀是 md,使用参数 suffix='pdf' 可修改

鸣谢

在此,我要特别感谢以下开源项目和其贡献者们,没有他们的努力和贡献,我的项目 lakedoc 将寸步难行:

  • Beautiful Soup 4Beautiful Soup 4 是一个用于从 HTML 和 XML 文件中提取数据的 Python 库。

  • MarkdownifyMarkdownify 是一个将 HTML 转换为 Markdown 的 Python 库。

  • ColoramaColorama 是一个用于在 Windows 和其他平台上生成终端颜色输出的 Python 库,

lakedoc's People

Contributors

gupingan avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.