当前位置: 首页 > news >正文

Word docx转html和markdown

Pypandoc使用pandoc来进行各种文本格式的转换。

安装

# 不带pandoc执行库
pip install pypandoc# 自带pandoc
pip install pypandoc_binary

使用

import pypandoc# convert all markdown files in a chapters/ subdirectory.
pypandoc.convert_file('chapters/*.md', 'docx', outputfile="somefile.docx")# convert all markdown files in the book1 and book2 directories.
pypandoc.convert_file(['book1/*.md', 'book2/*.md'], 'docx', outputfile="somefile.docx")# convert the front from another drive, and all markdown files in the chapter directory.
pypandoc.convert_file(['D:/book_front.md', 'book2/*.md'], 'docx', outputfile="somefile.docx")

支持pathlib

import pypandoc
from pathlib import Path# single file
input = Path('somefile.md')
output = input.with_suffix('.docx')
pypandoc.convert_file(input, 'docx', outputfile=output)# convert all markdown files in a chapters/ subdirectory.
pypandoc.convert_file(Path('chapters').glob('*.md'), 'docx', outputfile="somefile.docx")# convert all markdown files in the book1 and book2 directories.
pypandoc.convert_file([*Path('book1').glob('*.md'), *Path('book2').glob('*.md')], 'docx', outputfile="somefile.docx")
# pathlib globs must be unpacked if they are inside lists.

参考

https://pypi.org/project/pypandoc/
https://pandoc.org/help.html
https://www.strerr.com/cn/word2html.html
https://zhuanlan.zhihu.com/p/30891168
https://pypi.org/project/pandoc/

http://www.lryc.cn/news/208769.html

相关文章:

  • API商品数据接口调用爬虫实战
  • 【Python机器学习】零基础掌握GaussianProcessClassifier高斯过程
  • SQL-正则表达式和约束
  • “人类高质量数据”如何训练计算机视觉模型?
  • ListenableFuture和countdownlatch使用example
  • C- strtok() strtok_r()
  • order by数据过多引起的cpu飙升
  • namespace命名空间
  • golang中如何配置 sql.DB 以获得更好的性能
  • JAVA同城服务智慧养老小程序怎么开发?
  • Linux防火墙:Firewalld 常用命令
  • Java BigInteger比Long更大的整数自增转字符串存储
  • BigDecimal应用——计算费用场景中用到Integer,Double,BigDecimal三种类型出现的意外情况 结合BigDecimal源码分析
  • 数据抓取可以应用到哪些行业
  • 目标检测YOLO实战应用案例100讲-面向小目标检测的多尺度特征融合(续)
  • 如何选择适合的美颜SDK?
  • Spring-底层架构核心概念
  • RabbitMQ初入门
  • 电脑定时关机
  • 【算法】滑动窗口题单——4.不定长滑动窗口(求子数组个数)
  • CMake aux_source_directory 学习
  • Mybatis中延迟加载~
  • 【C语言】memmove()函数(拷贝重叠内存块函数详解)
  • 04-流媒体-ffmpeg.c源码分析
  • 迭代器 Iterator
  • 掌握CSS Flexbox,打造完美响应式布局,适配各种设备!
  • FlutterUnit 周边 | 收录排序算法可视化
  • 代码随想录Day30 贪心05 LeetCode T435无重叠区间 T763划分字母区间 T56 合并区间
  • 发展高质量存储力,中国高科技力量聚浪成潮
  • 修改svc的LoadBalancer的IP引发的惨案