{
    "href": "/post/2015/03/02/bookdown-docbook-like-html-output-from-markdown/",
    "relId": "2015/03/02/bookdown-docbook-like-html-output-from-markdown",
    "title": "Bookdown: DocBook-Like HTML Output From Markdown",
    "author": "pmjones",
    "markup": "html",
    "tags": [
        {
            "href": "/tag/bookdown/",
            "relId": "bookdown",
            "title": "Bookdown",
            "author": null,
            "created": null,
            "updated": [],
            "markup": "markdown"
        },
        {
            "href": "/tag/php/",
            "relId": "php",
            "title": "PHP",
            "author": null,
            "created": null,
            "updated": [],
            "markup": "markdown"
        },
        {
            "href": "/tag/programming/",
            "relId": "programming",
            "title": "Programming",
            "author": null,
            "created": null,
            "updated": [],
            "markup": "markdown"
        }
    ],
    "created": "2015-03-02 17:04:08 UTC",
    "updated": [
        "2015-03-02 17:04:08 UTC"
    ],
    "html": "<p>From <a href=\"http://bookdown.io\">bookdown.io</a>:</p>\n<blockquote>\n<p>Bookdown generates <a href=\"http://docbook.org\">DocBook</a>-like HTML output using <a href=\"http://daringfireball.net/projects/markdown/\">Markdown</a> and JSON files instead of XML.</p>\n<p>Bookdown is especially well-suited for publishing project documentation to &gt; GitHub Pages.</p>\n<p>Features include:</p>\n<ul>\n<li>\n<p>Automatic table-of-contents generation as index pages at each hierarchy level</p>\n</li>\n<li>\n<p>Custom index-page titles via JSON configuration</p>\n</li>\n<li>\n<p>Automatic numbering of page headings</p>\n</li>\n<li>\n<p>Automatic previous/next/up navigation headers and footers</p>\n</li>\n<li>\n<p>Multi-page hierarchical output</p>\n</li>\n<li>\n<p>Loading of remote content files via HTTP</p>\n</li>\n<li>\n<p>Templated output for theming</p>\n</li>\n<li>\n<p>Overridable page processing, especially for rendering</p>\n</li>\n</ul>\n<p>Bookdown can be used as a static site generator, or as a way to publish static pages as a subdirectory in an existing site.</p>\n</blockquote>\n<p><!--more--></p>\n<p>Yes, I know, there\u2019s a ton of static site generators for PHP out there already. <a href=\"https://sculpin.io\">Sculpin</a> seems to be the big one (hi Beau!) but it\u2019s not specifically for documentation. Then there\u2019s <a href=\"http://couscous.io\">Couscous</a> (hi Matthieu!), which is for documentation, but it\u2019s not DocBook-like documentation.</p>\n<p>By \u201cDocBook-like\u201d, I mean (among other things) numbered headers, auto-generated tables-of-contents on their own pages, hierarchical multi-page presentation, and the next/previous/up linking at the top and bottom of pages. Look at the <a href=\"http://solarphp.com/manual\">Solar</a> documentation sites for a better idea; the content on those pages was generated with DocBook.</p>\n<p>And frankly, look at the dependency listings on those two projects (<a href=\"https://github.com/sculpin/sculpin/blob/master/composer.json\">Scuplin</a>, <a href=\"https://github.com/CouscousPHP/Couscous/blob/master/composer.json\">Couscous</a>). They\u2019re rather extensive. It that a bad thing? No, but it\u2019s not my speed.  I think we we all know at this point that I\u2019m about reducing dependencies as much as possible, and those are just too much for me.</p>\n<p>Also: I can\u2019t stand YAML. I don\u2019t like YAML embedded in pages, and I don\u2019t like YAML config files. I much prefer JSON, and I don\u2019t want to add YAML frontmatter on Markdown pages.</p>\n<p>So: <a href=\"http://bookdown.io\">Bookdown</a>. This scratches my particular itch, with <a href=\"https://github.com/bookdown/Bookdown.Bookdown/blob/develop/composer.json\">very few dependencies</a>.</p>\n<p>Bookdown, although it <em>can</em> be used as a site generator, is only <em>incidentally</em> a site generator. What it really is is a <em>page</em> generator, with the idea that you can integrate the pages into any other site you want.</p>\n<p>Additionally, Bookdown allows you to pull content from remote locations.  This is especially interesting to me because of the decoupled nature of <a href=\"http://auraphp.com\">Aura</a> libraries. I would like very much to keep the manual documentation on each library in the same repo as that library, then publish each alone, <em>and</em> as part of a collection, without having to copy files around. <a href=\"http://bookdown.io/advanced/remote.html\">Bookdown remote content</a> should allow for that.</p>\n<p>I\u2019m happy with the architecture as well. It took two weekends of experimenting, and then almost exactly a week of dedicated development, to build Bookdown.</p>\n<p>The <a href=\"https://github.com/bookdown/Bookdown.Bookdown\">library</a> is fully separated from the <a href=\"https://github.com/bookdown/Bookdown.Project\">project</a>.  That means you can either run it as a project on its own, or integrate the core library into your own project and glue its services and commands into your own work.</p>\n<p>Everything uses dependency injection through <a href=\"https://github.com/bookdown/Bookdown.Bookdown/blob/develop/src/Container.php\">an application-specific container</a> which helps to keep the concerns well-separated. Everything uses factories and builders, which helps to enable the dependency injection.</p>\n<p>All the underlying processes are decoupled from each other, which should make it easy to replace them with custom processes.  For example, the <a href=\"https://github.com/bookdown/Bookdown.Bookdown/blob/develop/src/Process/Conversion/ConversionProcess.php\">ConversionProcess</a> currently uses <a href=\"https://github.com/thephpleague/commonmark\">CommonMark</a>, but I find it easy to imagine end-users replacing that with Textile, ReStructuredText, or even a combination of conversions that examines the filename extension.</p>\n<p>Finally, the code style is a little bit of a departure for me as well. I have previously used <code>$snake_case</code> variables, but I tried on purpose to use <code>$camelCase</code> instead, and it was not a hard switch to make. Camel-case seems more popular these days, so I may bow to common convention from now on.</p>\n<p>I really enjoyed putting this together. It\u2019s something I\u2019ve wanted to see in PHP land for a long time, and I finally got the opportunity and inclination. Take <a href=\"http://bookdown.io\">Bookdown</a> out for a test drive, see how you like it, and please feel free to provide constructive feedback!</p>\n<hr>\n<p class=\"reddit-links\">Read the Reddit discussion about this post <a href=\"https://www.reddit.com/r/PHP/comments/2xonpx/bookdown_docbooklike_html_output_from_markdown/\">here</a>.</p>\n"
}
