[{"data":1,"prerenderedAt":68},["Reactive",2],{"blog-post-markdown-text-wrapping-line-length-management-guide":3},{"slug":4,"title":5,"description":6,"excerpt":7,"date":8,"category":9,"author":10,"keywords":11,"readingMinutes":12,"html":13,"headings":14,"tools":43,"related":44},"markdown-text-wrapping-line-length-management-guide","Markdown Text Wrapping and Line Length Management: Complete Guide for Document Formatting and Content Optimization","Master Markdown text wrapping techniques, line length management, and content formatting for optimal readability across different platforms. Learn hard wraps, soft wraps, line break strategies, and automated formatting approaches.","Advanced Markdown text wrapping and line length management techniques enable professional document formatting that optimizes content readability across different platforms and display…","2025-11-06","Tutorial","Matthew Rathbone","markdown text wrapping, markdown line length, text formatting markdown, markdown hard wrap, markdown soft wrap, line breaks markdown, markdown paragraph formatting, content optimization",19,"\u003Cp>Advanced Markdown text wrapping and line length management techniques enable professional document formatting that optimizes content readability across different platforms and display environments. By mastering proper line length management, wrapping strategies, and formatting approaches, content creators can ensure their Markdown documents maintain consistent presentation, improve readability, and adapt effectively to various viewing contexts while preserving semantic meaning and visual hierarchy.\u003C/p>\n\u003Ch2 id=\"why-master-text-wrapping-and-line-length-management\">Why Master Text Wrapping and Line Length Management?\u003C/h2>\n\u003Cp>Professional text formatting provides essential benefits for content presentation:\u003C/p>\n\u003Cul>\n\u003Cli>\u003Cstrong>Readability Optimization\u003C/strong>: Control line lengths for optimal reading experience across devices and platforms\u003C/li>\n\u003Cli>\u003Cstrong>Platform Consistency\u003C/strong>: Ensure content displays correctly in different Markdown processors and viewing environments  \u003C/li>\n\u003Cli>\u003Cstrong>Version Control Efficiency\u003C/strong>: Use strategic line breaks to improve diff readability and merge conflict resolution\u003C/li>\n\u003Cli>\u003Cstrong>Responsive Design\u003C/strong>: Create content that adapts gracefully to different screen sizes and viewing contexts\u003C/li>\n\u003Cli>\u003Cstrong>Editorial Workflow\u003C/strong>: Implement formatting standards that support collaborative writing and content review processes\u003C/li>\n\u003C/ul>\n\u003Ch2 id=\"foundation-text-wrapping-concepts\">Foundation Text Wrapping Concepts\u003C/h2>\n\u003Ch3 id=\"hard-wraps-vs-soft-wraps\">Hard Wraps vs. Soft Wraps\u003C/h3>\n\u003Cp>Understanding the fundamental difference between hard and soft text wrapping approaches:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-markdown\">\u003Cspan class=\"hljs-section\"># Hard Wrap Example (Fixed Line Breaks)\u003C/span>\n\nThis paragraph uses hard wraps where each line\nis manually broken at a specific character count,\ntypically around 72-80 characters per line.\nEach line ends with a manual line break that\ncreates a new line in the source document.\n\n\u003Cspan class=\"hljs-section\"># Soft Wrap Example (Flow Text)\u003C/span>\n\nThis paragraph uses soft wraps where the text flows naturally in a single long line and the display environment (editor, browser, or viewer) handles the visual wrapping based on the available screen width and user preferences.\n\u003C/code>\u003C/pre>\u003Ch3 id=\"line-length-standards-and-guidelines\">Line Length Standards and Guidelines\u003C/h3>\n\u003Cp>Implementing professional line length standards for different content types:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-markdown\">\u003Cspan class=\"hljs-section\"># Line Length Guidelines by Content Type\u003C/span>\n\n\u003Cspan class=\"hljs-section\">## Technical Documentation (72-80 characters)\u003C/span>\nTechnical documentation typically uses shorter line lengths for better\ncode readability and to accommodate side-by-side viewing with code\nexamples. This length also works well for email and version control\nsystems that have traditional terminal width limitations.\n\n\u003Cspan class=\"hljs-section\">## Blog Posts and Articles (80-100 characters)\u003C/span>\nBlog posts and articles can use slightly longer line lengths that balance readability\nwith efficient use of screen space. This length provides good reading flow while \nmaintaining manageable line lengths for editorial review and collaborative editing\nworkflows.\n\n\u003Cspan class=\"hljs-section\">## Academic and Formal Documents (100-120 characters)\u003C/span>\nAcademic papers and formal documents may use longer line lengths that maximize content density while maintaining\nreadability for print and PDF formats. These longer lines work well for detailed explanations and complex\ntechnical descriptions that benefit from uninterrupted flow.\n\u003C/code>\u003C/pre>\u003Ch3 id=\"automated-text-wrapping-systems\">Automated Text Wrapping Systems\u003C/h3>\n\u003Cp>Creating intelligent text wrapping and formatting automation:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-javascript\">\u003Cspan class=\"hljs-comment\">// text-wrapper.js - Advanced text wrapping and line length manager\u003C/span>\n\u003Cspan class=\"hljs-keyword\">class\u003C/span> \u003Cspan class=\"hljs-title class_\">MarkdownTextWrapper\u003C/span> {\n    \u003Cspan class=\"hljs-title function_\">constructor\u003C/span>(\u003Cspan class=\"hljs-params\">options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">lineLength\u003C/span>: options.\u003Cspan class=\"hljs-property\">lineLength\u003C/span> || \u003Cspan class=\"hljs-number\">80\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">preserveShortLines\u003C/span>: options.\u003Cspan class=\"hljs-property\">preserveShortLines\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">respectCodeBlocks\u003C/span>: options.\u003Cspan class=\"hljs-property\">respectCodeBlocks\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">respectQuotes\u003C/span>: options.\u003Cspan class=\"hljs-property\">respectQuotes\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">respectLists\u003C/span>: options.\u003Cspan class=\"hljs-property\">respectLists\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">tabWidth\u003C/span>: options.\u003Cspan class=\"hljs-property\">tabWidth\u003C/span> || \u003Cspan class=\"hljs-number\">4\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">breakAtWords\u003C/span>: options.\u003Cspan class=\"hljs-property\">breakAtWords\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            ...options\n        };\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">patterns\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">codeBlock\u003C/span>: \u003Cspan class=\"hljs-regexp\">/^```[\\s\\S]*?^```$/gm\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">inlineCode\u003C/span>: \u003Cspan class=\"hljs-regexp\">/`[^`]+`/g\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">quote\u003C/span>: \u003Cspan class=\"hljs-regexp\">/^&gt;\\s+/gm\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">listItem\u003C/span>: \u003Cspan class=\"hljs-regexp\">/^(\\s*)[-*+]\\s+/gm\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">orderedList\u003C/span>: \u003Cspan class=\"hljs-regexp\">/^(\\s*)\\d+\\.\\s+/gm\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">heading\u003C/span>: \u003Cspan class=\"hljs-regexp\">/^#{1,6}\\s+/gm\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">horizontalRule\u003C/span>: \u003Cspan class=\"hljs-regexp\">/^[-*_]{3,}$/gm\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">link\u003C/span>: \u003Cspan class=\"hljs-regexp\">/\\[([^\\]]*)\\]\\(([^)]+)\\)/g\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">referenceLink\u003C/span>: \u003Cspan class=\"hljs-regexp\">/\\[([^\\]]*)\\]\\[([^\\]]*)\\]/g\u003C/span>\n        };\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">protectedRanges\u003C/span> = [];\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">wrapDocument\u003C/span>(\u003Cspan class=\"hljs-params\">markdown\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Reset protected ranges for each document\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">protectedRanges\u003C/span> = [];\n        \n        \u003Cspan class=\"hljs-comment\">// Identify protected ranges (code blocks, etc.)\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">respectCodeBlocks\u003C/span>) {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">identifyCodeBlocks\u003C/span>(markdown);\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Split into paragraphs and process each\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> paragraphs = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">splitIntoParagraphs\u003C/span>(markdown);\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> wrappedParagraphs = paragraphs.\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">paragraph\u003C/span> =&gt;\u003C/span> \n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">wrapParagraph\u003C/span>(paragraph)\n        );\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> wrappedParagraphs.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\n\\n&#x27;\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">identifyCodeBlocks\u003C/span>(\u003Cspan class=\"hljs-params\">markdown\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> match;\n        \n        \u003Cspan class=\"hljs-comment\">// Find fenced code blocks\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> fencedPattern = \u003Cspan class=\"hljs-regexp\">/^```[\\s\\S]*?^```$/gm\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">while\u003C/span> ((match = fencedPattern.\u003Cspan class=\"hljs-title function_\">exec\u003C/span>(markdown)) !== \u003Cspan class=\"hljs-literal\">null\u003C/span>) {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">protectedRanges\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">start\u003C/span>: match.\u003Cspan class=\"hljs-property\">index\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">end\u003C/span>: match.\u003Cspan class=\"hljs-property\">index\u003C/span> + match[\u003Cspan class=\"hljs-number\">0\u003C/span>].\u003Cspan class=\"hljs-property\">length\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;code-block&#x27;\u003C/span>\n            });\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Find indented code blocks\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> indentedPattern = \u003Cspan class=\"hljs-regexp\">/^(?: {4}|\\t).*$/gm\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">while\u003C/span> ((match = indentedPattern.\u003Cspan class=\"hljs-title function_\">exec\u003C/span>(markdown)) !== \u003Cspan class=\"hljs-literal\">null\u003C/span>) {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">protectedRanges\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">start\u003C/span>: match.\u003Cspan class=\"hljs-property\">index\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">end\u003C/span>: match.\u003Cspan class=\"hljs-property\">index\u003C/span> + match[\u003Cspan class=\"hljs-number\">0\u003C/span>].\u003Cspan class=\"hljs-property\">length\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;indented-code&#x27;\u003C/span>\n            });\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">isInProtectedRange\u003C/span>(\u003Cspan class=\"hljs-params\">position\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">protectedRanges\u003C/span>.\u003Cspan class=\"hljs-title function_\">some\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">range\u003C/span> =&gt;\u003C/span> \n            position &gt;= range.\u003Cspan class=\"hljs-property\">start\u003C/span> &amp;&amp; position &lt;= range.\u003Cspan class=\"hljs-property\">end\u003C/span>\n        );\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">splitIntoParagraphs\u003C/span>(\u003Cspan class=\"hljs-params\">markdown\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Split on double newlines, preserving empty lines\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> paragraphs = markdown.\u003Cspan class=\"hljs-title function_\">split\u003C/span>(\u003Cspan class=\"hljs-regexp\">/\\n\\s*\\n/\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> paragraphs.\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">p\u003C/span> =&gt;\u003C/span> p.\u003Cspan class=\"hljs-title function_\">trim\u003C/span>()).\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">p\u003C/span> =&gt;\u003C/span> p.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">wrapParagraph\u003C/span>(\u003Cspan class=\"hljs-params\">paragraph\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> lines = paragraph.\u003Cspan class=\"hljs-title function_\">split\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> wrappedLines = [];\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> line \u003Cspan class=\"hljs-keyword\">of\u003C/span> lines) {\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">shouldSkipLine\u003C/span>(line)) {\n                wrappedLines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(line);\n            } \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> (line.\u003Cspan class=\"hljs-property\">length\u003C/span> &lt;= \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">lineLength\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">preserveShortLines\u003C/span>) {\n                    wrappedLines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(line);\n                } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n                    \u003Cspan class=\"hljs-comment\">// Combine with next lines if they would fit\u003C/span>\n                    wrappedLines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(line);\n                }\n            } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n                wrappedLines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(...\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">wrapLongLine\u003C/span>(line));\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> wrappedLines.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">shouldSkipLine\u003C/span>(\u003Cspan class=\"hljs-params\">line\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Skip headings\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">patterns\u003C/span>.\u003Cspan class=\"hljs-property\">heading\u003C/span>.\u003Cspan class=\"hljs-title function_\">test\u003C/span>(line)) {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">true\u003C/span>;\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Skip horizontal rules\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">patterns\u003C/span>.\u003Cspan class=\"hljs-property\">horizontalRule\u003C/span>.\u003Cspan class=\"hljs-title function_\">test\u003C/span>(line)) {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">true\u003C/span>;\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Skip list items if option is set\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">respectLists\u003C/span> &amp;&amp; \n            (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">patterns\u003C/span>.\u003Cspan class=\"hljs-property\">listItem\u003C/span>.\u003Cspan class=\"hljs-title function_\">test\u003C/span>(line) || \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">patterns\u003C/span>.\u003Cspan class=\"hljs-property\">orderedList\u003C/span>.\u003Cspan class=\"hljs-title function_\">test\u003C/span>(line))) {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">true\u003C/span>;\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Skip quotes if option is set\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">respectQuotes\u003C/span> &amp;&amp; \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">patterns\u003C/span>.\u003Cspan class=\"hljs-property\">quote\u003C/span>.\u003Cspan class=\"hljs-title function_\">test\u003C/span>(line)) {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">true\u003C/span>;\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">false\u003C/span>;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">wrapLongLine\u003C/span>(\u003Cspan class=\"hljs-params\">line\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> wrappedLines = [];\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> remainingText = line;\n        \n        \u003Cspan class=\"hljs-keyword\">while\u003C/span> (remainingText.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">lineLength\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> breakPoint = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">findBreakPoint\u003C/span>(remainingText);\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (breakPoint === -\u003Cspan class=\"hljs-number\">1\u003C/span>) {\n                \u003Cspan class=\"hljs-comment\">// No good break point found, break at line length\u003C/span>\n                wrappedLines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(remainingText.\u003Cspan class=\"hljs-title function_\">substring\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">lineLength\u003C/span>));\n                remainingText = remainingText.\u003Cspan class=\"hljs-title function_\">substring\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">lineLength\u003C/span>);\n            } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n                wrappedLines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(remainingText.\u003Cspan class=\"hljs-title function_\">substring\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, breakPoint).\u003Cspan class=\"hljs-title function_\">trim\u003C/span>());\n                remainingText = remainingText.\u003Cspan class=\"hljs-title function_\">substring\u003C/span>(breakPoint).\u003Cspan class=\"hljs-title function_\">trim\u003C/span>();\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (remainingText.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n            wrappedLines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(remainingText);\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> wrappedLines;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">findBreakPoint\u003C/span>(\u003Cspan class=\"hljs-params\">text\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> maxLength = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">lineLength\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">breakAtWords\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> maxLength;\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Look for word boundaries near the line length limit\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> searchStart = \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">max\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, maxLength - \u003Cspan class=\"hljs-number\">20\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> searchEnd = \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">min\u003C/span>(text.\u003Cspan class=\"hljs-property\">length\u003C/span>, maxLength + \u003Cspan class=\"hljs-number\">1\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> searchText = text.\u003Cspan class=\"hljs-title function_\">substring\u003C/span>(searchStart, searchEnd);\n        \n        \u003Cspan class=\"hljs-comment\">// Find the last space within the acceptable range\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> spaceIndex = searchText.\u003Cspan class=\"hljs-title function_\">lastIndexOf\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (spaceIndex !== -\u003Cspan class=\"hljs-number\">1\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> searchStart + spaceIndex;\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Look for other break characters\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> breakChars = [\u003Cspan class=\"hljs-string\">&#x27;-&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;/&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;\\\\&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;&amp;&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;|&#x27;\u003C/span>];\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> char \u003Cspan class=\"hljs-keyword\">of\u003C/span> breakChars) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> charIndex = searchText.\u003Cspan class=\"hljs-title function_\">lastIndexOf\u003C/span>(char);\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (charIndex !== -\u003Cspan class=\"hljs-number\">1\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> searchStart + charIndex + \u003Cspan class=\"hljs-number\">1\u003C/span>;\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> -\u003Cspan class=\"hljs-number\">1\u003C/span>; \u003Cspan class=\"hljs-comment\">// No suitable break point found\u003C/span>\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">formatParagraph\u003C/span>(\u003Cspan class=\"hljs-params\">paragraph, options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> localOptions = { ...\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>, ...options };\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> wrapper = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">MarkdownTextWrapper\u003C/span>(localOptions);\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> wrapper.\u003Cspan class=\"hljs-title function_\">wrapParagraph\u003C/span>(paragraph);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">optimizeForPlatform\u003C/span>(\u003Cspan class=\"hljs-params\">markdown, platform\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> platformSettings = {\n            \u003Cspan class=\"hljs-attr\">github\u003C/span>: { \u003Cspan class=\"hljs-attr\">lineLength\u003C/span>: \u003Cspan class=\"hljs-number\">80\u003C/span>, \u003Cspan class=\"hljs-attr\">preserveShortLines\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span> },\n            \u003Cspan class=\"hljs-attr\">email\u003C/span>: { \u003Cspan class=\"hljs-attr\">lineLength\u003C/span>: \u003Cspan class=\"hljs-number\">72\u003C/span>, \u003Cspan class=\"hljs-attr\">preserveShortLines\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span> },\n            \u003Cspan class=\"hljs-attr\">blog\u003C/span>: { \u003Cspan class=\"hljs-attr\">lineLength\u003C/span>: \u003Cspan class=\"hljs-number\">100\u003C/span>, \u003Cspan class=\"hljs-attr\">preserveShortLines\u003C/span>: \u003Cspan class=\"hljs-literal\">false\u003C/span> },\n            \u003Cspan class=\"hljs-attr\">academic\u003C/span>: { \u003Cspan class=\"hljs-attr\">lineLength\u003C/span>: \u003Cspan class=\"hljs-number\">120\u003C/span>, \u003Cspan class=\"hljs-attr\">preserveShortLines\u003C/span>: \u003Cspan class=\"hljs-literal\">false\u003C/span> },\n            \u003Cspan class=\"hljs-attr\">mobile\u003C/span>: { \u003Cspan class=\"hljs-attr\">lineLength\u003C/span>: \u003Cspan class=\"hljs-number\">60\u003C/span>, \u003Cspan class=\"hljs-attr\">preserveShortLines\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span> }\n        };\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> settings = platformSettings[platform] || \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> wrapper = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">MarkdownTextWrapper\u003C/span>(settings);\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> wrapper.\u003Cspan class=\"hljs-title function_\">wrapDocument\u003C/span>(markdown);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">analyzeTextMetrics\u003C/span>(\u003Cspan class=\"hljs-params\">markdown\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> lines = markdown.\u003Cspan class=\"hljs-title function_\">split\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> nonEmptyLines = lines.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">line\u003C/span> =&gt;\u003C/span> line.\u003Cspan class=\"hljs-title function_\">trim\u003C/span>().\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> lineLengths = nonEmptyLines.\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">line\u003C/span> =&gt;\u003C/span> line.\u003Cspan class=\"hljs-property\">length\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> metrics = {\n            \u003Cspan class=\"hljs-attr\">totalLines\u003C/span>: lines.\u003Cspan class=\"hljs-property\">length\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">nonEmptyLines\u003C/span>: nonEmptyLines.\u003Cspan class=\"hljs-property\">length\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">averageLineLength\u003C/span>: lineLengths.\u003Cspan class=\"hljs-title function_\">reduce\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">sum, len\u003C/span>) =&gt;\u003C/span> sum + len, \u003Cspan class=\"hljs-number\">0\u003C/span>) / lineLengths.\u003Cspan class=\"hljs-property\">length\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">maxLineLength\u003C/span>: \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">max\u003C/span>(...lineLengths),\n            \u003Cspan class=\"hljs-attr\">minLineLength\u003C/span>: \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">min\u003C/span>(...lineLengths),\n            \u003Cspan class=\"hljs-attr\">linesOverLimit\u003C/span>: lineLengths.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">len\u003C/span> =&gt;\u003C/span> len &gt; \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">lineLength\u003C/span>).\u003Cspan class=\"hljs-property\">length\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">lineDistribution\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">calculateLineDistribution\u003C/span>(lineLengths)\n        };\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> metrics;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">calculateLineDistribution\u003C/span>(\u003Cspan class=\"hljs-params\">lineLengths\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> bins = {\n            \u003Cspan class=\"hljs-string\">&#x27;short (0-40)&#x27;\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-string\">&#x27;medium (41-80)&#x27;\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-string\">&#x27;long (81-120)&#x27;\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-string\">&#x27;very-long (120+)&#x27;\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>\n        };\n        \n        lineLengths.\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">length\u003C/span> =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (length &lt;= \u003Cspan class=\"hljs-number\">40\u003C/span>) bins[\u003Cspan class=\"hljs-string\">&#x27;short (0-40)&#x27;\u003C/span>]++;\n            \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> (length &lt;= \u003Cspan class=\"hljs-number\">80\u003C/span>) bins[\u003Cspan class=\"hljs-string\">&#x27;medium (41-80)&#x27;\u003C/span>]++;\n            \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> (length &lt;= \u003Cspan class=\"hljs-number\">120\u003C/span>) bins[\u003Cspan class=\"hljs-string\">&#x27;long (81-120)&#x27;\u003C/span>]++;\n            \u003Cspan class=\"hljs-keyword\">else\u003C/span> bins[\u003Cspan class=\"hljs-string\">&#x27;very-long (120+)&#x27;\u003C/span>]++;\n        });\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> bins;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">validateFormatting\u003C/span>(\u003Cspan class=\"hljs-params\">markdown, rules = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> issues = [];\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> lines = markdown.\u003Cspan class=\"hljs-title function_\">split\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> validationRules = {\n            \u003Cspan class=\"hljs-attr\">maxLineLength\u003C/span>: rules.\u003Cspan class=\"hljs-property\">maxLineLength\u003C/span> || \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">lineLength\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">noTrailingSpaces\u003C/span>: rules.\u003Cspan class=\"hljs-property\">noTrailingSpaces\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">consistentListIndentation\u003C/span>: rules.\u003Cspan class=\"hljs-property\">consistentListIndentation\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">noTabsInContent\u003C/span>: rules.\u003Cspan class=\"hljs-property\">noTabsInContent\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            ...rules\n        };\n        \n        lines.\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">line, index\u003C/span>) =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> lineNumber = index + \u003Cspan class=\"hljs-number\">1\u003C/span>;\n            \n            \u003Cspan class=\"hljs-comment\">// Check line length\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (line.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; validationRules.\u003Cspan class=\"hljs-property\">maxLineLength\u003C/span> &amp;&amp; !\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">shouldSkipLine\u003C/span>(line)) {\n                issues.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">line\u003C/span>: lineNumber,\n                    \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;line-too-long&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">`Line exceeds \u003Cspan class=\"hljs-subst\">${validationRules.maxLineLength}\u003C/span> characters (\u003Cspan class=\"hljs-subst\">${line.length}\u003C/span>)`\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">severity\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;warning&#x27;\u003C/span>\n                });\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Check trailing spaces\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (validationRules.\u003Cspan class=\"hljs-property\">noTrailingSpaces\u003C/span> &amp;&amp; line.\u003Cspan class=\"hljs-title function_\">endsWith\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span>) &amp;&amp; !line.\u003Cspan class=\"hljs-title function_\">endsWith\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;  &#x27;\u003C/span>)) {\n                issues.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">line\u003C/span>: lineNumber,\n                    \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;trailing-spaces&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Line has trailing spaces&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">severity\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;info&#x27;\u003C/span>\n                });\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Check tabs in content\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (validationRules.\u003Cspan class=\"hljs-property\">noTabsInContent\u003C/span> &amp;&amp; line.\u003Cspan class=\"hljs-title function_\">includes\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\t&#x27;\u003C/span>) &amp;&amp; !\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">isInProtectedRange\u003C/span>(index)) {\n                issues.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">line\u003C/span>: lineNumber,\n                    \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;tabs-in-content&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Line contains tab characters, use spaces instead&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">severity\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;warning&#x27;\u003C/span>\n                });\n            }\n        });\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            \u003Cspan class=\"hljs-attr\">isValid\u003C/span>: issues.\u003Cspan class=\"hljs-property\">length\u003C/span> === \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            issues,\n            \u003Cspan class=\"hljs-attr\">summary\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">errors\u003C/span>: issues.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">i\u003C/span> =&gt;\u003C/span> i.\u003Cspan class=\"hljs-property\">severity\u003C/span> === \u003Cspan class=\"hljs-string\">&#x27;error&#x27;\u003C/span>).\u003Cspan class=\"hljs-property\">length\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">warnings\u003C/span>: issues.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">i\u003C/span> =&gt;\u003C/span> i.\u003Cspan class=\"hljs-property\">severity\u003C/span> === \u003Cspan class=\"hljs-string\">&#x27;warning&#x27;\u003C/span>).\u003Cspan class=\"hljs-property\">length\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">info\u003C/span>: issues.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">i\u003C/span> =&gt;\u003C/span> i.\u003Cspan class=\"hljs-property\">severity\u003C/span> === \u003Cspan class=\"hljs-string\">&#x27;info&#x27;\u003C/span>).\u003Cspan class=\"hljs-property\">length\u003C/span>\n            }\n        };\n    }\n}\n\n\u003Cspan class=\"hljs-comment\">// Example usage and testing\u003C/span>\n\u003Cspan class=\"hljs-keyword\">function\u003C/span> \u003Cspan class=\"hljs-title function_\">demonstrateTextWrapping\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n    \u003Cspan class=\"hljs-keyword\">const\u003C/span> wrapper = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">MarkdownTextWrapper\u003C/span>({\n        \u003Cspan class=\"hljs-attr\">lineLength\u003C/span>: \u003Cspan class=\"hljs-number\">80\u003C/span>,\n        \u003Cspan class=\"hljs-attr\">breakAtWords\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span>,\n        \u003Cspan class=\"hljs-attr\">preserveShortLines\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span>\n    });\n    \n    \u003Cspan class=\"hljs-keyword\">const\u003C/span> sampleText = \u003Cspan class=\"hljs-string\">`\n# Text Wrapping Example\n\nThis is a very long paragraph that exceeds the typical line length limits and should be wrapped according to the specified formatting rules. The wrapper should break this text at appropriate word boundaries while preserving the readability and semantic meaning of the content.\n\n## Code Block Example\n\n\\`\\`\\`javascript\n// This code block should not be wrapped\nfunction exampleFunction(parameterWithVeryLongName, anotherParameterWithEvenLongerName) {\n    return parameterWithVeryLongName + anotherParameterWithEvenLongerName;\n}\n\\`\\`\\`\n\n## List Example\n\n- This is a list item that is quite long and might exceed the line length limit but should be handled appropriately\n- Another list item\n  - Nested item with even longer text that definitely exceeds typical line length limits\n`\u003C/span>;\n    \n    \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">&quot;Original Text:&quot;\u003C/span>);\n    \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(sampleText);\n    \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">&quot;\\nWrapped Text:&quot;\u003C/span>);\n    \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(wrapper.\u003Cspan class=\"hljs-title function_\">wrapDocument\u003C/span>(sampleText));\n    \n    \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">&quot;\\nText Metrics:&quot;\u003C/span>);\n    \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(wrapper.\u003Cspan class=\"hljs-title function_\">analyzeTextMetrics\u003C/span>(sampleText));\n    \n    \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">&quot;\\nValidation Results:&quot;\u003C/span>);\n    \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(wrapper.\u003Cspan class=\"hljs-title function_\">validateFormatting\u003C/span>(sampleText));\n}\n\n\u003Cspan class=\"hljs-variable language_\">module\u003C/span>.\u003Cspan class=\"hljs-property\">exports\u003C/span> = \u003Cspan class=\"hljs-title class_\">MarkdownTextWrapper\u003C/span>;\n\n\u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-built_in\">require\u003C/span>.\u003Cspan class=\"hljs-property\">main\u003C/span> === \u003Cspan class=\"hljs-variable language_\">module\u003C/span>) {\n    \u003Cspan class=\"hljs-title function_\">demonstrateTextWrapping\u003C/span>();\n}\n\u003C/code>\u003C/pre>\u003Ch2 id=\"platform-specific-formatting-strategies\">Platform-Specific Formatting Strategies\u003C/h2>\n\u003Ch3 id=\"github-and-git-integration\">GitHub and Git Integration\u003C/h3>\n\u003Cp>Optimizing text wrapping for version control and collaborative development:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-markdown\">\u003Cspan class=\"hljs-section\"># Git-Friendly Text Formatting\u003C/span>\n\n\u003Cspan class=\"hljs-section\">## Commit Message Guidelines (72 characters)\u003C/span>\n\nUse shorter line lengths in documentation that will be viewed\nin commit messages, pull requests, and terminal environments.\nThis ensures proper display in Git tools and command-line\ninterfaces.\n\n\u003Cspan class=\"hljs-section\">## Pull Request Descriptions (80 characters)\u003C/span>\n\nPull request descriptions should use consistent line wrapping to ensure\nreadability across different GitHub interface views, including mobile\ndevices and split-screen code review environments.\n\n\u003Cspan class=\"hljs-section\">## Documentation Files (80-100 characters)\u003C/span>\n\nREADME files and project documentation benefit from moderate line lengths that\nbalance readability with practical considerations for terminal viewing and\ncollaborative editing in various development environments.\n\u003C/code>\u003C/pre>\u003Ch3 id=\"email-and-newsletter-formatting\">Email and Newsletter Formatting\u003C/h3>\n\u003Cp>Adapting Markdown content for email distribution:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-markdown\">\u003Cspan class=\"hljs-section\"># Email-Optimized Text Formatting (72 characters)\u003C/span>\n\nEmail content requires shorter line lengths to accommodate\nvarious email clients and viewing environments. Traditional\nemail formatting uses 72-character lines to ensure proper\ndisplay across different systems and prevent unwanted line\nbreaks in plain text email formats.\n\n\u003Cspan class=\"hljs-section\">## Newsletter Layout Considerations\u003C/span>\n\nNewsletter content should consider both HTML rendering and\nplain text fallbacks, ensuring that line breaks enhance\nrather than disrupt the reading experience across different\nemail client capabilities.\n\u003C/code>\u003C/pre>\u003Ch3 id=\"mobile-and-responsive-design\">Mobile and Responsive Design\u003C/h3>\n\u003Cp>Creating content that adapts to different screen sizes:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-markdown\">\u003Cspan class=\"hljs-section\"># Mobile-Optimized Content (60 characters)\u003C/span>\n\nMobile content benefits from shorter line lengths that\naccommodate smaller screen widths and touch-based reading\npatterns. Shorter lines improve readability on mobile\ndevices and reduce horizontal scrolling.\n\n\u003Cspan class=\"hljs-section\">## Responsive Text Strategies\u003C/span>\n\nContent creators should consider how their text will\nreflow on different devices, ensuring that line breaks\nenhance rather than disrupt the mobile reading experience\nacross various screen orientations and sizes.\n\u003C/code>\u003C/pre>\u003Ch2 id=\"advanced-line-break-techniques\">Advanced Line Break Techniques\u003C/h2>\n\u003Ch3 id=\"semantic-line-breaks\">Semantic Line Breaks\u003C/h3>\n\u003Cp>Using line breaks to enhance content structure and meaning:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-markdown\">\u003Cspan class=\"hljs-section\"># Semantic Line Breaking Example\u003C/span>\n\n\u003Cspan class=\"hljs-section\">## Traditional Paragraph Formatting\u003C/span>\n\nThis paragraph uses traditional formatting where sentences flow naturally across line boundaries without considering the semantic structure of the content, which can make it harder to parse the meaning and relationships between different ideas and concepts.\n\n\u003Cspan class=\"hljs-section\">## Semantic Line Breaks\u003C/span>\n\nThis paragraph uses semantic line breaks\nwhere each line contains a complete thought or clause.\nThis approach makes the content easier to scan,\nimproves diff readability in version control,\nand enhances the editing experience\nby allowing writers to work with meaningful chunks of content\nrather than arbitrary line length boundaries.\n\n\u003Cspan class=\"hljs-section\">## Benefits of Semantic Formatting\u003C/span>\n\nSemantic line breaks offer several advantages:\n\n\u003Cspan class=\"hljs-bullet\">-\u003C/span> Each line contains a complete thought\n\u003Cspan class=\"hljs-bullet\">-\u003C/span> Version control diffs are more meaningful  \n\u003Cspan class=\"hljs-bullet\">-\u003C/span> Editorial review becomes more focused\n\u003Cspan class=\"hljs-bullet\">-\u003C/span> Content restructuring is simplified\n\u003Cspan class=\"hljs-bullet\">-\u003C/span> Translation workflows are improved\n\u003C/code>\u003C/pre>\u003Ch3 id=\"contextual-line-length-management\">Contextual Line Length Management\u003C/h3>\n\u003Cp>Adapting line lengths based on content context and purpose:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-python\">\u003Cspan class=\"hljs-comment\"># contextual-formatter.py - Context-aware text formatting\u003C/span>\n\u003Cspan class=\"hljs-keyword\">import\u003C/span> re\n\u003Cspan class=\"hljs-keyword\">from\u003C/span> typing \u003Cspan class=\"hljs-keyword\">import\u003C/span> \u003Cspan class=\"hljs-type\">List\u003C/span>, \u003Cspan class=\"hljs-type\">Dict\u003C/span>, \u003Cspan class=\"hljs-type\">Tuple\u003C/span>\n\n\u003Cspan class=\"hljs-keyword\">class\u003C/span> \u003Cspan class=\"hljs-title class_\">ContextualFormatter\u003C/span>:\n    \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">__init__\u003C/span>(\u003Cspan class=\"hljs-params\">self\u003C/span>):\n        self.context_rules = {\n            \u003Cspan class=\"hljs-string\">&#x27;heading&#x27;\u003C/span>: {\u003Cspan class=\"hljs-string\">&#x27;max_length&#x27;\u003C/span>: \u003Cspan class=\"hljs-number\">120\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;preserve&#x27;\u003C/span>: \u003Cspan class=\"hljs-literal\">True\u003C/span>},\n            \u003Cspan class=\"hljs-string\">&#x27;code-inline&#x27;\u003C/span>: {\u003Cspan class=\"hljs-string\">&#x27;max_length&#x27;\u003C/span>: \u003Cspan class=\"hljs-built_in\">float\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;inf&#x27;\u003C/span>), \u003Cspan class=\"hljs-string\">&#x27;preserve&#x27;\u003C/span>: \u003Cspan class=\"hljs-literal\">True\u003C/span>},\n            \u003Cspan class=\"hljs-string\">&#x27;code-block&#x27;\u003C/span>: {\u003Cspan class=\"hljs-string\">&#x27;max_length&#x27;\u003C/span>: \u003Cspan class=\"hljs-built_in\">float\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;inf&#x27;\u003C/span>), \u003Cspan class=\"hljs-string\">&#x27;preserve&#x27;\u003C/span>: \u003Cspan class=\"hljs-literal\">True\u003C/span>},\n            \u003Cspan class=\"hljs-string\">&#x27;quote&#x27;\u003C/span>: {\u003Cspan class=\"hljs-string\">&#x27;max_length&#x27;\u003C/span>: \u003Cspan class=\"hljs-number\">85\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;preserve&#x27;\u003C/span>: \u003Cspan class=\"hljs-literal\">False\u003C/span>},\n            \u003Cspan class=\"hljs-string\">&#x27;list-item&#x27;\u003C/span>: {\u003Cspan class=\"hljs-string\">&#x27;max_length&#x27;\u003C/span>: \u003Cspan class=\"hljs-number\">90\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;preserve&#x27;\u003C/span>: \u003Cspan class=\"hljs-literal\">False\u003C/span>},\n            \u003Cspan class=\"hljs-string\">&#x27;table&#x27;\u003C/span>: {\u003Cspan class=\"hljs-string\">&#x27;max_length&#x27;\u003C/span>: \u003Cspan class=\"hljs-built_in\">float\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;inf&#x27;\u003C/span>), \u003Cspan class=\"hljs-string\">&#x27;preserve&#x27;\u003C/span>: \u003Cspan class=\"hljs-literal\">True\u003C/span>},\n            \u003Cspan class=\"hljs-string\">&#x27;paragraph&#x27;\u003C/span>: {\u003Cspan class=\"hljs-string\">&#x27;max_length&#x27;\u003C/span>: \u003Cspan class=\"hljs-number\">80\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;preserve&#x27;\u003C/span>: \u003Cspan class=\"hljs-literal\">False\u003C/span>},\n            \u003Cspan class=\"hljs-string\">&#x27;link&#x27;\u003C/span>: {\u003Cspan class=\"hljs-string\">&#x27;max_length&#x27;\u003C/span>: \u003Cspan class=\"hljs-built_in\">float\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;inf&#x27;\u003C/span>), \u003Cspan class=\"hljs-string\">&#x27;preserve&#x27;\u003C/span>: \u003Cspan class=\"hljs-literal\">True\u003C/span>}\n        }\n        \n        self.patterns = {\n            \u003Cspan class=\"hljs-string\">&#x27;heading&#x27;\u003C/span>: re.\u003Cspan class=\"hljs-built_in\">compile\u003C/span>(\u003Cspan class=\"hljs-string\">r&#x27;^#{1,6}\\s+&#x27;\u003C/span>),\n            \u003Cspan class=\"hljs-string\">&#x27;code-block&#x27;\u003C/span>: re.\u003Cspan class=\"hljs-built_in\">compile\u003C/span>(\u003Cspan class=\"hljs-string\">r&#x27;^```[\\s\\S]*?^```$&#x27;\u003C/span>, re.MULTILINE),\n            \u003Cspan class=\"hljs-string\">&#x27;quote&#x27;\u003C/span>: re.\u003Cspan class=\"hljs-built_in\">compile\u003C/span>(\u003Cspan class=\"hljs-string\">r&#x27;^&gt;\\s*&#x27;\u003C/span>),\n            \u003Cspan class=\"hljs-string\">&#x27;list-item&#x27;\u003C/span>: re.\u003Cspan class=\"hljs-built_in\">compile\u003C/span>(\u003Cspan class=\"hljs-string\">r&#x27;^(\\s*)[-*+]\\s+&#x27;\u003C/span>),\n            \u003Cspan class=\"hljs-string\">&#x27;ordered-list&#x27;\u003C/span>: re.\u003Cspan class=\"hljs-built_in\">compile\u003C/span>(\u003Cspan class=\"hljs-string\">r&#x27;^(\\s*)\\d+\\.\\s+&#x27;\u003C/span>),\n            \u003Cspan class=\"hljs-string\">&#x27;table-row&#x27;\u003C/span>: re.\u003Cspan class=\"hljs-built_in\">compile\u003C/span>(\u003Cspan class=\"hljs-string\">r&#x27;\\|.*\\|&#x27;\u003C/span>),\n            \u003Cspan class=\"hljs-string\">&#x27;horizontal-rule&#x27;\u003C/span>: re.\u003Cspan class=\"hljs-built_in\">compile\u003C/span>(\u003Cspan class=\"hljs-string\">r&#x27;^[-*_]{3,}$&#x27;\u003C/span>)\n        }\n    \n    \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">identify_context\u003C/span>(\u003Cspan class=\"hljs-params\">self, line: \u003Cspan class=\"hljs-built_in\">str\u003C/span>\u003C/span>) -&gt; \u003Cspan class=\"hljs-built_in\">str\u003C/span>:\n        \u003Cspan class=\"hljs-string\">&quot;&quot;&quot;Identify the context type of a line&quot;&quot;&quot;\u003C/span>\n        line_stripped = line.strip()\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> \u003Cspan class=\"hljs-keyword\">not\u003C/span> line_stripped:\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;empty&#x27;\u003C/span>\n        \n        \u003Cspan class=\"hljs-comment\"># Check patterns in order of specificity\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> self.patterns[\u003Cspan class=\"hljs-string\">&#x27;heading&#x27;\u003C/span>].\u003Cspan class=\"hljs-keyword\">match\u003C/span>(line):\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;heading&#x27;\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">elif\u003C/span> self.patterns[\u003Cspan class=\"hljs-string\">&#x27;horizontal-rule&#x27;\u003C/span>].\u003Cspan class=\"hljs-keyword\">match\u003C/span>(line_stripped):\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;horizontal-rule&#x27;\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">elif\u003C/span> self.patterns[\u003Cspan class=\"hljs-string\">&#x27;quote&#x27;\u003C/span>].\u003Cspan class=\"hljs-keyword\">match\u003C/span>(line):\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;quote&#x27;\u003C/span>  \n        \u003Cspan class=\"hljs-keyword\">elif\u003C/span> self.patterns[\u003Cspan class=\"hljs-string\">&#x27;list-item&#x27;\u003C/span>].\u003Cspan class=\"hljs-keyword\">match\u003C/span>(line) \u003Cspan class=\"hljs-keyword\">or\u003C/span> self.patterns[\u003Cspan class=\"hljs-string\">&#x27;ordered-list&#x27;\u003C/span>].\u003Cspan class=\"hljs-keyword\">match\u003C/span>(line):\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;list-item&#x27;\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">elif\u003C/span> self.patterns[\u003Cspan class=\"hljs-string\">&#x27;table-row&#x27;\u003C/span>].\u003Cspan class=\"hljs-keyword\">match\u003C/span>(line):\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;table&#x27;\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">else\u003C/span>:\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;paragraph&#x27;\u003C/span>\n    \n    \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">format_content_by_context\u003C/span>(\u003Cspan class=\"hljs-params\">self, markdown: \u003Cspan class=\"hljs-built_in\">str\u003C/span>\u003C/span>) -&gt; \u003Cspan class=\"hljs-built_in\">str\u003C/span>:\n        \u003Cspan class=\"hljs-string\">&quot;&quot;&quot;Format markdown content based on contextual rules&quot;&quot;&quot;\u003C/span>\n        lines = markdown.split(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>)\n        formatted_lines = []\n        in_code_block = \u003Cspan class=\"hljs-literal\">False\u003C/span>\n        \n        i = \u003Cspan class=\"hljs-number\">0\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">while\u003C/span> i &lt; \u003Cspan class=\"hljs-built_in\">len\u003C/span>(lines):\n            line = lines[i]\n            \n            \u003Cspan class=\"hljs-comment\"># Handle code blocks specially\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> line.strip().startswith(\u003Cspan class=\"hljs-string\">&#x27;```&#x27;\u003C/span>):\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> \u003Cspan class=\"hljs-keyword\">not\u003C/span> in_code_block:\n                    in_code_block = \u003Cspan class=\"hljs-literal\">True\u003C/span>\n                    \u003Cspan class=\"hljs-comment\"># Find the end of the code block\u003C/span>\n                    code_block_lines = [line]\n                    i += \u003Cspan class=\"hljs-number\">1\u003C/span>\n                    \u003Cspan class=\"hljs-keyword\">while\u003C/span> i &lt; \u003Cspan class=\"hljs-built_in\">len\u003C/span>(lines):\n                        code_block_lines.append(lines[i])\n                        \u003Cspan class=\"hljs-keyword\">if\u003C/span> lines[i].strip().startswith(\u003Cspan class=\"hljs-string\">&#x27;```&#x27;\u003C/span>):\n                            in_code_block = \u003Cspan class=\"hljs-literal\">False\u003C/span>\n                            \u003Cspan class=\"hljs-keyword\">break\u003C/span>\n                        i += \u003Cspan class=\"hljs-number\">1\u003C/span>\n                    \n                    \u003Cspan class=\"hljs-comment\"># Add code block as-is\u003C/span>\n                    formatted_lines.extend(code_block_lines)\n                    i += \u003Cspan class=\"hljs-number\">1\u003C/span>\n                    \u003Cspan class=\"hljs-keyword\">continue\u003C/span>\n            \n            context = self.identify_context(line)\n            rule = self.context_rules.get(context, self.context_rules[\u003Cspan class=\"hljs-string\">&#x27;paragraph&#x27;\u003C/span>])\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> rule[\u003Cspan class=\"hljs-string\">&#x27;preserve&#x27;\u003C/span>] \u003Cspan class=\"hljs-keyword\">or\u003C/span> \u003Cspan class=\"hljs-built_in\">len\u003C/span>(line) &lt;= rule[\u003Cspan class=\"hljs-string\">&#x27;max_length&#x27;\u003C/span>]:\n                formatted_lines.append(line)\n            \u003Cspan class=\"hljs-keyword\">else\u003C/span>:\n                \u003Cspan class=\"hljs-comment\"># Apply context-specific formatting\u003C/span>\n                formatted_lines.extend(self.wrap_line_for_context(line, context, rule))\n            \n            i += \u003Cspan class=\"hljs-number\">1\u003C/span>\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>.join(formatted_lines)\n    \n    \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">wrap_line_for_context\u003C/span>(\u003Cspan class=\"hljs-params\">self, line: \u003Cspan class=\"hljs-built_in\">str\u003C/span>, context: \u003Cspan class=\"hljs-built_in\">str\u003C/span>, rule: \u003Cspan class=\"hljs-type\">Dict\u003C/span>\u003C/span>) -&gt; \u003Cspan class=\"hljs-type\">List\u003C/span>[\u003Cspan class=\"hljs-built_in\">str\u003C/span>]:\n        \u003Cspan class=\"hljs-string\">&quot;&quot;&quot;Wrap a line according to context-specific rules&quot;&quot;&quot;\u003C/span>\n        max_length = rule[\u003Cspan class=\"hljs-string\">&#x27;max_length&#x27;\u003C/span>]\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> context == \u003Cspan class=\"hljs-string\">&#x27;quote&#x27;\u003C/span>:\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> self.wrap_quote(line, max_length)\n        \u003Cspan class=\"hljs-keyword\">elif\u003C/span> context == \u003Cspan class=\"hljs-string\">&#x27;list-item&#x27;\u003C/span>:\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> self.wrap_list_item(line, max_length)\n        \u003Cspan class=\"hljs-keyword\">else\u003C/span>:\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> self.wrap_paragraph_line(line, max_length)\n    \n    \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">wrap_quote\u003C/span>(\u003Cspan class=\"hljs-params\">self, line: \u003Cspan class=\"hljs-built_in\">str\u003C/span>, max_length: \u003Cspan class=\"hljs-built_in\">int\u003C/span>\u003C/span>) -&gt; \u003Cspan class=\"hljs-type\">List\u003C/span>[\u003Cspan class=\"hljs-built_in\">str\u003C/span>]:\n        \u003Cspan class=\"hljs-string\">&quot;&quot;&quot;Wrap a quoted line, preserving quote markers&quot;&quot;&quot;\u003C/span>\n        quote_match = self.patterns[\u003Cspan class=\"hljs-string\">&#x27;quote&#x27;\u003C/span>].\u003Cspan class=\"hljs-keyword\">match\u003C/span>(line)\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> \u003Cspan class=\"hljs-keyword\">not\u003C/span> quote_match:\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> [line]\n        \n        quote_prefix = quote_match.group(\u003Cspan class=\"hljs-number\">0\u003C/span>)\n        content = line[\u003Cspan class=\"hljs-built_in\">len\u003C/span>(quote_prefix):]\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> \u003Cspan class=\"hljs-built_in\">len\u003C/span>(line) &lt;= max_length:\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> [line]\n        \n        wrapped_lines = []\n        words = content.split()\n        current_line = quote_prefix\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> word \u003Cspan class=\"hljs-keyword\">in\u003C/span> words:\n            test_line = current_line + (\u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> current_line != quote_prefix \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>) + word\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> \u003Cspan class=\"hljs-built_in\">len\u003C/span>(test_line) &lt;= max_length:\n                current_line = test_line\n            \u003Cspan class=\"hljs-keyword\">else\u003C/span>:\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> current_line != quote_prefix:\n                    wrapped_lines.append(current_line)\n                current_line = quote_prefix + word\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> current_line != quote_prefix:\n            wrapped_lines.append(current_line)\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> wrapped_lines\n    \n    \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">wrap_list_item\u003C/span>(\u003Cspan class=\"hljs-params\">self, line: \u003Cspan class=\"hljs-built_in\">str\u003C/span>, max_length: \u003Cspan class=\"hljs-built_in\">int\u003C/span>\u003C/span>) -&gt; \u003Cspan class=\"hljs-type\">List\u003C/span>[\u003Cspan class=\"hljs-built_in\">str\u003C/span>]:\n        \u003Cspan class=\"hljs-string\">&quot;&quot;&quot;Wrap a list item, preserving indentation and markers&quot;&quot;&quot;\u003C/span>\n        list_match = self.patterns[\u003Cspan class=\"hljs-string\">&#x27;list-item&#x27;\u003C/span>].\u003Cspan class=\"hljs-keyword\">match\u003C/span>(line) \u003Cspan class=\"hljs-keyword\">or\u003C/span> self.patterns[\u003Cspan class=\"hljs-string\">&#x27;ordered-list&#x27;\u003C/span>].\u003Cspan class=\"hljs-keyword\">match\u003C/span>(line)\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> \u003Cspan class=\"hljs-keyword\">not\u003C/span> list_match:\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> [line]\n        \n        prefix = list_match.group(\u003Cspan class=\"hljs-number\">0\u003C/span>)\n        content = line[\u003Cspan class=\"hljs-built_in\">len\u003C/span>(prefix):]\n        indent = list_match.group(\u003Cspan class=\"hljs-number\">1\u003C/span>) \u003Cspan class=\"hljs-keyword\">if\u003C/span> list_match.group(\u003Cspan class=\"hljs-number\">1\u003C/span>) \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> \u003Cspan class=\"hljs-built_in\">len\u003C/span>(line) &lt;= max_length:\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> [line]\n        \n        wrapped_lines = []\n        words = content.split()\n        current_line = prefix\n        continuation_prefix = indent + \u003Cspan class=\"hljs-string\">&#x27;  &#x27;\u003C/span>  \u003Cspan class=\"hljs-comment\"># Two spaces for continuation\u003C/span>\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> word \u003Cspan class=\"hljs-keyword\">in\u003C/span> words:\n            test_line = current_line + (\u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> current_line != prefix \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>) + word\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> \u003Cspan class=\"hljs-built_in\">len\u003C/span>(test_line) &lt;= max_length:\n                current_line = test_line\n            \u003Cspan class=\"hljs-keyword\">else\u003C/span>:\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> current_line != prefix:\n                    wrapped_lines.append(current_line)\n                    current_line = continuation_prefix + word\n                \u003Cspan class=\"hljs-keyword\">else\u003C/span>:\n                    \u003Cspan class=\"hljs-comment\"># Very long word, just add it\u003C/span>\n                    current_line = test_line\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> current_line.strip():\n            wrapped_lines.append(current_line)\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> wrapped_lines\n    \n    \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">wrap_paragraph_line\u003C/span>(\u003Cspan class=\"hljs-params\">self, line: \u003Cspan class=\"hljs-built_in\">str\u003C/span>, max_length: \u003Cspan class=\"hljs-built_in\">int\u003C/span>\u003C/span>) -&gt; \u003Cspan class=\"hljs-type\">List\u003C/span>[\u003Cspan class=\"hljs-built_in\">str\u003C/span>]:\n        \u003Cspan class=\"hljs-string\">&quot;&quot;&quot;Wrap a regular paragraph line&quot;&quot;&quot;\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> \u003Cspan class=\"hljs-built_in\">len\u003C/span>(line) &lt;= max_length:\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> [line]\n        \n        words = line.split()\n        wrapped_lines = []\n        current_line = \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> word \u003Cspan class=\"hljs-keyword\">in\u003C/span> words:\n            test_line = current_line + (\u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> current_line \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>) + word\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> \u003Cspan class=\"hljs-built_in\">len\u003C/span>(test_line) &lt;= max_length:\n                current_line = test_line\n            \u003Cspan class=\"hljs-keyword\">else\u003C/span>:\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> current_line:\n                    wrapped_lines.append(current_line)\n                current_line = word\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> current_line:\n            wrapped_lines.append(current_line)\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> wrapped_lines\n    \n    \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">generate_formatting_report\u003C/span>(\u003Cspan class=\"hljs-params\">self, markdown: \u003Cspan class=\"hljs-built_in\">str\u003C/span>\u003C/span>) -&gt; \u003Cspan class=\"hljs-type\">Dict\u003C/span>:\n        \u003Cspan class=\"hljs-string\">&quot;&quot;&quot;Generate a report on text formatting patterns&quot;&quot;&quot;\u003C/span>\n        lines = markdown.split(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>)\n        context_counts = {}\n        length_stats = []\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> line \u003Cspan class=\"hljs-keyword\">in\u003C/span> lines:\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> line.strip():  \u003Cspan class=\"hljs-comment\"># Skip empty lines\u003C/span>\n                context = self.identify_context(line)\n                context_counts[context] = context_counts.get(context, \u003Cspan class=\"hljs-number\">0\u003C/span>) + \u003Cspan class=\"hljs-number\">1\u003C/span>\n                length_stats.append(\u003Cspan class=\"hljs-built_in\">len\u003C/span>(line))\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            \u003Cspan class=\"hljs-string\">&#x27;total_lines&#x27;\u003C/span>: \u003Cspan class=\"hljs-built_in\">len\u003C/span>(lines),\n            \u003Cspan class=\"hljs-string\">&#x27;non_empty_lines&#x27;\u003C/span>: \u003Cspan class=\"hljs-built_in\">len\u003C/span>(length_stats),\n            \u003Cspan class=\"hljs-string\">&#x27;context_distribution&#x27;\u003C/span>: context_counts,\n            \u003Cspan class=\"hljs-string\">&#x27;length_statistics&#x27;\u003C/span>: {\n                \u003Cspan class=\"hljs-string\">&#x27;average&#x27;\u003C/span>: \u003Cspan class=\"hljs-built_in\">sum\u003C/span>(length_stats) / \u003Cspan class=\"hljs-built_in\">len\u003C/span>(length_stats) \u003Cspan class=\"hljs-keyword\">if\u003C/span> length_stats \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-string\">&#x27;max&#x27;\u003C/span>: \u003Cspan class=\"hljs-built_in\">max\u003C/span>(length_stats) \u003Cspan class=\"hljs-keyword\">if\u003C/span> length_stats \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-string\">&#x27;min&#x27;\u003C/span>: \u003Cspan class=\"hljs-built_in\">min\u003C/span>(length_stats) \u003Cspan class=\"hljs-keyword\">if\u003C/span> length_stats \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-string\">&#x27;lines_over_80&#x27;\u003C/span>: \u003Cspan class=\"hljs-built_in\">len\u003C/span>([l \u003Cspan class=\"hljs-keyword\">for\u003C/span> l \u003Cspan class=\"hljs-keyword\">in\u003C/span> length_stats \u003Cspan class=\"hljs-keyword\">if\u003C/span> l &gt; \u003Cspan class=\"hljs-number\">80\u003C/span>]),\n                \u003Cspan class=\"hljs-string\">&#x27;lines_over_100&#x27;\u003C/span>: \u003Cspan class=\"hljs-built_in\">len\u003C/span>([l \u003Cspan class=\"hljs-keyword\">for\u003C/span> l \u003Cspan class=\"hljs-keyword\">in\u003C/span> length_stats \u003Cspan class=\"hljs-keyword\">if\u003C/span> l &gt; \u003Cspan class=\"hljs-number\">100\u003C/span>])\n            }\n        }\n\n\u003Cspan class=\"hljs-comment\"># Example usage\u003C/span>\n\u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">demonstrate_contextual_formatting\u003C/span>():\n    formatter = ContextualFormatter()\n    \n    sample_text = \u003Cspan class=\"hljs-string\">&#x27;&#x27;&#x27;\n# This is a Very Long Heading That Might Exceed Normal Line Length Limits But Should Be Preserved As Is\n\nThis is a regular paragraph that contains quite a lot of text and should be wrapped according to the standard paragraph formatting rules to ensure good readability.\n\n&gt; This is a quoted section that also contains a significant amount of text and should be wrapped while preserving the quote formatting and maintaining the visual indication that this content is quoted material.\n\n- This is a list item with a considerable amount of text that should be wrapped while maintaining proper list formatting and indentation for continued lines\n- Another list item with normal length\n\n```python\n# This code block should not be wrapped at all regardless of line length\ndef very_long_function_name_that_exceeds_typical_limits(parameter_one, parameter_two, parameter_three):\n    return parameter_one + parameter_two + parameter_three\u003C/span>\n\u003C/code>\u003C/pre>\u003Cdiv class=\"table-responsive\">\u003Ctable class=\"table\">\n\u003Cthead>\n\u003Ctr>\n\u003Cth>Column 1\u003C/th>\n\u003Cth>Column 2 with very long header text\u003C/th>\n\u003Cth>Column 3\u003C/th>\n\u003C/tr>\n\u003C/thead>\n\u003Ctbody>\u003Ctr>\n\u003Ctd>Data\u003C/td>\n\u003Ctd>More data that might be quite long\u003C/td>\n\u003Ctd>Value\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>&#39;&#39;&#39;\u003C/td>\n\u003Ctd>\u003C/td>\n\u003Ctd>\u003C/td>\n\u003C/tr>\n\u003C/tbody>\u003C/table>\u003C/div>\n\u003Cpre>\u003Ccode>print(&quot;Original text:&quot;)\nprint(sample_text)\nprint(&quot;\\nFormatted text:&quot;)\nprint(formatter.format_content_by_context(sample_text))\nprint(&quot;\\nFormatting report:&quot;)\nprint(formatter.generate_formatting_report(sample_text))\n\u003C/code>\u003C/pre>\u003Cp>if \u003Cstrong>name\u003C/strong> == &#39;\u003Cstrong>main\u003C/strong>&#39;:\u003Cbr>    demonstrate_contextual_formatting()\u003C/p>\n\u003Cpre>\u003Ccode>\n## Integration with Content Management Systems\n\nText wrapping and line length management integrate seamlessly with comprehensive documentation workflows. When combined with [version control systems and collaborative editing platforms](https://blog.markdowntools.com/posts/markdown-version-control-git-integration-complete-guide), proper formatting ensures that content remains readable and maintainable across different development environments while supporting effective collaborative editing and review processes.\n\nFor sophisticated content presentation, text formatting works effectively with [responsive design systems and Progressive Web App documentation](https://blog.markdowntools.com/posts/markdown-progressive-web-app-documentation-complete-guide) to create content that adapts gracefully to different viewing environments while maintaining optimal readability and user experience across desktop, tablet, and mobile contexts.\n\nWhen building comprehensive content architectures, line length management complements [automated workflow systems and CI/CD integration](https://blog.markdowntools.com/posts/markdown-automation-workflows-complete-guide) by ensuring that automated formatting checks and content validation processes maintain consistent text presentation while supporting efficient content production and publication workflows.\n\n## Automation and Workflow Integration  \n\n### CI/CD Integration for Text Formatting\n\nImplementing automated text formatting validation in continuous integration:\n\n```yaml\n# .github/workflows/text-formatting.yml - Automated formatting checks\nname: Text Formatting Validation\n\non:\n  push:\n    branches: [main, develop]\n  pull_request:\n    branches: [main]\n    paths: [&#39;**/*.md&#39;]\n\njobs:\n  validate-formatting:\n    runs-on: ubuntu-latest\n    \n    steps:\n    - name: Checkout repository\n      uses: actions/checkout@v4\n    \n    - name: Setup Node.js\n      uses: actions/setup-node@v4\n      with:\n        node-version: &#39;18&#39;\n        cache: &#39;npm&#39;\n    \n    - name: Install formatting tools\n      run: |\n        npm install -g markdownlint-cli\n        npm install -g prettier\n        pip install markdown-line-length-checker\n    \n    - name: Check line length compliance\n      run: |\n        node scripts/check-line-lengths.js --max-length 80 --check-all\n    \n    - name: Validate markdown formatting  \n      run: |\n        markdownlint --config .markdownlint.json **/*.md\n    \n    - name: Check text wrapping consistency\n      run: |\n        python scripts/validate-text-wrapping.py --directory content/\n    \n    - name: Generate formatting report\n      if: always()\n      run: |\n        node scripts/generate-formatting-report.js &gt; formatting-report.md\n    \n    - name: Comment on PR with formatting results\n      if: github.event_name == &#39;pull_request&#39;\n      uses: actions/github-script@v6\n      with:\n        script: |\n          const fs = require(&#39;fs&#39;);\n          const report = fs.readFileSync(&#39;formatting-report.md&#39;, &#39;utf8&#39;);\n          \n          github.rest.issues.createComment({\n            issue_number: context.issue.number,\n            owner: context.repo.owner,\n            repo: context.repo.repo,\n            body: `## Text Formatting Report\\n\\n${report}`\n          });\n\u003C/code>\u003C/pre>\u003Ch3 id=\"editor-integration-and-live-formatting\">Editor Integration and Live Formatting\u003C/h3>\n\u003Cp>Creating editor plugins and configurations for consistent formatting:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-javascript\">\u003Cspan class=\"hljs-comment\">// editor-formatter.js - Real-time formatting for editors\u003C/span>\n\u003Cspan class=\"hljs-keyword\">class\u003C/span> \u003Cspan class=\"hljs-title class_\">EditorTextFormatter\u003C/span> {\n    \u003Cspan class=\"hljs-title function_\">constructor\u003C/span>(\u003Cspan class=\"hljs-params\">editor, options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">editor\u003C/span> = editor;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">lineLength\u003C/span>: options.\u003Cspan class=\"hljs-property\">lineLength\u003C/span> || \u003Cspan class=\"hljs-number\">80\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">autoWrap\u003C/span>: options.\u003Cspan class=\"hljs-property\">autoWrap\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">showRuler\u003C/span>: options.\u003Cspan class=\"hljs-property\">showRuler\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">highlightLongLines\u003C/span>: options.\u003Cspan class=\"hljs-property\">highlightLongLines\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            ...options\n        };\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">setupEventListeners\u003C/span>();\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">showRuler\u003C/span>) {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">addLineRuler\u003C/span>();\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">setupEventListeners\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Listen for text changes\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">editor\u003C/span>.\u003Cspan class=\"hljs-title function_\">on\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;change&#x27;\u003C/span>, \u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">instance, changeObj\u003C/span>) =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">autoWrap\u003C/span>) {\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">handleAutoWrap\u003C/span>(changeObj);\n            }\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">highlightLongLines\u003C/span>) {\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">highlightLongLines\u003C/span>();\n            }\n        });\n        \n        \u003Cspan class=\"hljs-comment\">// Listen for paste events\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">editor\u003C/span>.\u003Cspan class=\"hljs-title function_\">on\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;paste&#x27;\u003C/span>, \u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">instance, event\u003C/span>) =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-built_in\">setTimeout\u003C/span>(\u003Cspan class=\"hljs-function\">() =&gt;\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">formatPastedContent\u003C/span>(), \u003Cspan class=\"hljs-number\">10\u003C/span>);\n        });\n        \n        \u003Cspan class=\"hljs-comment\">// Add custom commands\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">editor\u003C/span>.\u003Cspan class=\"hljs-title function_\">setOption\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;extraKeys&#x27;\u003C/span>, {\n            \u003Cspan class=\"hljs-string\">&#x27;Ctrl-Shift-F&#x27;\u003C/span>: \u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">cm\u003C/span>) =&gt;\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">formatSelection\u003C/span>(),\n            \u003Cspan class=\"hljs-string\">&#x27;Alt-Q&#x27;\u003C/span>: \u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">cm\u003C/span>) =&gt;\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">rewrapParagraph\u003C/span>()\n        });\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">addLineRuler\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">editor\u003C/span>.\u003Cspan class=\"hljs-title function_\">setOption\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;rulers&#x27;\u003C/span>, [{\n            \u003Cspan class=\"hljs-attr\">column\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">lineLength\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">color\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;#ccc&#x27;\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">lineStyle\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;dashed&#x27;\u003C/span>\n        }]);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">formatSelection\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> selection = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">editor\u003C/span>.\u003Cspan class=\"hljs-title function_\">getSelection\u003C/span>();\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!selection) {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span>;\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> wrapper = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">MarkdownTextWrapper\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> formatted = wrapper.\u003Cspan class=\"hljs-title function_\">wrapDocument\u003C/span>(selection);\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">editor\u003C/span>.\u003Cspan class=\"hljs-title function_\">replaceSelection\u003C/span>(formatted);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">rewrapParagraph\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> cursor = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">editor\u003C/span>.\u003Cspan class=\"hljs-title function_\">getCursor\u003C/span>();\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> paragraph = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">findCurrentParagraph\u003C/span>(cursor);\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (paragraph) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> wrapper = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">MarkdownTextWrapper\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> formatted = wrapper.\u003Cspan class=\"hljs-title function_\">wrapParagraph\u003C/span>(paragraph.\u003Cspan class=\"hljs-property\">text\u003C/span>);\n            \n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">editor\u003C/span>.\u003Cspan class=\"hljs-title function_\">replaceRange\u003C/span>(\n                formatted,\n                paragraph.\u003Cspan class=\"hljs-property\">start\u003C/span>,\n                paragraph.\u003Cspan class=\"hljs-property\">end\u003C/span>\n            );\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">findCurrentParagraph\u003C/span>(\u003Cspan class=\"hljs-params\">cursor\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> doc = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">editor\u003C/span>.\u003Cspan class=\"hljs-title function_\">getDoc\u003C/span>();\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> startLine = cursor.\u003Cspan class=\"hljs-property\">line\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> endLine = cursor.\u003Cspan class=\"hljs-property\">line\u003C/span>;\n        \n        \u003Cspan class=\"hljs-comment\">// Find paragraph start\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">while\u003C/span> (startLine &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> line = doc.\u003Cspan class=\"hljs-title function_\">getLine\u003C/span>(startLine - \u003Cspan class=\"hljs-number\">1\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (line.\u003Cspan class=\"hljs-title function_\">trim\u003C/span>() === \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">break\u003C/span>;\n            }\n            startLine--;\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Find paragraph end\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">while\u003C/span> (endLine &lt; doc.\u003Cspan class=\"hljs-title function_\">lineCount\u003C/span>() - \u003Cspan class=\"hljs-number\">1\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> line = doc.\u003Cspan class=\"hljs-title function_\">getLine\u003C/span>(endLine + \u003Cspan class=\"hljs-number\">1\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (line.\u003Cspan class=\"hljs-title function_\">trim\u003C/span>() === \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">break\u003C/span>;\n            }\n            endLine++;\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> paragraphLines = [];\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">let\u003C/span> i = startLine; i &lt;= endLine; i++) {\n            paragraphLines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(doc.\u003Cspan class=\"hljs-title function_\">getLine\u003C/span>(i));\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            \u003Cspan class=\"hljs-attr\">text\u003C/span>: paragraphLines.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">start\u003C/span>: { \u003Cspan class=\"hljs-attr\">line\u003C/span>: startLine, \u003Cspan class=\"hljs-attr\">ch\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span> },\n            \u003Cspan class=\"hljs-attr\">end\u003C/span>: { \u003Cspan class=\"hljs-attr\">line\u003C/span>: endLine, \u003Cspan class=\"hljs-attr\">ch\u003C/span>: doc.\u003Cspan class=\"hljs-title function_\">getLine\u003C/span>(endLine).\u003Cspan class=\"hljs-property\">length\u003C/span> }\n        };\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">highlightLongLines\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> doc = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">editor\u003C/span>.\u003Cspan class=\"hljs-title function_\">getDoc\u003C/span>();\n        \n        \u003Cspan class=\"hljs-comment\">// Clear existing marks\u003C/span>\n        doc.\u003Cspan class=\"hljs-title function_\">getAllMarks\u003C/span>().\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">mark\u003C/span> =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (mark.\u003Cspan class=\"hljs-property\">className\u003C/span> === \u003Cspan class=\"hljs-string\">&#x27;long-line-highlight&#x27;\u003C/span>) {\n                mark.\u003Cspan class=\"hljs-title function_\">clear\u003C/span>();\n            }\n        });\n        \n        \u003Cspan class=\"hljs-comment\">// Add marks for long lines\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">let\u003C/span> i = \u003Cspan class=\"hljs-number\">0\u003C/span>; i &lt; doc.\u003Cspan class=\"hljs-title function_\">lineCount\u003C/span>(); i++) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> line = doc.\u003Cspan class=\"hljs-title function_\">getLine\u003C/span>(i);\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (line.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">lineLength\u003C/span>) {\n                doc.\u003Cspan class=\"hljs-title function_\">markText\u003C/span>(\n                    { \u003Cspan class=\"hljs-attr\">line\u003C/span>: i, \u003Cspan class=\"hljs-attr\">ch\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">lineLength\u003C/span> },\n                    { \u003Cspan class=\"hljs-attr\">line\u003C/span>: i, \u003Cspan class=\"hljs-attr\">ch\u003C/span>: line.\u003Cspan class=\"hljs-property\">length\u003C/span> },\n                    { \u003Cspan class=\"hljs-attr\">className\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;long-line-highlight&#x27;\u003C/span> }\n                );\n            }\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">formatPastedContent\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> history = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">editor\u003C/span>.\u003Cspan class=\"hljs-title function_\">getHistory\u003C/span>();\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> lastChange = history.\u003Cspan class=\"hljs-property\">done\u003C/span>[history.\u003Cspan class=\"hljs-property\">done\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span> - \u003Cspan class=\"hljs-number\">1\u003C/span>];\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (lastChange &amp;&amp; lastChange.\u003Cspan class=\"hljs-property\">changes\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> wrapper = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">MarkdownTextWrapper\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>);\n            \n            lastChange.\u003Cspan class=\"hljs-property\">changes\u003C/span>.\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">change\u003C/span> =&gt;\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (change.\u003Cspan class=\"hljs-property\">text\u003C/span> &amp;&amp; change.\u003Cspan class=\"hljs-property\">text\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> text = change.\u003Cspan class=\"hljs-property\">text\u003C/span>.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>);\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> formatted = wrapper.\u003Cspan class=\"hljs-title function_\">wrapDocument\u003C/span>(text);\n                    \n                    \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">editor\u003C/span>.\u003Cspan class=\"hljs-title function_\">replaceRange\u003C/span>(\n                        formatted,\n                        change.\u003Cspan class=\"hljs-property\">from\u003C/span>,\n                        change.\u003Cspan class=\"hljs-property\">to\u003C/span>\n                    );\n                }\n            });\n        }\n    }\n}\n\n\u003Cspan class=\"hljs-comment\">// CSS styles for editor integration\u003C/span>\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> editorStyles = \u003Cspan class=\"hljs-string\">`\n.long-line-highlight {\n    background-color: rgba(255, 200, 200, 0.3);\n}\n\n.CodeMirror-ruler {\n    border-left: 1px dashed #ccc;\n}\n\n.text-formatting-toolbar {\n    display: flex;\n    gap: 8px;\n    padding: 4px;\n    border-bottom: 1px solid #ddd;\n}\n\n.text-formatting-button {\n    padding: 4px 8px;\n    border: 1px solid #ccc;\n    background: #f5f5f5;\n    border-radius: 3px;\n    cursor: pointer;\n    font-size: 12px;\n}\n\n.text-formatting-button:hover {\n    background: #e5e5e5;\n}\n\n.text-formatting-status {\n    font-size: 11px;\n    color: #666;\n    padding: 2px 8px;\n}\n`\u003C/span>;\n\n\u003Cspan class=\"hljs-variable language_\">module\u003C/span>.\u003Cspan class=\"hljs-property\">exports\u003C/span> = \u003Cspan class=\"hljs-title class_\">EditorTextFormatter\u003C/span>;\n\u003C/code>\u003C/pre>\u003Ch2 id=\"troubleshooting-common-formatting-issues\">Troubleshooting Common Formatting Issues\u003C/h2>\n\u003Ch3 id=\"inconsistent-line-length-problems\">Inconsistent Line Length Problems\u003C/h3>\n\u003Cp>\u003Cstrong>Problem\u003C/strong>: Different team members using different line length standards\u003C/p>\n\u003Cp>\u003Cstrong>Solutions\u003C/strong>:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-markdown\">\u003Cspan class=\"hljs-section\"># Team Formatting Standards\u003C/span>\n\n\u003Cspan class=\"hljs-section\">## .editorconfig Configuration\u003C/span>\n\nCreate a project-level .editorconfig file:\n\n\u003Cspan class=\"hljs-code\">```ini\nroot = true\n\n[*.md]\ncharset = utf-8\nend_of_line = lf\ninsert_final_newline = true\ntrim_trailing_whitespace = true\nindent_style = space\nindent_size = 2\nmax_line_length = 80\u003C/span>\n\u003C/code>\u003C/pre>\u003Ch2 id=\"vs-code-settings\">VS Code Settings\u003C/h2>\n\u003Cp>Configure consistent settings in .vscode/settings.json:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-json\">\u003Cspan class=\"hljs-punctuation\">{\u003C/span>\n  \u003Cspan class=\"hljs-attr\">&quot;editor.wordWrap&quot;\u003C/span>\u003Cspan class=\"hljs-punctuation\">:\u003C/span> \u003Cspan class=\"hljs-string\">&quot;wordWrapColumn&quot;\u003C/span>\u003Cspan class=\"hljs-punctuation\">,\u003C/span>\n  \u003Cspan class=\"hljs-attr\">&quot;editor.wordWrapColumn&quot;\u003C/span>\u003Cspan class=\"hljs-punctuation\">:\u003C/span> \u003Cspan class=\"hljs-number\">80\u003C/span>\u003Cspan class=\"hljs-punctuation\">,\u003C/span>\n  \u003Cspan class=\"hljs-attr\">&quot;editor.rulers&quot;\u003C/span>\u003Cspan class=\"hljs-punctuation\">:\u003C/span> \u003Cspan class=\"hljs-punctuation\">[\u003C/span>\u003Cspan class=\"hljs-number\">80\u003C/span>\u003Cspan class=\"hljs-punctuation\">]\u003C/span>\u003Cspan class=\"hljs-punctuation\">,\u003C/span>\n  \u003Cspan class=\"hljs-attr\">&quot;markdown.preview.breaks&quot;\u003C/span>\u003Cspan class=\"hljs-punctuation\">:\u003C/span> \u003Cspan class=\"hljs-literal\">\u003Cspan class=\"hljs-keyword\">true\u003C/span>\u003C/span>\u003Cspan class=\"hljs-punctuation\">,\u003C/span>\n  \u003Cspan class=\"hljs-attr\">&quot;rewrap.wrappingColumn&quot;\u003C/span>\u003Cspan class=\"hljs-punctuation\">:\u003C/span> \u003Cspan class=\"hljs-number\">80\u003C/span>\n\u003Cspan class=\"hljs-punctuation\">}\u003C/span>\n\u003C/code>\u003C/pre>\u003Ch2 id=\"prettier-configuration\">Prettier Configuration\u003C/h2>\n\u003Cp>Set up automatic formatting with .prettierrc:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-json\">\u003Cspan class=\"hljs-punctuation\">{\u003C/span>\n  \u003Cspan class=\"hljs-attr\">&quot;printWidth&quot;\u003C/span>\u003Cspan class=\"hljs-punctuation\">:\u003C/span> \u003Cspan class=\"hljs-number\">80\u003C/span>\u003Cspan class=\"hljs-punctuation\">,\u003C/span>\n  \u003Cspan class=\"hljs-attr\">&quot;proseWrap&quot;\u003C/span>\u003Cspan class=\"hljs-punctuation\">:\u003C/span> \u003Cspan class=\"hljs-string\">&quot;always&quot;\u003C/span>\u003Cspan class=\"hljs-punctuation\">,\u003C/span>\n  \u003Cspan class=\"hljs-attr\">&quot;parser&quot;\u003C/span>\u003Cspan class=\"hljs-punctuation\">:\u003C/span> \u003Cspan class=\"hljs-string\">&quot;markdown&quot;\u003C/span>\n\u003Cspan class=\"hljs-punctuation\">}\u003C/span>\n\u003C/code>\u003C/pre>\u003Cpre>\u003Ccode>\n### Platform Rendering Differences\n\n**Problem**: Content looks different across various Markdown processors\n\n**Solutions**:\n\n```python\n# platform-tester.py - Test formatting across different platforms\nimport subprocess\nimport tempfile\nimport os\nfrom pathlib import Path\n\nclass PlatformFormattingTester:\n    def __init__(self):\n        self.platforms = {\n            &#39;github&#39;: self.test_github_rendering,\n            &#39;pandoc&#39;: self.test_pandoc_rendering,\n            &#39;markdown-it&#39;: self.test_markdown_it_rendering,\n            &#39;commonmark&#39;: self.test_commonmark_rendering\n        }\n        \n    def test_formatting_compatibility(self, markdown_content):\n        &quot;&quot;&quot;Test how content renders across different platforms&quot;&quot;&quot;\n        results = {}\n        \n        for platform, tester in self.platforms.items():\n            try:\n                result = tester(markdown_content)\n                results[platform] = {\n                    &#39;success&#39;: True,\n                    &#39;output&#39;: result,\n                    &#39;warnings&#39;: self.analyze_output(result)\n                }\n            except Exception as e:\n                results[platform] = {\n                    &#39;success&#39;: False,\n                    &#39;error&#39;: str(e),\n                    &#39;warnings&#39;: []\n                }\n        \n        return results\n    \n    def test_github_rendering(self, content):\n        &quot;&quot;&quot;Test GitHub-flavored Markdown rendering&quot;&quot;&quot;\n        # Use GitHub API or local GFM processor\n        with tempfile.NamedTemporaryFile(mode=&#39;w&#39;, suffix=&#39;.md&#39;, delete=False) as f:\n            f.write(content)\n            f.flush()\n            \n            result = subprocess.run([\n                &#39;npx&#39;, &#39;marked&#39;, &#39;--gfm&#39;, f.name\n            ], capture_output=True, text=True)\n            \n            os.unlink(f.name)\n            return result.stdout\n    \n    def test_pandoc_rendering(self, content):\n        &quot;&quot;&quot;Test Pandoc rendering&quot;&quot;&quot;\n        result = subprocess.run([\n            &#39;pandoc&#39;, &#39;-f&#39;, &#39;markdown&#39;, &#39;-t&#39;, &#39;html&#39;\n        ], input=content, capture_output=True, text=True)\n        \n        return result.stdout\n    \n    def test_markdown_it_rendering(self, content):\n        &quot;&quot;&quot;Test markdown-it rendering&quot;&quot;&quot;\n        with tempfile.NamedTemporaryFile(mode=&#39;w&#39;, suffix=&#39;.md&#39;, delete=False) as f:\n            f.write(content)\n            f.flush()\n            \n            result = subprocess.run([\n                &#39;npx&#39;, &#39;markdown-it&#39;, f.name\n            ], capture_output=True, text=True)\n            \n            os.unlink(f.name)\n            return result.stdout\n    \n    def test_commonmark_rendering(self, content):\n        &quot;&quot;&quot;Test CommonMark rendering&quot;&quot;&quot;\n        result = subprocess.run([\n            &#39;npx&#39;, &#39;commonmark&#39;\n        ], input=content, capture_output=True, text=True)\n        \n        return result.stdout\n    \n    def analyze_output(self, html_output):\n        &quot;&quot;&quot;Analyze rendered output for potential issues&quot;&quot;&quot;\n        warnings = []\n        \n        # Check for very long lines in output\n        lines = html_output.split(&#39;\\n&#39;)\n        long_lines = [i for i, line in enumerate(lines) if len(line) &gt; 200]\n        if long_lines:\n            warnings.append(f&quot;Long lines in output: {len(long_lines)} lines exceed 200 characters&quot;)\n        \n        # Check for missing line breaks\n        if &#39;&lt;br&gt;&#39; not in html_output and html_output.count(&#39;\\n&#39;) &lt; 3:\n            warnings.append(&quot;Output may be missing expected line breaks&quot;)\n        \n        return warnings\n    \n    def generate_compatibility_report(self, markdown_content):\n        &quot;&quot;&quot;Generate a comprehensive compatibility report&quot;&quot;&quot;\n        results = self.test_formatting_compatibility(markdown_content)\n        \n        report = {\n            &#39;summary&#39;: {\n                &#39;total_platforms&#39;: len(results),\n                &#39;successful_renders&#39;: len([r for r in results.values() if r[&#39;success&#39;]]),\n                &#39;failed_renders&#39;: len([r for r in results.values() if not r[&#39;success&#39;]]),\n                &#39;total_warnings&#39;: sum(len(r.get(&#39;warnings&#39;, [])) for r in results.values())\n            },\n            &#39;platform_results&#39;: results,\n            &#39;recommendations&#39;: self.generate_recommendations(results)\n        }\n        \n        return report\n    \n    def generate_recommendations(self, results):\n        &quot;&quot;&quot;Generate recommendations based on test results&quot;&quot;&quot;\n        recommendations = []\n        \n        failed_platforms = [name for name, result in results.items() if not result[&#39;success&#39;]]\n        if failed_platforms:\n            recommendations.append({\n                &#39;type&#39;: &#39;error&#39;,\n                &#39;message&#39;: f&quot;Rendering failed on {&#39;, &#39;.join(failed_platforms)}&quot;,\n                &#39;action&#39;: &quot;Check markdown syntax and platform-specific requirements&quot;\n            })\n        \n        total_warnings = sum(len(r.get(&#39;warnings&#39;, [])) for r in results.values())\n        if total_warnings &gt; 3:\n            recommendations.append({\n                &#39;type&#39;: &#39;warning&#39;,\n                &#39;message&#39;: f&quot;Multiple rendering warnings detected ({total_warnings})&quot;,\n                &#39;action&#39;: &quot;Review formatting for platform compatibility&quot;\n            })\n        \n        return recommendations\n\n# Usage example\ndef test_document_formatting():\n    tester = PlatformFormattingTester()\n    \n    sample_markdown = &#39;&#39;&#39;\n# Test Document\n\nThis is a paragraph with some **bold text** and *italic text*.\nThe line length should be consistent across different platforms.\n\n## Code Example\n\n```python\ndef example_function():\n    return &quot;This code should render correctly&quot;\n\u003C/code>\u003C/pre>\u003Ch2 id=\"list-example\">List Example\u003C/h2>\n\u003Cul>\n\u003Cli>Item 1 with a reasonably long description that tests wrapping\u003C/li>\n\u003Cli>Item 2 with \u003Ca href=\"https://example.com\">a link\u003C/a> in the text\u003C/li>\n\u003Cli>Item 3 with \u003Ccode>inline code\u003C/code> formatting\u003C/li>\n\u003C/ul>\n\u003Cblockquote>\n\u003Cp>This is a blockquote that might have different rendering\u003Cbr>characteristics across various Markdown processors and\u003Cbr>platforms that support different feature sets.\u003Cbr>&#39;&#39;&#39;\u003C/p>\n\u003C/blockquote>\n\u003Cpre>\u003Ccode>report = tester.generate_compatibility_report(sample_markdown)\nprint(&quot;Platform Compatibility Report:&quot;)\nprint(f&quot;Successful renders: {report[&#39;summary&#39;][&#39;successful_renders&#39;]}/{report[&#39;summary&#39;][&#39;total_platforms&#39;]}&quot;)\nprint(f&quot;Total warnings: {report[&#39;summary&#39;][&#39;total_warnings&#39;]}&quot;)\n\nfor rec in report[&#39;recommendations&#39;]:\n    print(f&quot;{rec[&#39;type&#39;].upper()}: {rec[&#39;message&#39;]}&quot;)\n    print(f&quot;Action: {rec[&#39;action&#39;]}&quot;)\n\u003C/code>\u003C/pre>\u003Cp>if \u003Cstrong>name\u003C/strong> == &#39;\u003Cstrong>main\u003C/strong>&#39;:\u003Cbr>    test_document_formatting()\u003C/p>\n\u003Cp>```\u003C/p>\n\u003Ch2 id=\"conclusion\">Conclusion\u003C/h2>\n\u003Cp>Advanced Markdown text wrapping and line length management techniques provide the foundation for creating professional, readable, and maintainable content that adapts effectively across different platforms and viewing environments. By implementing intelligent wrapping strategies, contextual formatting rules, and automated validation systems, content creators can ensure their documentation maintains consistent presentation while optimizing for both human readers and technical systems.\u003C/p>\n\u003Cp>The key to successful text formatting lies in understanding the specific requirements of your target platforms and audiences, implementing consistent formatting standards across your content ecosystem, and balancing automated formatting with editorial judgment to preserve content meaning and readability. Whether you&#39;re creating technical documentation, blog content, or collaborative editing environments, the techniques covered in this guide provide the tools needed to create well-formatted Markdown content that serves both creators and consumers effectively.\u003C/p>\n\u003Cp>Remember to establish clear formatting guidelines for your team, implement automated validation to maintain consistency, and regularly review your formatting choices based on user feedback and platform evolution. With proper attention to text wrapping and line length management, your Markdown content can achieve professional presentation standards while remaining maintainable and accessible across the diverse ecosystem of tools and platforms that support Markdown content creation and consumption.\u003C/p>\n",[15,19,22,25,28,31,34,37,40],{"id":16,"text":17,"level":18},"why-master-text-wrapping-and-line-length-management","Why Master Text Wrapping and Line Length Management?",2,{"id":20,"text":21,"level":18},"foundation-text-wrapping-concepts","Foundation Text Wrapping Concepts",{"id":23,"text":24,"level":18},"platform-specific-formatting-strategies","Platform-Specific Formatting Strategies",{"id":26,"text":27,"level":18},"advanced-line-break-techniques","Advanced Line Break Techniques",{"id":29,"text":30,"level":18},"troubleshooting-common-formatting-issues","Troubleshooting Common Formatting Issues",{"id":32,"text":33,"level":18},"vs-code-settings","VS Code Settings",{"id":35,"text":36,"level":18},"prettier-configuration","Prettier Configuration",{"id":38,"text":39,"level":18},"list-example","List Example",{"id":41,"text":42,"level":18},"conclusion","Conclusion",[],[45,53,61],{"slug":46,"title":47,"description":48,"excerpt":49,"date":50,"category":9,"author":10,"keywords":51,"readingMinutes":52},"markdown-text-wrapping-line-length-management-complete-guide","Markdown Text Wrapping and Line Length Management: Complete Guide for Professional Documentation and Cross-Platform Compatibility","Master Markdown text wrapping, line length control, and formatting strategies for professional documentation. Learn automatic wrapping, manual breaks, editor configuration, and cross-platform compatibility techniques.","Markdown text wrapping and line length management are crucial for creating readable, maintainable documentation that renders consistently across different platforms, editors, and display…","2025-11-05","markdown text wrapping, line length markdown, markdown line breaks, text formatting, markdown editors, documentation standards, text width control, markdown best practices",20,{"slug":54,"title":55,"description":56,"excerpt":57,"date":58,"category":9,"author":10,"keywords":59,"readingMinutes":60},"markdown-line-spacing-paragraph-formatting-complete-guide","Markdown Line Spacing and Paragraph Formatting: Complete Guide to Text Layout and Visual Spacing","Master Markdown line spacing, paragraph formatting, and text layout techniques. Learn to control spacing, create visual breaks, and format paragraphs for professional documentation and content.","Effective line spacing and paragraph formatting in Markdown enables precise control over text layout and visual presentation, creating professional documentation that guides reader attention and…","2026-01-04","markdown line spacing, paragraph formatting markdown, markdown text layout, markdown spacing control, paragraph breaks markdown, markdown visual spacing, text formatting markdown",10,{"slug":62,"title":63,"description":64,"excerpt":65,"date":66,"category":9,"author":10,"keywords":67,"readingMinutes":52},"markdown-document-templates-automation-complete-guide","Markdown Document Templates and Automation: Complete Guide for Streamlined Content Creation and Workflow Optimization","Master Markdown document templates and automation techniques to streamline content creation workflows. Learn template design patterns, variable substitution, automated generation, and integration with modern development tools for efficient documentation systems.","Markdown document templates and automation systems transform repetitive content creation tasks into efficient, standardized workflows that ensure consistency, reduce errors, and dramatically…","2025-11-30","markdown templates, markdown automation, document templates markdown, markdown workflow automation, markdown templating systems, automated markdown generation, markdown content management",1792184944410]