### Python Virtual Environment Setup Source: https://github.com/itsme1229/markitdown/blob/main/README.md Demonstrates how to create and activate a Python virtual environment using standard 'venv', 'uv', and 'conda'. This is a prerequisite for installing MarkItDown to avoid dependency conflicts. ```bash python -m venv .venv source .venv/bin/activate ``` ```bash uv venv --python=3.12 .venv source .venv/bin/activate # NOTE: Be sure to use 'uv pip install' rather than just 'pip install' to install packages in this virtual environment ``` ```bash conda create -n markitdown python=3.12 conda activate markitdown ``` -------------------------------- ### Install Markitdown with specific feature groups Source: https://context7.com/itsme1229/markitdown/llms.txt This section shows how to install Markitdown with support for various file types by specifying optional dependencies. For example, to process Excel files, you would install `markitdown[xlsx]`. This allows for a modular installation, reducing the package size if only specific converters are needed. ```bash pip install 'markitdown[xlsx]' # Excel files pip install 'markitdown[xls]' # Legacy Excel files pip install 'markitdown[pdf]' # PDF files pip install 'markitdown[docx]' # Word documents pip install 'markitdown[pptx]' # PowerPoint presentations pip install 'markitdown[outlook]' # Outlook MSG files pip install 'markitdown[audio-transcription]' # Audio files (wav, mp3) pip install 'markitdown[youtube-transcription]' # YouTube videos pip install 'markitdown[az-doc-intel]' # Azure Document Intelligence ``` -------------------------------- ### Install and Run Tests with Hatch Source: https://github.com/itsme1229/markitdown/blob/main/README.md Installs the 'hatch' build tool and its dependencies, activates a shell environment, and then executes the test suite. Assumes Python environment is set up. ```shell pip install hatch hatch shell hatch test ``` -------------------------------- ### Optional Dependencies Installation for MarkItDown Source: https://context7.com/itsme1229/markitdown/llms.txt Optimize your MarkItDown installation by selectively installing only the necessary converters using feature groups. This reduces the overall installation size and helps avoid potential dependency conflicts. ```bash # Install all converters pip install 'markitdown[all]' # Install specific converters pip install 'markitdown[pdf,docx,pptx]' ``` -------------------------------- ### Install and Use MarkItDown Plugin (Bash) Source: https://github.com/itsme1229/markitdown/blob/main/packages/markitdown-sample-plugin/README.md These bash commands demonstrate how to install a MarkItDown plugin locally using pip and verify its availability. It also shows the command-line usage for converting an RTF file with the installed plugin. ```bash pip install -e . markitdown --list-plugins markitdown --use-plugins path-to-file.rtf ``` -------------------------------- ### Install MarkItDown from Source Source: https://github.com/itsme1229/markitdown/blob/main/README.md Instructions for installing MarkItDown by cloning the repository and installing it in editable mode with all dependencies. This method is useful for developers who need to modify the package. ```bash git clone git@github.com:microsoft/markitdown.git cd markitdown pip install -e 'packages/markitdown[all]' ``` -------------------------------- ### Install MarkItDown Package Source: https://github.com/itsme1229/markitdown/blob/main/packages/markitdown/README.md Installs the MarkItDown package from PyPI, including all optional dependencies for full functionality. Alternatively, installation from source is supported via git clone and pip. ```bash pip install markitdown[all] ``` ```bash git clone git@github.com:microsoft/markitdown.git cd markitdown pip install -e packages/markitdown[all] ``` -------------------------------- ### Install Optional MarkItDown Dependencies Source: https://github.com/itsme1229/markitdown/blob/main/README.md Installs specific optional dependencies for MarkItDown to support various file formats like PDF, DOCX, and PPTX. This allows for granular control over the installed features, avoiding unnecessary packages. ```bash pip install 'markitdown[pdf, docx, pptx]' ``` -------------------------------- ### Enable MarkItDown Plugin in Python Source: https://github.com/itsme1229/markitdown/blob/main/packages/markitdown-sample-plugin/README.md This Python code shows how to enable and use installed MarkItDown plugins programmatically. It involves creating a MarkItDown instance with `enable_plugins=True` and then calling the `convert` method with the path to the file to be processed. ```python from markitdown import MarkItDown md = MarkItDown(enable_plugins=True) result = md.convert("path-to-file.rtf") print(result.text_content) ``` -------------------------------- ### MarkItDown Command-Line Conversion Source: https://github.com/itsme1229/markitdown/blob/main/README.md Examples of using the MarkItDown command-line interface to convert a PDF file to Markdown. Shows both redirecting output to a file and specifying the output file with the -o flag. Also demonstrates piping content directly. ```bash markitdown path-to-file.pdf > document.md ``` ```bash markitdown path-to-file.pdf -o document.md ``` ```bash cat path-to-file.pdf | markitdown ``` -------------------------------- ### List and Enable MarkItDown Plugins Source: https://github.com/itsme1229/markitdown/blob/main/README.md Commands to manage plugins for MarkItDown. `--list-plugins` shows installed plugins, while `--use-plugins` enables them for file processing. Plugins extend MarkItDown's functionality and are disabled by default. ```bash markitdown --list-plugins ``` ```bash markitdown --use-plugins path-to-file.pdf ``` -------------------------------- ### Run Tests using Devcontainer Source: https://github.com/itsme1229/markitdown/blob/main/README.md Executes the project's test suite within a pre-configured development container environment. This method ensures all dependencies are already installed and consistent. ```shell hatch test ``` -------------------------------- ### Performance Timing and Marking (JavaScript) Source: https://github.com/itsme1229/markitdown/blob/main/packages/markitdown/tests/test_files/test_serp.html This snippet provides functions for setting the start time, marking specific performance events, recording navigation data, and flushing performance logs. It leverages the browser's Performance API if available, otherwise falls back to using Date objects. It's essential for measuring navigation and resource loading times. ```javascript var perf = perf || {}; (function(n) { var t = [], i = !1, l, r, e; var a = function() { return window.performance && performance.now ? performance.now() : new Date - (window.si_ST || 0); }; var p = function(e) { r = e; }; var w = function(t, i) { if (!i || typeof i !== 'number') return; t = t || 'mark'; if (l) { var o = a(); t = t + ':' + Math.round(o - r); } else { t = t + ':' + Math.round(i - r); } n.log(t, o); }; var b = function(t, i) { if (!i || typeof i !== 'number') return; if (!l) return; var o = a(); n.log(t, o, i); }; var u = function() { if (i) return; var t = a(); n.log('flush', t, r); t = []; i = !0; }; var k = function() { r = a(); e = window.fp || 0; i = !1; }; if (window.performance && performance.timing) { l = !0; r = performance.timing.navigationStart; } else { r = window.si_ST ? window.si_ST : new Date; } e = window.fp || 0; n.setStartTime = p; n.mark = w; n.record = b; n.flush = u; n.reset = k; sj_be(window, 'load', u, !1); sj_be(window, 'beforeunload', u, !1); })(perf || (perf = {})); ``` -------------------------------- ### Configure MarkItDown Plugin Entrypoint (TOML) Source: https://github.com/itsme1229/markitdown/blob/main/packages/markitdown-sample-plugin/README.md This TOML configuration snippet defines the entry point for a MarkItDown plugin within the `pyproject.toml` file. It specifies a key (e.g., `sample_plugin`) that identifies the plugin and maps it to the fully qualified name of the Python package that implements the plugin. ```toml [project.entry-points."markitdown.plugin"] sample_plugin = "markitdown_sample_plugin" ``` -------------------------------- ### User Navigation and Connection Metrics (JavaScript) Source: https://github.com/itsme1229/markitdown/blob/main/packages/markitdown/tests/test_files/test_serp.html This function `si_PP` captures and records various performance metrics related to user navigation, connection type, and page load. It sends this data as an image request for logging. It also includes optional parameters for page type and other custom data, making it useful for detailed performance analysis. ```javascript window.si_PP = function(n, t, i) { var r, o, a, h, e, c, l, v; if (!_G.PPS) { for (o = ["FC", "BC", "SE", "TC", "H", "BP", null]; r = o.shift(); ) o.push('"' + r + '":' + (_G[r + "T"] ? _G[r + "T"] - _G.ST : -1)); var u = window.perf, s = "navigation", r, f = i || window.performance && window.performance.timing; if (f && u) { if (a = f.navigationStart, u.setStartTime(a), a >= 0) { for (r in f) h = f[r], typeof h == "number" && h > 0 && r !== "navigationStart" && r !== s && u.mark(r, h); _G.FCT && u.mark("FN", _G.FCT); _G.BCT && u.mark("BN", _G.BCT) } u.record("nav", s in f ? f[s] : performance[s].type) } e = "connection"; c = ""; window.navigator && navigator[e] && (c = ',"net":"' + navigator[e].type + '"', navigator[e].downlinkMax && (c += ',"dlMax":"' + navigator[e].downlinkMax + '"')); l = window.ChatMergeLogHelper; typeof l != "undefined" && typeof l.getBotRequestId == "function" && (v = l.getBotRequestId()); _G.PPImg = new Image; _G.PPImg.src = _G.lsUrl + '&Type=Event.CPT&DATA={"pp":{"S":"' + (t || "L") + '",' + o.join(",") + ',"CT":' + (n - _G.ST) + ',"IL":' + _d.images.length + "}} marketdown" + (_G.C1 ? "," + _G.C1 : "") + c + "}" + (_G.P ? "&P=" + _G.P : "") + (_G.DA ? "&DA=" + _G.DA : "") + (_G.MN ? "&MN=" + _G.MN : "") + (v ? "&rid=" + v : ""); _G.PPS = 1; sb_st(function() { u && u.flush(); sj_evt.fire("onPP"); sj_evt.fire(window.p1) }, 1) } }; window.onbeforeunload = function() { si_PP(new Date, "A") }; sj_evt.bind("ajax.requestSent", function() { window.perf && perf.reset() }); ``` -------------------------------- ### Configuration: Entity Preview Settings (JavaScript) Source: https://github.com/itsme1229/markitdown/blob/main/packages/markitdown/tests/test_files/test_serp.html Defines a configuration object for entity preview features. It includes settings for a feature list and a boolean flag for test hooks, allowing customization of the preview behavior. ```javascript var EntityPreviewConfig = { featureList: "", testHooks: false }; ``` -------------------------------- ### CSS Styling for Image Carousels Source: https://github.com/itsme1229/markitdown/blob/main/packages/markitdown/tests/test_files/test_serp.html This CSS code styles an image carousel component, specifically targeting elements related to slide expansion and navigation. It controls the width and margin of individual slides, applies rounded borders, and manages the visibility and appearance of 'see more' indicators. These styles are applied to elements with IDs starting with 'slideexp0_F4EC09'. ```css #slideexp0_F4EC09 .slide { width: 280px; margin-right: 8px; } #slideexp0_F4EC09c .b_slidebar .slide { border-radius: 6px; } #slideexp0_F4EC09 .slide:last-child { margin-right: 1px; } #slideexp0_F4EC09c { margin: -4px; } #slideexp0_F4EC09c .b_viewport { padding: 4px 1px 4px 1px; margin: 0 3px; } #slideexp0_F4EC09c .b_slidebar .slide { box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05); -webkit-box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05); } #slideexp0_F4EC09c .b_slidebar .slide.see_more { box-shadow: 0 0 0 0px rgba(0, 0, 0, 0.00); -webkit-box-shadow: 0 0 0 0px rgba(0, 0, 0, 0.00); } #slideexp0_F4EC09c .b_slidebar .slide.see_more .carousel_seemore { border: 0px; } #slideexp0_F4EC09c .b_slidebar .slide.see_more:hover { box-shadow: 0 0 0 0px rgba(0, 0, 0, 0.00); -webkit-box-shadow: 0 0 0 0px rgba(0, 0, 0, 0.00); } ``` -------------------------------- ### JavaScript Initialization and Configuration Source: https://github.com/itsme1229/markitdown/blob/main/packages/markitdown/tests/test_files/test_serp.html This snippet demonstrates the initialization of JavaScript variables and configuration objects. It includes setting boolean flags and defining a 'fab_config' object with specific settings for a floating action button. These settings control its appearance, actions on click and hover, and visibility. ```javascript V2={}));var ClickBackRSCustomControl = false;;var fab_config ={"fabStyle":1,"fabSbAction":"OpenChat","fabSbActionHover":"None","fabSbActionData":"None","fabTooltip":"","micFabAlwaysVisible":false,"fabClickNoAS":false,"FabAddSuggestions":false,"DisableAlsoTryWhenHasPoleRS":false};;sj_be(_w, "click", function() { _G.UIWP = true; }, 1);; // ``` -------------------------------- ### Build and Run MarkItDown with Docker Source: https://github.com/itsme1229/markitdown/blob/main/README.md Provides Docker commands for building a MarkItDown image and running it as a container. The build command creates a 'markitdown:latest' image. The run command executes the container, processing input from stdin and writing output to stdout. ```bash docker build -t markitdown:latest . docker run --rm -i markitdown:latest < ~/your-file.pdf > output.md ``` -------------------------------- ### Behavior Management Module Initialization (JavaScript) Source: https://github.com/itsme1229/markitdown/blob/main/packages/markitdown/tests/test_files/test_serp.html This code initializes the Behavior Management (`BM`) module, defining essential functions like `wireup`, `enqueue`, `dequeue`, and `trigger`. These functions are used to register, manage, and execute behavior rules and event handlers for UI elements. ```javascript var BM = BM || {}; (function(n) { function u(n, u) { n in t || (t[n] = []); !u.compute || n in r || (r[n] = u.compute); !u.unload || n in i || (i[n] = u.unload); u.load && u.load() } function f(n, i) { t[n].push({t: s(), i: i}) } function e(n) { return n in i && i[n](), n in t ? t[n] : void 0 } function o() { for (var n in r) r[n]() } function s() { return window.performance && performance.now ? Math.round(performance.now()) : new Date - window.si_ST } var t = {}, i = {}, r = {}; n.wireup = u; n.enqueue = f; n.dequeue = e; n.trigger = o })(BM); ``` -------------------------------- ### JavaScript: Initialize Search Engine Globals Source: https://github.com/itsme1229/markitdown/blob/main/packages/markitdown/tests/test_files/test_serp.html This JavaScript code initializes global variables for a search engine, including region, language, marketing settings, and event tracking. It also defines functions for image preloading and setting various search parameters like timeouts and default behaviors. ```javascript //Microsoft wikipedia - Search// ``` -------------------------------- ### JavaScript: Domain Whitelisting Configuration Source: https://github.com/itsme1229/markitdown/blob/main/packages/markitdown/tests/test_files/test_serp.html This JavaScript code defines two arrays, `_w.AM` and `_w.APD`, which appear to serve as whitelists for domains. These lists likely control which domains are permitted for certain functionalities, such as ad serving or integration with specific Microsoft services. The `_w.AM` array seems to be a more comprehensive list, while `_w.APD` might be used for a specific set of approved domains for partner integrations. ```javascript _w.AM=["live.com","azureedge.net","virtualearth.net","windows.net","onenote","hexun.com","dict.bing.com.cn","msn.com","variflight.com","bing.net","msftoffers.com","chinacloudapp.cn","cbsnews.com","swx.cdn.skype.com","swc.cdn.skype.com","latest-swx.cdn.skype.com","a.config.skype.com","b.config.skype.com","platform.bing.com","microsofttranslator.com","bing.com","facebook.net",".delve.office.com",".uservoice.com",".cdn.office.net","platform.twitter.com","cdn.syndication.twimg.com","spoprod-a.akamaihd.net","bingstatic.com","yahoo.co.jp","youtube.com","ytimg.com","r.msftstatic.com","rafd.bing.com","rafd.staging-bing-int.com","raka.bing.com","r.bing.com","r.staging-bing-int.com","raka.staging-bing-int.com","rcf.staging-bing-int.com","rcf.bing.com","s.cn.bing.net","xpaycdn-int.azureedge.net","xpaycdn.azureedge.net","ssl.kaptcha.com","tst.kaptcha.com","snrproxy.binginternal.com","snrproxyeast.binginternal.com","snrproxync.binginternal.com","snrproxysc.binginternal.com","snrproxywest.binginternal.com","cetonc.binginternal.com","cetosc.binginternal.com","cetoeast.binginternal.com","cetowest.binginternal.com","akam.bing.com","akam.staging-bing-int.com","ewlmaakam.staging-bing-int.com","akamproxyeast.staging-bing-int.com","akamproxync.staging-bing-int.com","akamproxysc.staging-bing-int.com","akamproxywest.staging-bing-int.com","cjfdbemmaeeohgibnhdhlakiahifjjcf","ewlmaakam.staging-bing-int.com","bngpiglbalmenaabohcooocpnljgfemj","rwww.bing.com","vlscppe.microsoft.com","ov-df.microsoft.com","content.lifecycle.officeppe.net","content.lifecycle.office.net","pmservices.cp.microsoft.com","paymentinstruments.mp.microsoft.com","paymentinstruments-int.mp.microsoft.com","edge.payments.microsoft.com","uniblends.www.microsoft.com","login.microsoftonline.com","login.live.com","fpt.microsoft.com"] ``` ```javascript _w.APD=[".delve.office.com",".uservoice.com",".cdn.office.net","a.config.skype.com","abcnews.go.com","amazon.com","apps.powerapps.com","app.powerbi.com","app.powerbi.cn","app.powerbi.de","app.powerbigov.us","b.config.skype.com","bfb","bfb-int","bing.com","bing.net","bing-int.com","bingsandbox.com","bingweathermap.azureedge.net","bloomberg.com","c.tenor.com","cbsnews.com","cdn.syndication.twimg.com","channel9.msdn.com","chinacloudapp.cn","clarity.ms","cnn.com","covid19healthbot.cdc.gov","covid19healthbot-dev.cdc.gov","ctmbing.azurefd.net","dailymotion.com","dict.bing.com.cn","downvids.com","downvids.net","edition.cnn.com","embed.vevo.com","euronews.com","facebook.com","fave.api.cnn.io","hexun.com","huffingtonpost.com","idsync.rlcdn.com","ign.com","imdb.com","latest-swx.cdn.skype.com","live.com","login.live-int.com","mashable.com","microsoft.com","microsoftonline.com","microsofttranslator.com","mathsolver.microsoft.com","msecnd.net","msftoffers.com","msit.powerbi.com","msn.com","mtv.com","onenote","photosynth.net","platform.bing.com","platform.twitter.com","powerbi-df.analysis-df.windows.net","r.msftstatic.com","rafd.bing.com","rafd.staging-bing-int.com","raka.bing.com","r.bing.com","r.staging-bing-int.com","raka.staging-bing-int.com","rcf.staging-bing-int.com","rcf.bing.com","rottentomatoes.com","s.cn.bing.net","skype.com","snrproxy.binginternal.com","snrproxyeast.binginternal.com","snrproxync.binginternal.com","snrproxysc.binginternal.com","snrproxywest.binginternal.com","spoprod-a.akamaihd.net","substrate.office.com","swc.cdn.skype.com","swx.cdn.skype.com","variflight.com","video.disney.com","videoplayercdn.osi.office.net","vimeo.com","azureedge.net","virtualearth.net","web.powerapps.com","widgets.icanbuy.com","widgets.ign.com","windows.net","wsj.com","xpaycdn-int.azureedge.net","xpaycdn.azureedge.net","ssl.kaptcha.com","tst.kaptcha.com","yahoo.co.jp","youtube.com","ytimg.com","zdnet.com","chrome-extension://haldlgldplgnggkjaafhelgiaglafanh","player.twitch.tv","mixer.com","3pcookiecheck.azureedge.net","cetonc.binginternal.com","cetosc.binginternal.com","cetoeast.binginternal.com","cetowest.binginternal.com","akam.bing.com","akam.staging-bing-int. ``` -------------------------------- ### Basic MarkItDown Conversion with Python API Source: https://github.com/itsme1229/markitdown/blob/main/README.md Demonstrates basic file conversion using the MarkItDown Python API. It initializes MarkItDown, converts a specified file (e.g., 'test.xlsx'), and prints the extracted text content. Plugins can be enabled or disabled during initialization. ```python from markitdown import MarkItDown md = MarkItDown(enable_plugins=False) # Set to True to enable plugins result = md.convert("test.xlsx") print(result.text_content) ``` -------------------------------- ### Run Pre-commit Checks Source: https://github.com/itsme1229/markitdown/blob/main/README.md Executes all pre-commit hooks across all files in the repository. This ensures code style, formatting, and other checks pass before committing changes. ```shell pre-commit run --all-files ``` -------------------------------- ### Register MarkItDown Plugin Entrypoint (Python) Source: https://github.com/itsme1229/markitdown/blob/main/packages/markitdown-sample-plugin/README.md This Python code snippet outlines the necessary components for registering a MarkItDown plugin. It defines the plugin interface version and a `register_converters` function, which is the main entry point called by MarkItDown to instantiate and register custom converters like `RtfConverter`. ```python # The version of the plugin interface that this plugin uses. # The only supported version is 1 for now. __plugin_interface_version__ = 1 # The main entrypoint for the plugin. This is called each time MarkItDown instances are created. def register_converters(markitdown: MarkItDown, **kwargs): """ Called during construction of MarkItDown instances to register converters provided by plugins. """ # Simply create and attach an RtfConverter instance markitdown.register_converter(RtfConverter()) ``` -------------------------------- ### Docker Integration for MarkItDown Source: https://context7.com/itsme1229/markitdown/llms.txt Deploy and run MarkItDown within Docker containers for consistent, isolated document processing. This simplifies dependency management and ensures reproducible builds across different environments. ```bash # Build Docker image docker build -t markitdown:latest . # Process file via stdin docker run --rm -i markitdown:latest < document.pdf > output.md # Process with volume mount docker run --rm -v $(pwd):/data markitdown:latest /data/document.pdf > output.md # Process multiple files for file in *.pdf; do docker run --rm -i markitdown:latest < "$file" > "${file%.pdf}.md" done ``` -------------------------------- ### Initialize and Handle Dynamic Scope Dropdown (JavaScript) Source: https://github.com/itsme1229/markitdown/blob/main/packages/markitdown/tests/test_files/test_serp.html Initializes and manages a dynamic scope dropdown component. It handles click events for logo elements, logs specific events with context, and clears cookies. The functions also manipulate DOM elements to update scope item content and IDs, and dynamically remove elements from the scope bar based on provided identifiers. Dependencies include global objects like `_w`, `sj_log`, `sj_cook`, `sj_evt`, and `_G`. ```javascript var DynScopesDropdownRE; (function(n) { var u = !1, i, f = !1, e = !1, r = -1, o = !1, t = "b-scopeListItem-", h = t + "menu", c = t + "conv", l = t + "convups", a = t + "realestate"; function v() { var n = null; if (u || (n = _d.querySelector(".b_logoArea")) && sj_be(n, "click", y), u = !0) } function y() { var n = "WebLogoClick"; document.querySelector("cib-serp[mode='conversation']") && (n = "ConversationLogoClick"); _w.sj_log && sj_log("CI.HeaderMSLogo", n, (_G === null || _G === void 0 ? void 0 : _G.V) || "other") } function p() { sj_cook && sj_cook.set && sj_cook.clear && (sj_cook.clear("dsc", "/"), i && sj_cook.set("dsc", "order", i, !1, "/")) } function w(n, t, i, r) { var c = tt(), e, o, s, h, u; if (c) { if (e = rt(c), b(e, i, r), n) { var a = n.split(","), v = e.length, l = [], y = []; for (u = 0; u < a.length; u++) o = a[u].split(":"), o && o.length == 2 && (s = parseInt(o[0]), h = parseInt(o[1]), s < v && h < v && (l[h] = e[s].innerHTML, y[h] = e[s].id)); for (u = 0; u < l.length; u++) e[u].innerHTML = l[u], e[u].id = y[u] } f && k(e); c.className = "" } } function b(n, t, i) { var r, u; if (i) t ? sessionStorage.setItem("RealEstateQuery", t) : sessionStorage.removeItem("RealEstateQuery"); else if (t) for (r = 0; r < n.length; r++) n[r].id === a && (u = n[r].innerHTML, n[r].innerHTML = u.replace(/href="[^"]*"/i, 'href="https://www.bing.com/homes/map?q=' + t + '&FORM=000060"')) } function k(n) { for (var i, u, f, t = 0; t < n.length; t++) { if (n[t].id === c || n[t].id === l) { i = n.length - 1; e && r > 0 && (i = r - 1); t != i && (u = n[t].innerHTML, f = n[t].id, t < i ? d(n, t, i) : g(n, i, t), n[i].innerHTML = u, n[i].id = f, sj_evt.fire("dynamicchatscoperelocate")); break } } } function d(n, t, i) { for (var r = t; r < i; r++) n[r].innerHTML = n[r + 1].innerHTML, n[r].id = n[r + 1].id } function g(n, t, i) { for (var r = i; r > t; r--) n[r].innerHTML = n[r - 1].innerHTML, n[r].id = n[r - 1].id } function nt(n) { var e, o, h, u, c, l, f, a, r, i; if (n && (h = n.split(":"), u = it(), (e = u === null || u === void 0 ? void 0 : u.children) === null || e === void 0 ? void 0 : e.length)) { for (c = u.children, l = s(), f = 0; f < h.length; f++) { for (a = t + h[f], r = 0; r < c.length; r++) { if (i = c[r], i.id === a) { u.removeChild(i); break } } for (r = 0; r < l.length; r++) { if (i = l[r], i.id === a) { (o = i === null || i === void 0 ? void 0 : i.parentElement) === null || o === void 0 ? void 0 : o.removeChild(i); break } } } } } function tt() { var n = _d.querySelectorAll(".b_scopebar > .b_scopehide"); return n && n.length > 0 ? n[0] : null } function it() { var n = _d.querySelectorAll(".b_scopebar"); return (n === null || n === void 0 ? void 0 : n.length) ? n[0].firstChild : null } function rt(n) { for (var f, i = [], u = n.children, t = 0; t < u.length; t++) u[t].id === h ? (r = t, f = s(), i.push.apply(i, f), e = !0) : i.push(u[t]); return i } function s() { var n = _d.querySelectorAll(".b_scopebar #b-scopeListItem-menu .b_sp_over_menu .b_scopebar_item"); return Array.prototype.slice.call(n) } n.init = v })(DynScopesDropdownRE || (DynScopesDropdownRE = {})); _G.AppVer = "44432986"; ``` -------------------------------- ### Identity Configuration (JavaScript) Source: https://github.com/itsme1229/markitdown/blob/main/packages/markitdown/tests/test_files/test_serp.html Defines configuration settings for user identity management. It includes flags for single sign-on (`sglid`), a URL template for organization photos, and boolean flags related to login preferences and explicit sign-in methods. ```javascript var Identity; (function(Identity) { Identity.sglid =false; Identity.orgIdPhotoUrl ="https://business.bing.com/api/v3/search/person/photo?caller=IP\u0026id={0}"; Identity.setLoginPreference =false; Identity.isExplicitMsaSignIn =false; })(Identity || (Identity = {})); ``` -------------------------------- ### Convert File to Markdown using Command-Line Source: https://github.com/itsme1229/markitdown/blob/main/packages/markitdown/README.md Converts a specified file (e.g., PDF) to Markdown format using the MarkItDown command-line utility. The output is redirected to a Markdown file. ```bash markitdown path-to-file.pdf > document.md ``` -------------------------------- ### Performance Observer for Element Visibility (JavaScript) Source: https://github.com/itsme1229/markitdown/blob/main/packages/markitdown/tests/test_files/test_serp.html This module utilizes the PerformanceObserver API to track 'element' entry types, specifically focusing on elements related to the 'frp' (likely First Render Paint or similar) metrics. It records the render time of these elements and disconnects the observer once the first relevant metric is captured, optimizing performance. ```javascript var FRPMetricModule; (function() { var t = !1, i, n; typeof PerformanceObserver != "undefined" && typeof PerformanceObserver == "function" && (i = PerformanceObserver.supportedEntryTypes || [], i.indexOf("element") >= 0 && (n = new PerformanceObserver(function(i) { i.getEntries().forEach(function(i) { var r, u, f; typeof _w.frpPreviousEntry == "undefined" && (_w.frpPreviousEntry = i); ((r = i === null || i === void 0 ? void 0 : i.identifier) === null || r === void 0 ? void 0 : r.length) > 0 && (u = i.identifier, u.startsWith("frp") && u !== "frp.SearchBox" && (f = Math.round(Math.min(_w.frpPreviousEntry.renderTime, i.renderTime)), _G.frp = f, _w.perf && !t && (_w.perf.record && _w.perf.record("FRP", f), t = !0), n && t && n.disconnect())) }) }), n.observe({entryTypes: ["element"] }))) })(FRPMetricModule || (FRPMetricModule = {})); ``` -------------------------------- ### Enable and Use Plugins in MarkItDown Source: https://context7.com/itsme1229/markitdown/llms.txt Extend MarkItDown's functionality by enabling its plugin system. Plugins can add support for custom converters and specialized format handling, enhancing the tool's versatility. ```python from markitdown import MarkItDown # Enable plugins during initialization md = MarkItDown(enable_plugins=True) # Or enable plugins later md = MarkItDown(enable_plugins=False) md.enable_plugins() # Convert using both built-in and plugin converters result = md.convert("custom-format.xyz") ``` -------------------------------- ### LLM Image Description with Python API Source: https://github.com/itsme1229/markitdown/blob/main/README.md Utilizes Large Language Models (LLMs) for generating image descriptions, specifically for PowerPoint and image files. Requires an LLM client (e.g., OpenAI) and model to be provided. A custom prompt can also be specified. ```python from markitdown import MarkItDown from openai import OpenAI client = OpenAI() md = MarkItDown(llm_client=client, llm_model="gpt-4o", llm_prompt="optional custom prompt") result = md.convert("example.jpg") print(result.text_content) ``` -------------------------------- ### CSS: Optimize Content Visibility and Layout Source: https://github.com/itsme1229/markitdown/blob/main/packages/markitdown/tests/test_files/test_serp.html This CSS code applies optimizations for content visibility and layout, particularly for search results pages. It utilizes the `content-visibility` property to defer rendering of off-screen content, improving initial page load performance. Specific rules target various elements like headers, search answers, algorithms, and pagination. ```css #b_header #id_h{content-visibility:hidden} #b_results>.b_ans:not(.b_top):nth-child(n+5) .rqnaContainerwithfeedback #df_listaa{content-visibility:auto;contain-intrinsic-size:648px 205px} #b_results>.b_algo:not(.b_algoBorder):nth-child(n+5)>h2{content-visibility:auto;contain-intrinsic-size:608px 24px} #b_results>.b_algo:not(.b_algoBorder):nth-child(n+5) .b_caption:not(.b_rich):not(.b_capmedia):not(.b_snippetgobig):not(.rebateContent){content-visibility:auto;contain-intrinsic-size:608px 65px;padding-right:16px;margin-right:-16px;margin-left:-16px;padding-left:16px} #b_results>.b_algo:not(.b_algoBorder):nth-child(n+5) .b_caption.b_rich .captionMediaCard .wide_wideAlgo{content-visibility:auto;contain-intrinsic-size:370px 120px} #b_results>.b_algo:not(.b_algoBorder):nth-child(n+5) .scs_icn{content-visibility:auto} #b_results>.b_ans:nth-child(n+7) .b_rs:not(.pageRecoContainer){content-visibility:auto;contain-intrinsic-size:608px 296px} #b_results>.b_ans:nth-child(n+7) .b_rs:not(.pageRecoContainer) .b_rsv3{padding-bottom:1px} #b_results>.b_pag{content-visibility:auto;contain-intrinsic-size:628px 45px} #b_footer>#b_footerItems{content-visibility:auto;contain-intrinsic-size:1px 24px} .cnt_vis_hid{content-visibility:hidden} ``` -------------------------------- ### Voice Search Microphone Click Handling (JavaScript) Source: https://github.com/itsme1229/markitdown/blob/main/packages/markitdown/tests/test_files/test_serp.html Handles the click event for the voice search microphone icon. It binds to the 'micLoaded' event and, upon loading, simulates a click on the microphone icon to initiate voice search. It also logs pre-click information. ```javascript var MicLoad;(function(n){ function r(n){ function i(){ sj_evt.unbind("micLoaded",i); var t=n.querySelector(".b_icon"); t&&t.click() } t||(n.clicked||(sj_evt.bind("micLoaded",i,!0),n.clicked=!0),sj_log("CI.VoiceSearch","MicPreClick","Beforeload")) } function i(){ t=!0; sj_evt.unbind("micLoaded",i) } var t=!1; n.handleMicClick=r; sj_evt.bind("micLoaded",i,!0) })(MicLoad||(MicLoad={})); ```