### Install mrkdwn_analysis Source: https://github.com/yannbanas/mrkdwn_analysis/blob/main/README.md Install the library using pip. ```bash pip install markdown-analysis ``` -------------------------------- ### Global Analysis Summary Source: https://github.com/yannbanas/mrkdwn_analysis/blob/main/README.md Perform a comprehensive analysis of the Markdown document to get a summary of its elements. ```python analysis = analyzer.analyse() print(analysis) # { # 'headers': X, # 'paragraphs': Y, # 'blockquotes': Z, # 'code_blocks': A, # 'ordered_lists': B, # 'unordered_lists': C, # 'tables': D, # 'html_blocks': E, # 'html_inline_count': F, # 'words': G, # 'characters': H # } ``` -------------------------------- ### Retrieve Document Statistics Source: https://github.com/yannbanas/mrkdwn_analysis/blob/main/README.md Get advanced statistics about the document, including reading time, complexity metrics, link statistics, and word frequency. ```python # Get reading time reading_time = doc.get_reading_time() print(reading_time['formatted']) # "5 min read" # Document complexity metrics complexity = doc.get_complexity_metrics() print(f"Complexity score: {complexity['complexity_score']}") # Link statistics link_stats = doc.get_link_statistics() print(f"External links: {link_stats['external_links']}") # Word frequency analysis top_words = doc.get_word_frequency(top_n=20) ``` -------------------------------- ### Initialize MarkdownAnalyzer Source: https://github.com/yannbanas/mrkdwn_analysis/blob/main/README.md Import the MarkdownAnalyzer class and create an instance with the path to your Markdown file. ```python from mrkdwn_analysis import MarkdownAnalyzer analyzer = MarkdownAnalyzer("path/to/document.md") ``` -------------------------------- ### Analyze Markdown File Source: https://github.com/yannbanas/mrkdwn_analysis/blob/main/README.md Analyze a specific Markdown file ('example.md') and print the identified elements. ```python analyzer = MarkdownAnalyzer("example.md") print(analyzer.identify_headers()) # {"Header": [{"line": X, "level": 1, "text": "Python 3.11"}, {"line": Y, "level": 3, "text": "Performance Details"}]} print(analyzer.identify_paragraphs()) # {"Paragraph": ["A major **Python** release ...", "This paragraph contains inline HTML: ..."]} print(analyzer.identify_html_blocks()) # [{"line": Z, "content": "

HTML block example

"}] print(analyzer.identify_html_inline()) # [{"line": W, "html": "Red text"}] print(analyzer.identify_lists()) # { # "Ordered list": [["Ordered list item 1", "Ordered list item 2"]], # "Unordered list": [["A basic point", "A task to do [Task]", "A completed task [Task done]"]] # } print(analyzer.identify_code_blocks()) # {"Code block": [{"start_line": X, "content": "import math\nprint(math.factorial(10))", "language": "python"}]} print(analyzer.analyse()) # { # 'headers': 2, # 'paragraphs': 2, # 'blockquotes': 1, # 'code_blocks': 1, # 'ordered_lists': 2, # 'unordered_lists': 3, # 'tables': 0, # 'html_blocks': 1, # 'html_inline_count': 1, # 'words': 42, # 'characters': 250 # } ``` -------------------------------- ### Identify Headers Source: https://github.com/yannbanas/mrkdwn_analysis/blob/main/README.md Extract all headers from the Markdown document. ```python headers = analyzer.identify_headers() ``` -------------------------------- ### Export Document to Various Formats Source: https://github.com/yannbanas/mrkdwn_analysis/blob/main/README.md Export document content to JSON, HTML with optional styling, or plain text with formatting stripped. ```python # Export to JSON json_output = doc.to_json(include_metadata=True) # Export to HTML with styling html_output = doc.to_html(include_style=True) # Export to plain text plain_text = doc.to_plain_text(strip_formatting=True) ``` -------------------------------- ### Identify Links Source: https://github.com/yannbanas/mrkdwn_analysis/blob/main/README.md Extract all links from the Markdown document. ```python links = analyzer.identify_links() ``` -------------------------------- ### Identify Paragraphs Source: https://github.com/yannbanas/mrkdwn_analysis/blob/main/README.md Extract all paragraphs from the Markdown document. ```python paragraphs = analyzer.identify_paragraphs() ``` -------------------------------- ### Identify Code Blocks Source: https://github.com/yannbanas/mrkdwn_analysis/blob/main/README.md Extract code blocks, including their content and language, from the Markdown document. ```python code_blocks = analyzer.identify_code_blocks() ``` -------------------------------- ### Identify Lists Source: https://github.com/yannbanas/mrkdwn_analysis/blob/main/README.md Extract both ordered and unordered lists, including tasks, from the Markdown document. ```python lists = analyzer.identify_lists() ``` -------------------------------- ### Check Broken Links Source: https://github.com/yannbanas/mrkdwn_analysis/blob/main/README.md Validate text links in the Markdown document to identify any broken links. ```python broken_links = analyzer.check_links() ``` -------------------------------- ### Identify Inline HTML Source: https://github.com/yannbanas/mrkdwn_analysis/blob/main/README.md Extract inline HTML elements from the Markdown document. ```python inline_html = analyzer.identify_html_inline() ``` -------------------------------- ### Identify HTML Blocks Source: https://github.com/yannbanas/mrkdwn_analysis/blob/main/README.md Extract standalone HTML blocks from the Markdown document. ```python html_blocks = analyzer.identify_html_blocks() ``` -------------------------------- ### Check for Broken Links in Document Source: https://github.com/yannbanas/mrkdwn_analysis/blob/main/README.md Efficiently check all links within the document for broken URLs using parallel processing. Reports broken links with their status codes or error messages. ```python # Parallel link checking (much faster!) broken_links = doc.check_links(max_workers=10) for link in broken_links: print(f"Broken: {link['url']} - {link.get('status_code', 'error')}") ``` -------------------------------- ### Search and Filter Document Content Source: https://github.com/yannbanas/mrkdwn_analysis/blob/main/README.md Use the search function to find specific text within the document. Filter headers by their level or generate a table of contents up to a specified depth. ```python # Search for content results = doc.search("Python", case_sensitive=False) # Find headers by level h2_headers = doc.find_headers_by_level(2) # Generate table of contents toc = doc.get_table_of_contents(max_level=3) ``` -------------------------------- ### Extract Code by Language Source: https://github.com/yannbanas/mrkdwn_analysis/blob/main/README.md Extract all code blocks from the document that are identified as belonging to a specific programming language, such as Python. ```python # Extract Python code blocks python_code = doc.extract_code_by_language('python') for block in python_code: print(block['content']) ``` -------------------------------- ### Validate Document Structure Source: https://github.com/yannbanas/mrkdwn_analysis/blob/main/README.md Validate the overall structure of the document, receiving a validity status, a score, and a list of identified issues with their types and messages. ```python # Validate document structure validation = doc.validate_structure() print(f"Valid: {validation['valid']}, Score: {validation['score']}/100") for issue in validation['issues']: print(f"[{issue['type']}] {issue['message']}") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.