{"id":22281925,"url":"https://github.com/gregwar/rst","last_synced_at":"2025-04-08T14:09:48.224Z","repository":{"id":9017390,"uuid":"10773598","full_name":"Gregwar/RST","owner":"Gregwar","description":"PHP library to parse reStructuredText documents","archived":false,"fork":false,"pushed_at":"2024-10-03T15:18:03.000Z","size":294,"stargazers_count":95,"open_issues_count":13,"forks_count":22,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-08T14:09:36.562Z","etag":null,"topics":["library","parser","php","restructuredtext","restructuredtext-parser","rst"],"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/Gregwar.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}},"created_at":"2013-06-18T21:09:20.000Z","updated_at":"2025-02-16T17:53:12.000Z","dependencies_parsed_at":"2023-01-14T11:51:42.093Z","dependency_job_id":null,"html_url":"https://github.com/Gregwar/RST","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gregwar%2FRST","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gregwar%2FRST/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gregwar%2FRST/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gregwar%2FRST/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Gregwar","download_url":"https://codeload.github.com/Gregwar/RST/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247856541,"owners_count":21007620,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["library","parser","php","restructuredtext","restructuredtext-parser","rst"],"created_at":"2024-12-03T16:23:31.623Z","updated_at":"2025-04-08T14:09:48.201Z","avatar_url":"https://github.com/Gregwar.png","language":"PHP","readme":"# RST\n\n[![Build status](https://travis-ci.org/Gregwar/RST.svg?branch=master)](https://travis-ci.org/Gregwar/RST)\n[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=YUXRLWHQSWS6L)\n\nPHP library to parse reStructuredText document\n\n## Usage\n\nThe parser can be used this way:\n\n```php\n\u003c?php\n\n$parser = new Gregwar\\RST\\Parser;\n\n// RST document\n$rst = ' \nHello world\n===========\n\nWhat is it?\n----------\nThis is a **RST** document!\n\nWhere can I get it?\n-------------------\nYou can get it on the `GitHub page \u003chttps://github.com/Gregwar/RST\u003e`_\n';\n\n// Parse it\n$document = $parser-\u003eparse($rst);\n\n// Render it\necho $document;\n/* Will output, in HTML mode:\n\u003ca id=\"title.1\"\u003e\u003c/a\u003e\u003ch1\u003eHello world\u003c/h1\u003e\n\u003ca id=\"title.1.1\"\u003e\u003c/a\u003e\u003ch2\u003eWhat is it?\u003c/h2\u003e\n\u003cp\u003eThis is a \u003cb\u003eRST\u003c/b\u003e document!\u003c/p\u003e\n\u003ca id=\"title.1.2\"\u003e\u003c/a\u003e\u003ch2\u003eWhere can I get it?\u003c/h2\u003e\n\u003cp\u003eYou can get it on the \u003ca href=\"https://github.com/Gregwar/RST\"\u003eGitHub page\u003c/a\u003e\u003c/p\u003e\n*/\n```\n\nFor more information, you can have a look at `test/document/document.rst` and its result\n`test/document/document.html`\n\n## Using the builder\n\nThe builder is another tool that will parses a whole tree of documents and generates\nan output directory containing files.\n\nYou can simply use it with:\n\n```php\n\u003c?php\n\n$builder = new Gregwar\\RST\\Builder;\n$builder-\u003ebuild('input', 'output');\n```\n\nIt will parses all the files in the `input` directory, starting with `index.rst` and\nscanning for dependencies references and generates you target files in the `output`\ndirectory. Default format is HTML.\n\nYou can use those methods on it to customize the build:\n\n* `copy($source, $destination)`: copy the `$source` file or directory to the `$destination`\n  file or directory of the build\n* `mkdir($directory)`: create the `$directory` in build directory\n* `addHook($function)`: adds an hook that will be called after each document is parsed, this\n  hook will be called with the `$document` as parameter and can then tweak it as you want\n* `addBeforeHook($function)`: adds an hook that will be called before parsing the\n  document, the parser will be passed as a parameter\n\n## Abort on error\n\nIn some situation you want the build to continue even if there is some errors,\nlike missing references:\n\n```php\n\u003c?php\n\n// Using parser\n$parser-\u003egetEnvironment()-\u003egetErrorManager()-\u003eabortOnError(false);\n\n// Using builder\n$builder-\u003egetErrorManager()-\u003eabortOnError(false);\n```\n\n## Writing directives\n\n### Step 1: Extends the Directive class\n\nWrite your own class that extends the `Gregwar\\RST\\Directive` class, and define the\nmethod `getName()` that return the directive name.\n\nYou can then redefine one of the following method:\n\n* `processAction()` if your directive simply tweak the document without modifying the nodes\n* `processNode()` if your directive is adding a node\n* `process()` if your directive is tweaking the node that just follows it\n\nSee `Directive.php` for more information\n\n### Step 2: Register your directive\n\nYou can register your directive by directly calling `registerDirective()` on your\n`Parser` object.\n\nElse, you will have to also create your own kernel by extending the `Kernel` class\nand adding your own logic to define extra directives, see `Kernel.php` for more information.\nThen, pass the kernel when constructing the `Parser` or the `Builder`\n\n## License\n\nThis library is under MIT license\n","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=YUXRLWHQSWS6L"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregwar%2Frst","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgregwar%2Frst","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregwar%2Frst/lists"}