{"id":28746807,"url":"https://github.com/schlessera/markdown-escape-php","last_synced_at":"2026-04-30T07:40:04.134Z","repository":{"id":299390801,"uuid":"1002872864","full_name":"schlessera/markdown-escape-php","owner":"schlessera","description":"[WIP] A PHP library for escaping content to be safely embedded in Markdown without breaking rendering. Supports multiple Markdown dialects and provides context-aware escaping for different use cases.","archived":false,"fork":false,"pushed_at":"2025-06-16T13:53:00.000Z","size":106,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-30T07:39:58.791Z","etag":null,"topics":["escape","llm","markdown","php","security"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/schlessera.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-16T09:20:06.000Z","updated_at":"2025-06-16T13:53:03.000Z","dependencies_parsed_at":"2025-06-16T10:35:40.293Z","dependency_job_id":"176221ee-3dff-46bf-94cb-0bc5dd29a240","html_url":"https://github.com/schlessera/markdown-escape-php","commit_stats":null,"previous_names":["schlessera/markdown-escape-php"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/schlessera/markdown-escape-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schlessera%2Fmarkdown-escape-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schlessera%2Fmarkdown-escape-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schlessera%2Fmarkdown-escape-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schlessera%2Fmarkdown-escape-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/schlessera","download_url":"https://codeload.github.com/schlessera/markdown-escape-php/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schlessera%2Fmarkdown-escape-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32458237,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T22:27:22.272Z","status":"online","status_checked_at":"2026-04-30T02:00:05.929Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["escape","llm","markdown","php","security"],"created_at":"2025-06-16T15:48:38.908Z","updated_at":"2026-04-30T07:40:04.119Z","avatar_url":"https://github.com/schlessera.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Markdown Escape PHP [⚠️ WIP ⚠️]\n\n[![Tests](https://github.com/schlessera/markdown-escape-php/workflows/Tests/badge.svg)](https://github.com/schlessera/markdown-escape-php/actions)\n[![Code Coverage](https://codecov.io/gh/schlessera/markdown-escape-php/graph/badge.svg?token=A9JB5LMQXY)](https://codecov.io/gh/schlessera/markdown-escape-php)\n[![Latest Stable Version](https://poser.pugx.org/schlessera/markdown-escape/v/stable)](https://packagist.org/packages/schlessera/markdown-escape)\n[![License](https://poser.pugx.org/schlessera/markdown-escape/license)](https://packagist.org/packages/schlessera/markdown-escape)\n\nA PHP library for escaping content to be safely embedded in Markdown without breaking rendering. Supports multiple Markdown dialects and provides context-aware escaping for different use cases.\n\n## Features\n\n- **Multiple Dialect Support**: CommonMark and GitHub Flavored Markdown (GFM)\n- **Context-Aware Escaping**: Different escaping strategies for URLs, inline code, code blocks, and general content\n- **Templating System**: Built-in templating engine with PHP short tags for generating complex Markdown documents\n- **SOLID Design**: Built with clean architecture and design patterns for easy extension\n- **PHP 7.2+ Compatible**: Works with PHP 7.2 and all newer versions\n- **Fully Tested**: Comprehensive unit and feature tests\n- **Zero Dependencies**: No runtime dependencies beyond PHP itself\n- **High Test Coverage**: 98%+ code coverage with comprehensive unit and integration tests\n\n## Installation\n\nInstall via Composer:\n\n```bash\ncomposer require schlessera/markdown-escape\n```\n\n## Quick Start\n\n```php\nuse Markdown\\Escape\\MarkdownEscape;\n\n// Create an escaper instance (defaults to CommonMark)\n$escape = new MarkdownEscape();\n\n// Or use factory methods for specific dialects\n$escape = MarkdownEscape::commonMark();\n$escape = MarkdownEscape::gfm();\n\n// Escape general content\n$escaped = $escape-\u003eescapeContent('This is *bold* and _italic_ text');\n// Output: This is \\*bold\\* and \\_italic\\_ text\n\n// Escape URLs\n$escaped = $escape-\u003eescapeUrl('https://example.com/path with spaces/(parentheses)');\n// Output: https://example.com/path%20with%20spaces/%28parentheses%29\n\n// Escape inline code\n$escaped = $escape-\u003eescapeInlineCode('Use `backticks` for code');\n// Output: ``Use `backticks` for code``\n\n// Escape code blocks\n$code = \"function test() {\\n    return true;\\n}\";\n$escaped = $escape-\u003eescapeCodeBlock($code, ['use_fences' =\u003e true, 'language' =\u003e 'php']);\n// Output: ```php\n//         function test() {\n//             return true;\n//         }\n//         ```\n```\n\n### Templating System\n\nGenerate complex Markdown documents using the built-in templating system:\n\n```php\nuse Markdown\\Escape\\MarkdownTemplate;\n\n// Create template instance\n$template = MarkdownTemplate::gfm();\n\n// Use built-in templates\n$result = $template-\u003erender('table', [\n    'headers' =\u003e ['Name', 'Status', 'Progress'],\n    'rows' =\u003e [\n        ['Feature **A**', 'Complete', '100%'],\n        ['Feature *B*', 'In Progress', '75%']\n    ]\n]);\n\n// Custom templates with automatic escaping\n$result = $template-\u003erenderString('\n# \u003c?= $md-\u003eescapeContent($title) ?\u003e\n\nPublished by \u003c?= $md-\u003eescapeContent($author) ?\u003e on \u003c?= date(\"Y-m-d\") ?\u003e\n\n\u003c?php foreach ($sections as $section): ?\u003e\n## \u003c?= $md-\u003eescapeContent($section[\"title\"]) ?\u003e\n\n\u003c?= $md-\u003eescapeContent($section[\"content\"]) ?\u003e\n\u003c?php endforeach; ?\u003e\n', [\n    'title' =\u003e 'My **Important** Document',\n    'author' =\u003e 'John [Admin] Doe',\n    'sections' =\u003e [\n        ['title' =\u003e 'Introduction', 'content' =\u003e 'Content with *markdown* syntax...']\n    ]\n]);\n```\n\n## Documentation\n\n- [User Guide](docs/user-guide.md) - Comprehensive guide to using the library\n- [Templating Guide](docs/templating-guide.md) - Complete guide to the templating system\n- [Architecture](docs/architecture.md) - Understanding the library's design\n- [Examples](examples/) - Working examples demonstrating various features\n- [Code Coverage](docs/code-coverage.md) - Testing and coverage information\n\n## Requirements\n\n- PHP 7.2 or higher\n- Composer for dependency management\n\n## Development\n\n### Running Tests\n\n```bash\ncomposer test              # Run all tests\ncomposer test:unit         # Run unit tests only\ncomposer test:integration  # Run integration tests only\ncomposer test:performance  # Run performance tests\n```\n\n### Code Coverage\n\n```bash\ncomposer test:coverage     # Generate HTML coverage report and text summary\ncomposer test:coverage:clover  # Generate Clover XML report\ncomposer coverage:badge    # Generate coverage badge\n\n# View coverage report\nopen coverage/html/index.html  # macOS\nxdg-open coverage/html/index.html  # Linux\nstart coverage/html/index.html  # Windows\n```\n\n### Code Style\n\n```bash\ncomposer cs       # Check code style\ncomposer cs-fix   # Fix code style issues\n```\n\n### Static Analysis\n\n```bash\ncomposer phpstan\n```\n\n### PHP Compatibility Check\n\n```bash\ncomposer phpcompat  # Checks PHP 7.2+ compatibility\n```\n\n### Full Check\n\n```bash\ncomposer check    # Runs all checks (CS, PHPStan, PHP compatibility, and tests)\n```\n\n## License\n\nThis library is released under the MIT License. See [LICENSE](LICENSE) file for details.\n\n## Contributing\n\nContributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.\n\n## Support\n\nIf you discover any security related issues, please email alain.schlesser@gmail.com instead of using the issue tracker.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschlessera%2Fmarkdown-escape-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschlessera%2Fmarkdown-escape-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschlessera%2Fmarkdown-escape-php/lists"}