欢迎阅读我的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. Note_Fem边界条件的处理和numpy实现的四种方法

    将单元刚度矩阵组装为全局刚度矩阵后,有: 此时的线性方程没有唯一解,\([K]\)是奇异矩阵,这是没有引入边界条件,消除刚体位移的原因. 边界条件分为两类:Forced and Geometric;对 ...

  2. 自动化平台-环境搭建2-cmd 下mysql 卸载命令

    "" net stop mysql sc delete mysql rd /s /q "C:\Program Files\MySQL" rd /s /q &qu ...

  3. wxformbuilder 如何生成python 代码

    ?问题 正常通过F8->F6 ,我执行这两步操作后如下图,以.fbp格式显示,没生成文件 解决方案 object properties 下勾选python 效果图:

  4. Qt Oracle往数据库里插入或者更新图片

    文章目录 Qt Oracle往数据库里插入或者更新图片 前言 读取本地图片文件 QPixmap 转 QByteArray 组成SQL,并执行 Qt Oracle往数据库里插入或者更新图片 前言 最近遇 ...

  5. Golang 入门 : 整型

    整型介绍 Go语言同时提供了有符号和无符号类型的整数运算.这里有 int8.int16.int32 和 int64 四种截然不同大小的有符号整形数类型,分别对应 8.16.32.64 bit大小的有符 ...

  6. laravel The Process class relies on proc_open, which is not available on your PHP installation.

    解决办法: 在php.ini中,找到disable_functions选项,看看后面是否有proc_open函数被禁用了,去掉proc_get_status,proc_open即可

  7. Ansible忽略任务失败

    在默认情况下,任务失败时会中止剧本任务,不过可以通过忽略失败的任务来覆盖此类行为.在可能出错且不影响全局的段中使用ignore_errors关键词来达到目的. 环境: 受控主机清单文件: [dev] ...

  8. Qt安装好后如何添加或删除组件

    一.使用MaintenanceTool进行管理 1.在Qt的安装路径下找到MaintenanceTool.exe,双击打开后,界面如下,(本人用的是5.10版本) 2.直接选择Skip,进入如下界面, ...

  9. element-ui和ant-design-vue 数字输入框只能输入大于等于1的整数

    限制输入的是大于等于1的整数 <template> <div> <h1>ant-design-vue 1.xx</h1> <a-input-num ...

  10. C++基础学习--随记

    博客地址:https://www.cnblogs.com/zylyehuo/ 参考"C++基础与深度解析" 一.预备知识 // c++常用工具 /usr/bin/time //查看 ...