{"id":22774350,"url":"https://github.com/yr72dpi/bbcode","last_synced_at":"2026-05-01T09:32:27.029Z","repository":{"id":171558927,"uuid":"417528504","full_name":"YR72dpi/BBcode","owner":"YR72dpi","description":"¤ The `bbcode` class is a PHP utility that allows you to convert BBCode (Bulletin Board Code) to HTML. It is inspired by the project Genert/bbcode on GitHub.","archived":false,"fork":false,"pushed_at":"2023-08-02T10:38:34.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-30T13:11:29.823Z","etag":null,"topics":["bbcode","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/YR72dpi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2021-10-15T14:26:10.000Z","updated_at":"2023-08-02T10:38:42.000Z","dependencies_parsed_at":"2024-07-27T14:03:50.816Z","dependency_job_id":null,"html_url":"https://github.com/YR72dpi/BBcode","commit_stats":null,"previous_names":["yr72dpi/bbcode"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/YR72dpi/BBcode","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YR72dpi%2FBBcode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YR72dpi%2FBBcode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YR72dpi%2FBBcode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YR72dpi%2FBBcode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YR72dpi","download_url":"https://codeload.github.com/YR72dpi/BBcode/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YR72dpi%2FBBcode/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32492184,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"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":["bbcode","php"],"created_at":"2024-12-11T18:14:21.266Z","updated_at":"2026-05-01T09:32:27.009Z","avatar_url":"https://github.com/YR72dpi.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"*chatGPT Documentation*\n\n# BBCode to HTML Converter\n\n**Class**: bbcode\n\n## Description\nThe `bbcode` class is a PHP utility that allows you to convert BBCode (Bulletin Board Code) to HTML. It is inspired by the project [Genert/bbcode](https://github.com/Genert/bbcode) on GitHub.\n\n## Parsers\nThe `bbcode` class provides various parsers for different BBCode tags. Each parser is defined as an associative array with the following elements:\n\n- `pattern`: A regular expression to match the BBCode tag.\n- `replace`: The HTML code to replace the matched BBCode tag.\n- `content`: The content to be placed inside the HTML code.\n- `exemple`: An optional example of the BBCode tag for the menu bar.\n\nThe available parsers include:\n\n- **Gras**: `[b]Texte[/b]` -\u003e `\u003cb\u003eTexte\u003c/b\u003e`\n- **Italic**: `[i]Texte[/i]` -\u003e `\u003ci\u003eTexte\u003c/i\u003e`\n- **Sous ligné**: `[u]Texte[/u]` -\u003e `\u003cu\u003eTexte\u003c/u\u003e`\n- **Petit**: `[small]Texte[/small]` -\u003e `\u003csmall\u003eTexte\u003c/small\u003e`\n- **Titre**: `[t]Titre[/t]` -\u003e `\u003ch4\u003eTitre\u003c/h4\u003e`\n- **Paragraphe**: `[p]Texte[/p]` -\u003e `\u003cp\u003eTexte\u003c/p\u003e`\n- **Citation**: `[q]Citation[/q]` -\u003e `\u003cblockquote\u003eCitation\u003c/blockquote\u003e`\n- **Centrer**: `[center]Texte[/center]` -\u003e `\u003cdiv style=\"text-align:center\"\u003eTexte\u003c/div\u003e`\n- **URL**: `[url]Url[/url]` -\u003e `\u003ca target=\"_blank\" href=\"Url\"\u003eUrl\u003c/a\u003e`\n- **URL avec nom**: `[url=Url]Nom[/url]` -\u003e `\u003ca target=\"_blank\" href=\"Url\"\u003eNom\u003c/a\u003e`\n- **Image**: `[img]Url de l'image[/img]` -\u003e `\u003cimg src=\"Url de l'image\"\u003e`\n- **Liste**: \n  ```\n  [list]\n      [*] texte\n      [*] texte\n      [*] texte\n  [/list]\n  ```\n  -\u003e `\u003cul\u003e\u003cli\u003etexte\u003c/li\u003e\u003cli\u003etexte\u003c/li\u003e\u003cli\u003etexte\u003c/li\u003e\u003c/ul\u003e`\n- **Liste 123**:\n  ```\n  [list=1]\n      [*] texte\n      [*] texte\n      [*] texte\n  [/list]\n  ```\n  -\u003e `\u003col\u003e\u003cli\u003etexte\u003c/li\u003e\u003cli\u003etexte\u003c/li\u003e\u003cli\u003etexte\u003c/li\u003e\u003c/ol\u003e`\n- **Liste abc**:\n  ```\n  [list=a]\n      [*] texte\n      [*] texte\n      [*] texte\n  [/list]\n  ```\n  -\u003e `\u003col type=\"a\"\u003e\u003cli\u003etexte\u003c/li\u003e\u003cli\u003etexte\u003c/li\u003e\u003cli\u003etexte\u003c/li\u003e\u003c/ol\u003e`\n- **Liste ABC**:\n  ```\n  [list=A]\n      [*] texte\n      [*] texte\n      [*] texte\n  [/list]\n  ```\n  -\u003e `\u003col type=\"A\"\u003e\u003cli\u003etexte\u003c/li\u003e\u003cli\u003etexte\u003c/li\u003e\u003cli\u003etexte\u003c/li\u003e\u003c/ol\u003e`\n- **Liste item**: `[*] texte` -\u003e `\u003cli\u003etexte\u003c/li\u003e`\n\n## Methods\n\n### convertToHtml(string $source, bool $caseSensitive = null): string\nConverts BBCode to HTML.\n\n**Parameters**\n- `$source`: The text containing BBCode to convert to HTML.\n- `$caseSensitive` (optional): A boolean indicating whether the conversion should be case-sensitive. By default, the conversion is case-insensitive.\n\n**Returns**\n- Returns the resulting HTML text after the conversion.\n\n### deleteBalise(string $source): string\nRemoves all BBCode tags from the text.\n\n**Parameters**\n- `$source`: The text containing BBCode tags to remove.\n\n**Returns**\n- Returns the text without BBCode tags.\n\n### addParser(string $name, string $pattern, string $replace, string $content, string $exemple = null): bbcode\nAdds a new parser for a custom BBCode tag.\n\n**Parameters**\n- `$name`: The name of the tag in the menu.\n- `$pattern`: The regular expression (regex) to detect the BBCode tag.\n- `$replace`: The HTML code to replace the BBCode tag.\n- `$content`: The content to be placed in the resulting HTML code.\n- `$exemple` (optional): The default value in the menu input. If not provided, the tag will not be displayed in the menu bar.\n\n**Returns**\n- Returns the instance of the `bbcode` class, allowing method chaining.\n\n### addLinebreakParser(): bbcode\nAdds a parser for the line break BBCode tag.\n\n**Returns**\n- Returns the instance of the `bbcode` class, allowing method chaining.\n\n### menu(string $idClassForm, bool $js_css = true): string\nCreates a menu bar with all available BBCode patterns.\n\n**Parameters**\n- `$idClassForm`: The ID of your form input where the BBCode will be inserted.\n- `$js_css` (optional): A boolean indicating whether to include CSS styles and JavaScript scripts for the menu. By default, it is `true`.\n\n**Returns**\n- Returns the HTML code of the menu bar with buttons to insert BBCode tags.\n\n## Example\n```php\n// Creating an instance of the bbcode class\n$bbcode = new bbcode();\n\n// Convert BBCode to HTML\n$source = \"[b]Bold Text[/b] [i]Italic Text[/i]\";\n$htmlResult = $bbcode-\u003econvertToHtml($source);\n\n// Remove BBCode tags\n$sourceWithBalises = \"[b]Bold Text[/b] [i]Italic Text[/i]\";\n$textWithoutBalises = $bbcode-\u003edeleteBalise($sourceWithBalises);\n\n// Add a custom parser\n$bbcode-\u003eaddParser(\"Color\", \"/\\[color=([a-zA-Z]+)\\](.*?)\\[\\/color\\]/s\", \"\u003cspan style='color:$1;'\u003e$2\u003c/span\u003e\", \"$2\", \"[color=red]Red Text[/color]\");\n\n// Create a menu bar for inserting BBCode tags\n$menu = $bbcode-\u003emenu(\"input_bbcode\");\n```\n\nPlease note that the above examples are based on the available methods in the `bbcode` class. You can use them to manipulate and handle BBCode in your PHP application.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyr72dpi%2Fbbcode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyr72dpi%2Fbbcode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyr72dpi%2Fbbcode/lists"}