欢迎阅读我的blog!

个人网站阅读《markitdown 的安装和简单使用》

安装

microsoft/markitdown: Python tool for converting files and office documents to Markdown.

官网给出了两个方法:

目前(20250224),直接使用pip install markitdown会安装markitdown-0.0.1a4,而目前最新版是markitdown-0.0.2a1,故建议用第二种方法从源代码进行构建:

git clone git@github.com:microsoft/markitdown.git
cd markitdown
pip install -e packages/markitdown

主要参数解释

-h, --help:显示帮助信息

-v, --version:显示版本号

-o OUTPUT, --output OUTPUT:指定输出文件名(如果不指定,将输出到控制台)

-d, --use-docintel:使用文档智能服务来提取文本(需要有效的 Document Intelligence 端点)

-p, --use-plugins:使用第三方插件来转换文件

--list-plugins:列出已安装的第三方插件

使用

基本信息

在命令行输入 markitdown -v 会输出版本:

C:\Users\Vanilla>
markitdown 0.0.2a1

输出帮助信息: markitdown -h

测试第三方插件:markitdown --list-plugins

docx文件测试

我选择之前美赛的论文进行测试。

这份完整的数模论文该有的部件都有:公式、图片、表格、题注、多级标题、加粗、斜体、链接、序号、页眉;其中,行间公式使用的是mathtype,行内公式使用的是word自带的公式编辑器。

执行命令

Measure-Command {
markitdown .\MCM-finish.docx -o docx.md
}

部分测试结果

摘要部分

提取结果:

Saving Juneau: Sustainable Development in Tourism

**Summary**

Excessive tourism in Juneau City has caused environmental and social challenges. To address these issues and promote sustainable development, we developed a multi-objective optimization model for sustainable tourism and applied it to Juneau City.

We constructed a general multi-objective optimization model with **tourist numbers** as the decision variable. The **objective function** integrates economic, environmental, and social factors, resulting in six goals. **Constraints** include carbon emissions, water resource utilization, and waste management. Further research will refine this model for application in other cities.

可以发现:

  • 页眉完全没有被提取
  • 标题 Saving Juneau: Sustainable Development in Tourism 原本是标题,这里变成了正常文本
  • 加粗正常

目录部分

提取结果:

**Contents**

