{"id":18136249,"url":"https://github.com/purarue/pmark","last_synced_at":"2026-02-10T00:02:29.696Z","repository":{"id":94610501,"uuid":"285393760","full_name":"purarue/pmark","owner":"purarue","description":"A hacky, markdown pre-processor/generator","archived":false,"fork":false,"pushed_at":"2024-11-12T04:11:30.000Z","size":49,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-12T04:29:50.798Z","etag":null,"topics":["cli","markdown","markdown-generator","scripting"],"latest_commit_sha":null,"homepage":"","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/purarue.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}},"created_at":"2020-08-05T20:11:30.000Z","updated_at":"2024-11-12T04:11:34.000Z","dependencies_parsed_at":"2024-11-01T14:41:34.456Z","dependency_job_id":"222cc178-1493-49e6-894d-441a06af5d2c","html_url":"https://github.com/purarue/pmark","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purarue%2Fpmark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purarue%2Fpmark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purarue%2Fpmark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purarue%2Fpmark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/purarue","download_url":"https://codeload.github.com/purarue/pmark/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230532452,"owners_count":18240792,"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":["cli","markdown","markdown-generator","scripting"],"created_at":"2024-11-01T14:41:24.385Z","updated_at":"2026-02-10T00:02:19.685Z","avatar_url":"https://github.com/purarue.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pmark\n\nA hacky, markdown pre-processor.\n\nUses code blocks to generate markdown, from within the markdown itself.\n\nThis allows you to specify any sort of script to execute as a code block, whose contents then get replaced by the output of the script.\n\nAs an example, in a file `P_README.md`:\n\n    ## README\n\n    Description of project\n\n    ```\n    \u003e\u003e\u003ePMARK\n    #!/bin/sh\n    printf 'This was last edited by %s on *%s*\\n' \"$(whoami)\" \"$(date)\"\n    ```\n\nRunning `pmark ./P_README.md` would generate the file `README.md`, with contents:\n\n    ## README\n\n    Description of project\n\n    This was last edited by username on *Wed 05 Aug 2020 05:44:55 AM PDT*\n\n---\n\nSay you want a markdown file to act as an index for other directories in the folder, to create a table of contents of sort.\n\nDirectory Contents:\n\n```\n.\n├── 01\n│   └── README.md\n├── 02\n│   └── README.md\n├── 03\n│   └── README.md\n└── P_TABLE_OF_CONTENTS.md\n```\n\n`P_TABLE_OF_CONTENTS.md`:\n\n    Book Contents:\n\n    ```\n    \u003e\u003e\u003ePMARK\n    #!/usr/bin/env python3\n    import os\n    for path in os.listdir():\n        if os.path.isdir(path):\n            # create markdown which links to that chapter\n            print(\"* [Chapter {}]({})\".format(path, path + '/README.md')\n    ```\n\n    For more info, visit ...\n\nThat would generate the following markdown:\n\n`TABLE_OF_CONTENTS.md`\n\n    Book Contents:\n\n    * [Chapter 01](01/README.md)\n    * [Chapter 02](02/README.md)\n    * [Chapter 03](03/README.md)\n\n    For more info, visit ...\n\nThere's no restriction on the language, this creates the corresponding script file (with a random name, like `\u003cscript_directory\u003e/CT1PIRQX5-pmark`) and executes it from the markdown files' directory.\n\n---\n\nThis sets two environment variables that are accessible from within the script:\n\n- `RUN_FROM`: The directory `pmark` was executed in.\n- `IN_DIR`: The directory this markdown file is in.\n\n---\n\nIf you wanted to run this against all files which contain `pmark` blocks recursively, can combine this with the `find` command:\n\n`find . -name 'P_*.md' -exec pmark {} +`\n\nOr, with [`fd`](https://github.com/sharkdp/fd):\n\n`fd 'P_*.md' -X pmark`\n\nIf no files are provided, this searches for files matching `P_*.md` in the current directory.\n\n---\n\nI'll often use this in Github `README`s, especially for new projects, as while I'm developing tools/libraries it keeps my `README` up to date with the right flags/example output, e.g.,:\n\n```\n\u003e\u003e\u003ePMARK\nperl -E 'print \"`\"x3, \"\\n\"'\nmake\n./mytool -h\nmake clean\nperl -E 'print \"`\"x3, \"\\n\"'\n```\n\nIn my `.git/hooks/pre-commit` I have, so it runs right before I commit:\n\n```\nfind . -name 'P_*.md' -exec pmark {} \\+\n```\n\nFor examples see [here](https://github.com/purarue/ttally/blob/26f3b32ed6085efea965185c79e831a0ab033770/P_README.md) or [here](https://github.com/purarue/plaintext-playlist/blob/8b053fa45a19ccb4e82f4d47cfe58802a94ff252/P_README.md)\n\nAs a more complex example, I use this for my blog, see [my blog index](https://github.com/purarue/exobrain/tree/24a5440fe57943c531231fd24f4e2bd07856ccc2/sitemap).\n\n### Installation\n\nOr [`basher`](https://github.com/basherpm/basher):\n\n```\nbasher install purarue/pmark\n```\n\n### Specification\n\n- Expects the filename to start with `P_`, the output filename is the rest of the filename excluding the `P_` prefix.\n- The markdown block must start with `\u003e\u003e\u003ePMARK`, all other code blocks are ignored.\n- Like markdown itself, nested code blocks are not allowed. If you want to generate a markdown codeblock using code, see [`examples/P_SHELL.md`](examples/P_SHELL.md) for a workaround.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpurarue%2Fpmark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpurarue%2Fpmark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpurarue%2Fpmark/lists"}