[1 Introduction 3](#_Toc188935048)

[1.1 Background 3](#_Toc188935049)

[1.2 Restatement of the problem 3](#_Toc188935050)

[1.3 Our works 4](#_Toc188935051)

[2 Model Preparation 4](#_Toc188935052)

[2.1 Assumptions and Justifications 4](#_Toc188935053)

[2.2 Notations 5](#_Toc188935054)

[3 Juneau: A Sustainable Tourism Model 6](#_Toc188935055)
  • 原本目录是可以跳转的。可以发现,这里转换的保留了跳转域,但是完全不可用啊……

正文部分

转换结果:

# Introduction

## Background

![图示

描述已自动生成](data:image/png;base64...)

Figure :Current situation map of Juneau City[1]

In 2023, Juneau, Alaska, hosted 1.6 million cruise passengers, with a daily peak of up to 20,000 visitors. While this influx brought significant economic benefits, it also caused overcrowding and accelerated glacial retreat, impacting natural attractions and potentially deterring future tourists. Additionally, excessive tourism has increased hidden costs related to infrastructure strain, environmental damage, and social challenges.

可以发现:

  • 一级、二级标题格式转换正常

  • 图片似乎是想要转换为base64的格式,但是

    • 内容没有发生转换

    • 图片描述是word自动生成的一句提示“图示描述已自动生成”,但是自动生成的描述去哪里了呢?

    • 图片描述中间还有两个换行符是怎么回事

  • 图片题注变成了正常文本,但是图片序号(包含域信息)消失了

  • 引用直接变成了纯文本

符号说明部分

转换结果:

* **Assumption 2:** Ignoring the carbon footprint caused by tourists' use of transportation within the city of Juneau.
* Justification: Juneau has no direct roads. Most tourists choose cruise ships or planes to reach there. In contrast, the carbon footprint generated by tourists' sightseeing within the city can be negligible. ## Notations | Notation | Description | Unit |
| --- | --- | --- |
| | Direct income from tourism | USD |
| | The i-th source of direct income from tourism | USD |
| | Tax revenue | USD |
| | Daily water consumption per tourist | L/person/day |
| | Carbon footprint | t |

可以发现:

  • 序号转换成功,这里使用的是 *,使用着
  • 表格正常转换
  • 表格中最左边一列是word公式,全部消失

附录部分

# References

1. Background image source: Travel Juneau. (n.d.). *Home*. <https://www.traveljuneau.com/>
2. LSC Transportation Consultants, Inc. (2024). *Juneau visitor circulator study final report (Prepared for City and Borough of Juneau)*. <https://juneau.org/wp-content/uploads/2024/02/Juneau-Visitor-Circulator-Study-Final-Report-2024-1.pdf>

可以发现:

  • 斜体正常
  • 链接正常,但是这里直接使用了 <link> 的方式而非 markdown 中更常用的 [name](link)

测试总结

文档部件 转换情况 备注
文件类型 docx 最新版的word
文件大小 16.3MB 图片较多,分辨率较大;25页,计空格39578字
转换耗时 2.4986917 可以说是挺快的了
公式 × 所有公式直接消失了
图片 × 完全不可用
表格
题注 变成文字
多级标题 多级标题正常;普通标题变成正常文本
加粗
斜体
链接
序号
页眉 × 消失
目录 正常文本,域跳转不可用

pdf文件测试

执行命令

Measure-Command {
markitdown .\MCM-finish.pdf -o pdf.md
}

部分测试结果

摘要部分

提取结果:

Problem Chosen
X 2025
MCM/ICM
Summary Sheet Team Control Number XXXXXXX Saving Juneau: Sustainable Development in Tourism Summary Excessive tourism in Juneau City has caused environmental and social challenges.
To address these issues and promote sustainable development, we developed a multi-
objective optimization model for sustainable tourism and applied it to Juneau City. We constructed a general multi-objective optimization model with tourist
numbers as the decision variable. The objective function integrates economic,
environmental, and social factors, resulting in six goals. Constraints include carbon
emissions, water resource utilization, and waste management. Further research will
refine this model for application in other cities. Task 1: We extended the model by adding sales tax and hotel tax as decision
variables and maximizing tax revenue with related constraints. Using literature review
and linear regression, we determine the values, estimate the parameters and applied the
NSGA-II algorithm to find Pareto optimal solutions. The entropy weight method

可以发现:

  • 页眉的文字也能够转换了,虽然格式有点乱,但是至少是有的
  • 摘要部分的每一个自动换行都变成了换行符。这应该是与PDF存段落的方式(每行分开存储)有关
  • 没有任何的格式(加粗没了)

目录部分

提取结果:

Team#XXXXXXX

Page  2  of  25

Contents

1

Introduction ..................................................................................................... 3
1.1 Background ......................................................................................... 3
1.2 Restatement of the problem ................................................................. 3
1.3 Our works ............................................................................................ 4
2 Model Preparation ........................................................................................... 4
2.1 Assumptions and Justifications ........................................................... 4
2.2 Notations ............................................................................................. 5
3 Juneau: A Sustainable Tourism Model ............................................................ 6
  • 页眉部分正常
  • 没有能够跳转域信息
  • 所见即所得:PDF中的所有文本都被成功的转换了,最大程度的保留了文本信息

正文部分

转换结果:

1  Introduction

1.1 Background

Figure 1:Current situation map of Juneau City[1]

In 2023, Juneau, Alaska, hosted 1.6 million cruise passengers, with a daily peak
of up to 20,000 visitors. While this influx brought significant economic benefits, it also
caused overcrowding and accelerated glacial retreat, impacting natural attractions and
potentially deterring future tourists. Additionally, excessive tourism has increased
hidden costs related to infrastructure strain, environmental damage, and social
challenges.

可以发现:

  • 没有一级、二级标题格式,但是有一级、二级序号

  • 图片完全消失

  • 图片题注当然也没有

  • 引用变成了纯文本

符号说明部分

转换结果:

  Justification: Juneau has no direct roads. Most tourists choose cruise ships or
planes to reach there. In contrast, the carbon footprint generated by tourists'
sightseeing within the city can be negligible. 2.2 Notations Notation Description
Direct income from tourism
The i-th source of direct income from tourism
Tax revenue
Daily water consumption per tourist …… Unit
USD
USD
USD
L/person/day

可以发现:

  • 序号转换成了不知道是个什么东西:
  • 表格格式转换失败,只有文字
  • 表格中最左边一列是word公式,全部消失
  • 遵循的是先行再列而不是先列再行,不符合逻辑

附录部分

References

[1]  Background  image  source:  Travel  Juneau.  (n.d.). Home. https://www.traveljuneau.com/

[2]  LSC  Transportation  Consultants,  Inc.  (2024).  Juneau  visitor  circulator  study  final  repo

rt  (Prepared  for  City  and  Borough  of  Juneau).  https://juneau.org/wp-content/uploads/20

24/02/Juneau-Visitor-Circulator-Study-Final-Report-2024-1.pdf

可以发现:

  • 斜体格式消失
  • 链接有的正常有的不正常,因为换行会把链接截断
  • 链接没有使用markdown的格式而是裸露的网址

测试总结

文档部件 转换情况 备注
文件类型 pdf
文件大小 5.42MB 图片较多,分辨率较大;25页,计空格39578字
转换耗时 12.411024 比word转md慢,大约是其5倍
公式 × 所有公式直接消失了
图片 × 图片消失
表格 × 表格格式消失
题注 变成文字
多级标题 × 变成(带序号的)正常文本
加粗 ×
斜体 ×
链接 × 纯文本,且会被换行截断
序号 × 纯文本
页眉 纯文本
目录 纯正常文本

markitdown的安装与简单使用的更多相关文章

  1. (转)python requests的安装与简单运用

    requests是python的一个HTTP客户端库,跟urllib,urllib2类似,那为什么要用requests而不用urllib2呢?官方文档中是这样说明的: python的标准库urllib ...

  2. MongoDB在Windows下安装、Shell客户端的使用、Bson扩充的数据类型、MongoVUE可视化工具安装和简单使用、Robomongo可视化工具(2)

    一.Windows 下载安装 1.去http://www.mongodb.org/downloads下载,mongodb默认安装在C:\Program Files\MongoDB目录下,到F:\Off ...

  3. python requests的安装与简单运用

    requests是python的一个HTTP客户端库,跟urllib,urllib2类似,那为什么要用requests而不用urllib2呢?官方文档中是这样说明的: python的标准库urllib ...

  4. memcache的windows下的安装和简单使用

    原文:memcache的windows下的安装和简单使用 memcache是为了解决网站访问量大,数据库压力倍增的解决方案之一,由于其简单实用,很多站点现在都在使用memcache,但是memcach ...

  5. 【RabbitMQ】RabbitMQ在Windows的安装和简单的使用

    版本说明 使用当前版本:3.5.4 安装与启动 在官网上下载其Server二进制安装包,在Windows上的安装时简单的,与一般软件没什么区别. 安装前会提示你,还需要安装Erlang,并打开下载页面 ...

  6. Thrift的安装和简单演示样例

    本文仅仅是简单的解说Thrift开源框架的安装和简单使用演示样例.对于具体的解说,后面在进行阐述. Thrift简述                                           ...

  7. libmemcached安装及简单例子

    libmemcached安装及简单例子 1.下载安装libmemcached  $ wget http://launchpad.net/libmemcached/1.0/0.44/+download/ ...

  8. [hadoop系列]Pig的安装和简单演示样例

    inkfish原创,请勿商业性质转载,转载请注明来源(http://blog.csdn.net/inkfish ).(来源:http://blog.csdn.net/inkfish) Pig是Yaho ...

  9. Redis 安装与简单示例

    Redis 安装与简单示例 一.Redis的安装 Redis下载地址如下:https://github.com/dmajkic/redis/downloads 解压后根据自己机器的实际情况选择32位或 ...

  10. Redis 安装与简单使用

    安装 Redis 一般系统都会有软件管理工具,但是通常版本都不会太新,况且 Redis 的安装很简单,因此下面使用源码的安装方式. 下载源码 wget http://download.redis.io ...

随机推荐

  1. manim边学边做--局部缩放的场景类

    在动画制作中,尤其是数学和科学可视化领域,有时我们需要将观众的注意力集中在场景的某个特定部分. Manim提供了一个强大的工具 ZoomedScene,它允许我们在场景中创建一个独立的缩放视图,从而实 ...

  2. django4.2 与python 最新对应关系表

  3. Netty基础—2.网络编程基础二

    大纲 1.网络编程简介 2.BIO网络编程 3.AIO网络编程 4.NIO网络编程之Buffer 5.NIO网络编程之实战 6.NIO网络编程之Reactor模式 1.网络编程简介 既然是通信,那么肯 ...

  4. [python] 使用Python实现Markdown文档格式转换

    本文主要介绍如何利用Python中的MarkItDown库将多种文件高效转换为Markdown文本,以及如何使用Python-Markdown库将Markdown文本转换为HTML(超文本标记语言)文 ...

  5. 【软件】基于JSP和Bootstrap的潇湘博客平台

    潇湘博客平台 XiaoXiangBlog 说明 Eclipse 项目 - Version: 2020-06 (4.16.0). JDK8. 潇湘博客(XiaoXiangBlog) 一个简单的Java ...

  6. 为Avalonia应用添加图标

    前言 为了让自己开发的应用更加好看,开发者往往需要增加一些图标. 本文分享在开发Avalonia应用时如何为应用增加图标,希望可以帮助到正在学习使用Avalonia并有此需求的开发者. 实践 经过搜索 ...

  7. Linux centos8 VPS基本配置之SSH

    Linux centos8 VPS基本配置之SSH 最近在使用阿里云的时候,需要安装一些nodejs模块,但是总是安装失败,我已经使用了淘宝镜像cnpm加速,查看了具体原因是有github的依赖. 阿 ...

  8. 0x01 基础算法

    目录 基础算法 排序 快速排序 归并排序 二分 整数二分 浮点数二分 高精度 输入输出 高精度加法 高精度减法 高精度乘法 高精度除法 前缀和 差分 双指针算法 位运算 离散化 区间合并 基础算法 排 ...

  9. CH39x产品介绍

    CH39x产品介绍 芯片 CH392 CH395 CH390 接口 异步串口/SPI 异步串口/SPI/8位并口(仅CH395L支持) SPI/16位或8位并口(仅CH390L支持) 网口速率 10M ...

  10. mybatis-plus.global-config.db-config.id-type=auto 和 @TableId(value = "id", type = IdType.ASSIGN_ID)哪个优先生效

    对于id自动生成的方式,有注解和配置两种. 含义相同:不过设置自动增长的时候必须保证数据库中id是自增,assign_id和assign_uuid则不需要. yml配置: mybatis-plus: ...