﻿<feed xmlns="http://www.w3.org/2005/Atom">
  <title type="text" xml:lang="en">Markdown</title>
  <link type="application/atom+xml" href="https://d.moonfire.us/tags/markdown/atom.xml" rel="self" />
  <link type="text/html" href="https://d.moonfire.us/tags/markdown/" rel="alternate" />
  <updated>2026-07-22T17:35:48Z</updated>
  <id>https://d.moonfire.us/tags/markdown/</id>
  <author>
    <name>D. Moonfire</name>
  </author>
  <rights>Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International</rights>
  <entry>
    <title>Capabilities</title>
    <link rel="alternate" href="https://d.moonfire.us/blog/2022/12/21/capabilities/" />
    <updated>2022-12-21T06:00:00Z</updated>
    <id>https://d.moonfire.us/blog/2022/12/21/capabilities/</id>
    <category term="development" scheme="https://d.moonfire.us/categories/" label="Development" />
    <category term="mastodon" scheme="https://d.moonfire.us/tags/" label="Mastodon" />
    <category term="pleroma" scheme="https://d.moonfire.us/tags/" label="Pleroma" />
    <category term="gotosocial" scheme="https://d.moonfire.us/tags/" label="GoToSocial" />
    <category term="emoji" scheme="https://d.moonfire.us/tags/" label="Emoji" />
    <category term="markdown" scheme="https://d.moonfire.us/tags/" label="Markdown" />
    <summary type="html">Lately, I've been thinking about capabilities of server APIs and how the clients interact with them. This is driven by a couple things I'm considering doing in the future but also with the frustration that certain features in the fediverse are difficult to implement for clients.
</summary>
    <content type="html">&lt;p&gt;Lately, I've been thinking about capabilities of server APIs and how the clients interact with them. This is driven by a couple things I'm considering doing in the future but also with the frustration that certain features in the fediverse are difficult to implement for clients.&lt;/p&gt;
&lt;p&gt;In specific, I'm very fond of &lt;a href="/tags/markdown/"&gt;Markdown&lt;/a&gt; posts and &lt;a href="/tags/emoji/"&gt;emoji responses&lt;/a&gt;. I love Markdown for all things and I like the low-attention responses of emojis when you don't need to have a big post to say &amp;ldquo;I'm sorry&amp;rdquo; or &amp;ldquo;that blows&amp;rdquo;. My family and work buddies use emoji responses fairly heavily, and it is well supported with Slack, Discord, and even Microsoft Teams as of this week.&lt;/p&gt;
&lt;p&gt;Mastodon decided &lt;a href="https://github.com/mastodon/mastodon/issues/4106"&gt;not to implement them&lt;/a&gt; which is one reason I like &lt;a href="https://pleroma.social/"&gt;Pleroma&lt;/a&gt; and &lt;a href="https://join.misskey.page/en-US/"&gt;Misskey&lt;/a&gt;, though Misskey has historically been too heavy to put on my servers so one of my accounts uses Pleroma.&lt;/p&gt;
&lt;p&gt;However, my favorite Android client, &lt;a href="https://tusky.app/"&gt;Tusky&lt;/a&gt; handles Markdown fairly well on the Glitch instance I'm on, but doesn't for Pleroma and it doesn't do emoji responses at all. &lt;a href="https://husky.adol.pw/"&gt;Huksy&lt;/a&gt; supports these as a fork of Tusky specifically for Pleroma. But Husky doesn't really play well with the Glitch, which means I struggle to find One Client to Rule Them All™.&lt;/p&gt;
&lt;p&gt;Likewise, I want to switch my Pleroma for &lt;a href="https://docs.gotosocial.org/en/latest/"&gt;GoToSocial&lt;/a&gt; for various reasons, but they also support Markdown but not emoji responses. Mainly because there is no standard for emoji responses and if I want to get emoji responses, I need broader acceptance or patterns to work with.&lt;/p&gt;
&lt;p&gt;So, this comes down to capabilities. I want there was a way of having Tusky be able to query the server to determine it can handle emoji responses, so it can turn on that logic so I don't have to have Tusky and Husky. Simple, but I also want it to have the ability to know if the server can handle Markdown (base Mastodon can't, Glitch can) without doing various server identification scans.&lt;/p&gt;
&lt;p&gt;This means a fedi server should have some ability to say &amp;ldquo;I can handle this feature&amp;rdquo; that can be queried. If there was a standard for that, then Tusky or a CLI or any other client could selectively enable or disable the feature as needed.&lt;/p&gt;
&lt;h2&gt;Fine-Grained&lt;/h2&gt;
&lt;p&gt;This is talking about a fine-grained approach to APIs. We have many different fedi servers out there, being developed and also in production. Likewise, we have a number of clients that are also growing as the fedi becomes more popular. I think we're going to see features moving from server to server as they become interesting and there is no way every client can make that choice for every server.&lt;/p&gt;
&lt;p&gt;Identifying those abilities will make it easier to say &amp;ldquo;this client supports Markdown for those servers who have it&amp;rdquo;. It decouples the tie between the servers and the clients by giving a bit of an abstraction, not unlike how the &lt;a href="https://microsoft.github.io/language-server-protocol/"&gt;Language Server Protocol&lt;/a&gt; has made developing language refactoring a lot easier across multiple clients by working to an interface.&lt;/p&gt;
&lt;h2&gt;Approach 1 - Instance Information&lt;/h2&gt;
&lt;p&gt;The first approach, which is somewhat specific to fedi servers, is to update the instance information (&lt;a href="https://docs.joinmastodon.org/methods/instance/#v2"&gt;Mastodon&lt;/a&gt;, Pleroma doesn't have it implemented) to provide that information to clients. This would require updating Glitch and submitting a patch to Pleroma (and maybe Misskey) once some sort of understand/agreement could be found on how to identify these features.&lt;/p&gt;
&lt;p&gt;This is probably the easiest and I think would really benefit the client ecosystem as a whole, not only to give me the features I want.&lt;/p&gt;
&lt;h2&gt;Approach 2 - OpenAPI Support&lt;/h2&gt;
&lt;p&gt;A more generic approach, which is beyond just fedi servers, is to encourage most API servers to also expose their &lt;a href="https://spec.openapis.org/oas/v3.1.0"&gt;OpenAPI v3.1.0&lt;/a&gt; file in a well-known location that describes all the endpoints they support for that specific instance. This has benefits beyond just describing what they can handle.&lt;/p&gt;
&lt;p&gt;However, knowing there is an endpoint that can handle something doesn't mean it works the same way. Pleroma may have the same abilities as Glitch for Markdown, but they may not be communicating them in the same way or require different inputs. There needs to be a signal that indicates a specification is in use.&lt;/p&gt;
&lt;h3&gt;References&lt;/h3&gt;
&lt;p&gt;OpenAPI has a &lt;code&gt;$ref&lt;/code&gt; which can be used to describe an endpoint; this reference is a &lt;a href="https://json-spec.readthedocs.io/reference.html"&gt;JSON Reference&lt;/a&gt; that allows an endpoint to point to another specification either in the same document or to an &lt;a href="https://swagger.io/docs/specification/using-ref/"&gt;external URL&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It is the external URL that interests me. If that points to a fragment of OpenAPI specification that is documented for a specific feature, that would be a signal that the endpoint impelments that specific feature. In other words, if there was an &lt;code&gt;/api/emoji&lt;/code&gt; endpoint that is described as:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-json"&gt;{
    &amp;quot;$ref&amp;quot;: &amp;quot;https://well.known.location/emoji.xml&amp;quot;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then a client could use that information to assume that the endpoint has those abilities and can handle those requests.&lt;/p&gt;
&lt;h3&gt;Capabilities&lt;/h3&gt;
&lt;p&gt;As mentioned before, Mastodon doesn't have that ability since a posting is a posting, be it a response or a full text. OpenAPI also has the ability to add &lt;a href="https://spec.openapis.org/oas/v3.1.0#specification-extensions"&gt;additional specifications&lt;/a&gt; to an endpoint, such as a &lt;code&gt;x-additional-refs&lt;/code&gt; that has an array of &lt;code&gt;$ref&lt;/code&gt; object that do point to specific ones.&lt;/p&gt;
&lt;p&gt;That way, then Mastodon &lt;a href="https://docs.joinmastodon.org/methods/statuses/#create"&gt;post status endpoint&lt;/a&gt; could add a &lt;code&gt;x-additional-$refs&lt;/code&gt; that would allow it to describe the ability to have polls (added in 2.8.0), schedules (2.7.0), in a clear manner that clients would know it could handle those correctly without guessing or inferring from server information. Or&amp;hellip; emoji.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-json"&gt;{
    &amp;quot;paths&amp;quot;: {
        &amp;quot;/api/v1/statuses&amp;quot;: {
            &amp;quot;post&amp;quot;: {
                &amp;quot;operationId&amp;quot;: &amp;quot;postStatus&amp;quot;,
                &amp;quot;parameters&amp;quot;: [],
                &amp;quot;x-additional-$refs&amp;quot;: [
                    &amp;quot;https://well.known.location/emoji.xml&amp;quot;
                ]
            }
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This approach also appeals to some other projects I have in mind, so I'm curious to see what others think of it.&lt;/p&gt;
&lt;h2&gt;Thoughts&lt;/h2&gt;
&lt;p&gt;Obviously, I have a specific goal in mind: Markdown and emoji. But hopefully there is also a benefit for allowing other servers to provide this information and make it easier to create clients and interfaces to their servers.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Integrating Semantic Versioning into MfGames Writing</title>
    <link rel="alternate" href="https://d.moonfire.us/blog/2018/08/27/mfgames-writing-releases/" />
    <updated>2018-08-27T05:00:00Z</updated>
    <id>https://d.moonfire.us/blog/2018/08/27/mfgames-writing-releases/</id>
    <category term="programming" scheme="https://d.moonfire.us/categories/" label="Programming" />
    <category term="writing" scheme="https://d.moonfire.us/categories/" label="Writing" />
    <category term="markdown" scheme="https://d.moonfire.us/tags/" label="Markdown" />
    <category term="mfgames-writing" scheme="https://d.moonfire.us/tags/" label="MfGames Writing" />
    <category term="semantic-release" scheme="https://d.moonfire.us/tags/" label="Semantic Release" />
    <category term="gitlab" scheme="https://d.moonfire.us/tags/" label="Gitlab" />
    <summary type="html">How to release a novel or story using MfGames Writing.
</summary>
    <content type="html">&lt;p&gt;The final component of this &lt;a href="/tags/mfgames-writing/"&gt;MfGames Writing&lt;/a&gt; series is how to integrate &lt;a href="/blog/2018/08/13/publishing-processes/"&gt;semantic releases&lt;/a&gt; into the publication process.&lt;/p&gt;
&lt;p&gt;If you want to use &lt;a href="http://sentimentalversioning.org/"&gt;sentimental versioning&lt;/a&gt;, then you can probably skip this. I like having automatic versioning because it helps me identify the version that beta readers or an editor has when I go to integrate the changes.&lt;/p&gt;
&lt;h1&gt;Series&lt;/h1&gt;
&lt;p&gt;I appear to be writing a short series of post about the tools I use for publication and writing.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/13/publishing-processes/"&gt;Semantic Versions and Releases&lt;/a&gt;: Why semantic versioning helps with the writing process.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/21/mfgames-writing-reasons/"&gt;Evolution of MfGames Writing&lt;/a&gt;: A brief history and reasoning behind the tools.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/22/mfgames-writing-init/"&gt;First Steps Using MfGames Writing&lt;/a&gt;: Starting a new project with MfGames Writing.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/23/mfgames-writing-content/"&gt;Adding Content to MfGames Writing&lt;/a&gt;: Adding front and back matter to novels.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/24/mfgames-writing-docker-and-ci/"&gt;Working with MfGames Writing, CI, and Docker&lt;/a&gt;: Adding automatic building with commits.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/25/mfgames-writing-formats/"&gt;Additional Formats for MfGames Writing&lt;/a&gt;: How to create PDF, MOBI, DOCX, and HTML versions.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/26/mfgames-writing-themes/"&gt;Theming for MfGames Writing&lt;/a&gt;: A light introduction on how to customize the output.&lt;/li&gt;
&lt;li&gt;Integrating Semantic Versioning into MfGames Writing: Tying semantic releases into the process.&lt;/li&gt;
&lt;/ol&gt;
&lt;h1&gt;NPM Packages&lt;/h1&gt;
&lt;p&gt;Like everything else, we pull in a number of packages from NPM to handle the release process.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-shell"&gt;$ npm install
npm install \
  @commitlint/cli \
  @commitlint/config-conventional \
  @semantic-release/changelog \
  @semantic-release/git \
  commitizen \
  cz-conventional-changelog \
  husky \
  semantic-release
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is a pretty big and scary list, but there isn't a lot of clean ways to do this. I'll give a brief summary of them.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;@commitlint&lt;/code&gt; is to make sure we have a consistent commit messages (the &lt;code&gt;feat:&lt;/code&gt; and &lt;code&gt;fix:&lt;/code&gt; stuff). This makes sure everything else works smoothly.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;@semantic-release&lt;/code&gt; packages are to do the release process.&lt;/p&gt;
&lt;p&gt;The two packages, &lt;code&gt;commitizen&lt;/code&gt; and &lt;code&gt;cz-conventional-changelog&lt;/code&gt;, are used to help guide you through creating the commits if you are unfamiliar with it. When these are installed, you can use &lt;code&gt;git cz&lt;/code&gt; instead of &lt;code&gt;git commit&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Finally, &lt;code&gt;husky&lt;/code&gt; is used to make sure you follow the commits correctly because it will reject the commit if you don't follow conventions.&lt;/p&gt;
&lt;h1&gt;Configuration&lt;/h1&gt;
&lt;p&gt;The bulk of the configuration happens inside &lt;code&gt;package.json&lt;/code&gt;. This file can get pretty big, so I'm only going to list the differences.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-json"&gt;{
    &amp;quot;scripts&amp;quot;: {
        &amp;quot;commitmsg&amp;quot;: &amp;quot;commitlint -E GIT_PARAMS&amp;quot;
    },
    &amp;quot;release&amp;quot;: {
        &amp;quot;branch&amp;quot;: &amp;quot;master&amp;quot;,
        &amp;quot;message&amp;quot;: &amp;quot;chore(release): v${nextRelease.version}\n\n${nextRelease.notes}&amp;quot;,
        &amp;quot;verifyConditions&amp;quot;: [
            &amp;quot;@semantic-release/changelog&amp;quot;,
            &amp;quot;@semantic-release/git&amp;quot;
        ],
        &amp;quot;analyzeCommits&amp;quot;: [&amp;quot;@semantic-release/commit-analyzer&amp;quot;],
        &amp;quot;prepare&amp;quot;: [
            &amp;quot;@semantic-release/changelog&amp;quot;,
            &amp;quot;@semantic-release/npm&amp;quot;,
            &amp;quot;@semantic-release/git&amp;quot;
        ],
        &amp;quot;publish&amp;quot;: [],
        &amp;quot;success&amp;quot;: [],
        &amp;quot;fail&amp;quot;: []
    },
    &amp;quot;commitlint&amp;quot;: {
        &amp;quot;extends&amp;quot;: [&amp;quot;@commitlint/config-conventional&amp;quot;]
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;Updating .gitlab-ci.yml&lt;/h1&gt;
&lt;p&gt;To actually use this, we have to modify the GitLab setup slightly.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-yaml"&gt;image: dmoonfire/mfgames-writing-js:1.1.1

stages:
    - publish

publish:
    stage: publish
    tags:
        - docker
    script:
        - npm ci
        - npx commitlint --from=master to=CI_BUILD_REF_NAME
        - npx semantic-release
        - npm run build

    artifacts:
        expire_in: 1 week
        paths:
            - &amp;quot;*.pdf&amp;quot;
            - &amp;quot;*.epub&amp;quot;
            - &amp;quot;*.mobi&amp;quot;
            - &amp;quot;*.docx&amp;quot;
            - &amp;quot;*.html&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The two new lines are what does the release process.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-yaml"&gt;- npx commitlint --from=master to=CI_BUILD_REF_NAME
- npx semantic-release
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;What Does This Give You&lt;/h1&gt;
&lt;p&gt;So, given the amount of setup, what does this give you? Every time you push up a &lt;code&gt;feat:&lt;/code&gt; or &lt;code&gt;fix:&lt;/code&gt;, it will do the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Bump the version to the next appropriate one (1.0.0 to 1.1.0 for example).&lt;/li&gt;
&lt;li&gt;Generate the EPUB, MOBI, etc file.&lt;/li&gt;
&lt;li&gt;Create or update the &lt;code&gt;CHANGELOG.md&lt;/code&gt; file with the summary of your changes.&lt;/li&gt;
&lt;li&gt;Tag the version in Git with &lt;code&gt;v1.1.0&lt;/code&gt; (for example).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;That means, every change you do will have a distinct version. With everything else tied together, you could put it in a header and use that to figure out where to make the changes (my writing group gives me 4-12 sets of corrections, frequently overlapping).&lt;/p&gt;
&lt;p&gt;This isn't for everyone but I have found it very helpful when working with others.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Theming for MfGames Writing</title>
    <link rel="alternate" href="https://d.moonfire.us/blog/2018/08/26/mfgames-writing-themes/" />
    <updated>2018-08-26T05:00:00Z</updated>
    <id>https://d.moonfire.us/blog/2018/08/26/mfgames-writing-themes/</id>
    <category term="programming" scheme="https://d.moonfire.us/categories/" label="Programming" />
    <category term="writing" scheme="https://d.moonfire.us/categories/" label="Writing" />
    <category term="markdown" scheme="https://d.moonfire.us/tags/" label="Markdown" />
    <category term="mfgames-writing" scheme="https://d.moonfire.us/tags/" label="MfGames Writing" />
    <summary type="html">Branding requires a distinct style for writing. Here is how you customize a theme for MfGames Writing to match.
</summary>
    <content type="html">&lt;p&gt;One of the big parts about &lt;a href="/tags/mfgames-writing/"&gt;MfGames Writing&lt;/a&gt; is the ability to customize the appearance of the generated files. If we didn't have that, then every book would look the same and I don't care for that. Books should allow for different themes, chapter numbers, and even spacing. To that regard, everything is funneled through a theme for formatting.&lt;/p&gt;
&lt;h1&gt;Series&lt;/h1&gt;
&lt;p&gt;I appear to be writing a short series of post about the tools I use for publication and writing.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/13/publishing-processes/"&gt;Semantic Versions and Releases&lt;/a&gt;: Why semantic versioning helps with the writing process.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/21/mfgames-writing-reasons/"&gt;Evolution of MfGames Writing&lt;/a&gt;: A brief history and reasoning behind the tools.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/22/mfgames-writing-init/"&gt;First Steps Using MfGames Writing&lt;/a&gt;: Starting a new project with MfGames Writing.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/23/mfgames-writing-content/"&gt;Adding Content to MfGames Writing&lt;/a&gt;: Adding front and back matter to novels.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/24/mfgames-writing-docker-and-ci/"&gt;Working with MfGames Writing, CI, and Docker&lt;/a&gt;: Adding automatic building with commits.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/25/mfgames-writing-formats/"&gt;Additional Formats for MfGames Writing&lt;/a&gt;: How to create PDF, MOBI, DOCX, and HTML versions.&lt;/li&gt;
&lt;li&gt;Theming for MfGames Writing: A light introduction on how to customize the output.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/27/mfgames-writing-releases/"&gt;Integrating Semantic Versioning into MfGames Writing&lt;/a&gt;: Tying semantic releases into the process.&lt;/li&gt;
&lt;/ol&gt;
&lt;h1&gt;HTML&lt;/h1&gt;
&lt;p&gt;The entire theme system is built on HTML and CSS. In previous versions of this, I generated XeLaTeX files for PDF and used a custom conversion utility for Word documents. It also increased the complexity significantly. Switching to a HTML-based system simplified the theme creation and made debugging easier.&lt;/p&gt;
&lt;p&gt;This is one case where looking at a &lt;a href="https://gitlab.com/mfgames-writing/mfgames-writing-clean-js"&gt;reference implementation&lt;/a&gt; will be helpful.&lt;/p&gt;
&lt;h1&gt;Components&lt;/h1&gt;
&lt;p&gt;In the &lt;a href="/blog/2018/08/23/mfgames-writing-content/"&gt;content&lt;/a&gt; post, there are quite a few references to &lt;code&gt;element&lt;/code&gt; on each of the content items. These elements are Liquid-based stylesheets that are provided by the theme.&lt;/p&gt;
&lt;p&gt;For example, the &lt;code&gt;title.xhtml&lt;/code&gt; in the clean theme looks like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;div class=&amp;quot;element-page-break element-page-break-title&amp;quot;&amp;gt;&amp;amp;#160;&amp;lt;/div&amp;gt;
{{html}}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;{{html}}&lt;/code&gt; is where the contents in the &lt;code&gt;source&lt;/code&gt; given on the content will be placed. In this case, the &lt;code&gt;element-page-break&lt;/code&gt; is how I handle page rendering with WeasyPrint.&lt;/p&gt;
&lt;p&gt;A more complicated example would be &lt;a href="https://gitlab.com/mfgames-writing/mfgames-writing-clean-js/blob/master/templates/chapter.xhtml"&gt;chapter.xhtml&lt;/a&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;div class=&amp;quot;element-wrapper {{content.element}}&amp;quot;&amp;gt;
    &amp;lt;div class=&amp;quot;element-page-break element-page-break-right&amp;quot;&amp;gt;&amp;amp;#160;&amp;lt;/div&amp;gt;
    &amp;lt;div class=&amp;quot;element-page-pad-right&amp;quot;&amp;gt;
        {% if content.number %}
        &amp;lt;div class=&amp;quot;element-number&amp;quot;&amp;gt;Chapter {{content.number}}&amp;lt;/div&amp;gt;
        {% endif %}
        &amp;lt;h1 class=&amp;quot;element-title&amp;quot;&amp;gt;{{content.title}}&amp;lt;/h1&amp;gt;
        {{html}}
    &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can see more uses of the Liquid tags. In this case, if we have a &lt;code&gt;number&lt;/code&gt; property in the content, it will insert the &lt;code&gt;Chapter #&lt;/code&gt; above the title of the chapter (from the YAML header) and the contents of the body into &lt;code&gt;{{html}}&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Recursive Templates&lt;/h2&gt;
&lt;p&gt;To reduce copy/paste, there are also recursive templates. For example, the &lt;a href="https://gitlab.com/mfgames-writing/mfgames-writing-clean-js/blob/master/templates/colophon.xhtml"&gt;colophon&lt;/a&gt; template looks like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;---
extends: simple-title
---
{{html}}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Once this page is rendered, the results are formatted by the &lt;a href="https://gitlab.com/mfgames-writing/mfgames-writing-clean-js/blob/master/templates/simple-title.xhtml"&gt;simple-title&lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;div class=&amp;quot;element-wrapper {{content.element}}&amp;quot;&amp;gt;
&amp;lt;div class=&amp;quot;element-page-break element-page-break-right&amp;quot;&amp;gt;&amp;amp;#160;&amp;lt;/div&amp;gt;
&amp;lt;h1 class=&amp;quot;initial&amp;quot;&amp;gt;{{content.title}}&amp;lt;/h1&amp;gt;
{{html}}
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It is recursive, so you can have one template extending another extending another.&lt;/p&gt;
&lt;h1&gt;Styling&lt;/h1&gt;
&lt;p&gt;You'll notice that there is very little styling in the HTML. Instead, most of it is done with a SASS template in the theme. The base style is called &lt;a href="https://gitlab.com/mfgames-writing/mfgames-writing-clean-js/blob/master/styles/stylesheet.scss"&gt;stylesheet.scss&lt;/a&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-scss"&gt;p {
    margin-bottom: 0;
    margin-top: 0;
    text-align: left;
    text-indent: 2em;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Stylesheets can be overridden by specific formats. The most common is having a &lt;a href="https://gitlab.com/mfgames-writing/mfgames-writing-clean-js/blob/master/styles/weasyprint-base.scss"&gt;WeasyPrint-specific stylesheet&lt;/a&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-scss"&gt;@import &amp;quot;stylesheet&amp;quot;;

@page {
    @bottom-center {
        content: counter(page);
        vertical-align: top;
        padding-top: 1em;
    }
    size: letter portrait;
    margin: 3cm 2cm;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To figure out overrides, the system looks for the format name first (&lt;code&gt;html.scss&lt;/code&gt; or &lt;code&gt;weasyprint.scss&lt;/code&gt;) and if it doesn't find one, goes to the base (&lt;code&gt;stylesheet.scss&lt;/code&gt;).&lt;/p&gt;
&lt;h2&gt;Stylesheet Variables&lt;/h2&gt;
&lt;p&gt;Because I'm fond of single points of truth, SASS also lets us have variables so we can pull the version, or information from the edition data.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-scss"&gt;@page :right {
    @top-right {
        content: themeString(&amp;quot;edition.title&amp;quot;);
        vertical-align: bottom;
        padding-bottom: 1em;
    }
    padding-left: 1cm;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;themeString&lt;/code&gt; works just like the Liquid templates.&lt;/p&gt;
&lt;h1&gt;Creating New Themes&lt;/h1&gt;
&lt;p&gt;To create a new theme, I basically just copy all of the clean theme and start customizing.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Additional Formats for MfGames Writing</title>
    <link rel="alternate" href="https://d.moonfire.us/blog/2018/08/25/mfgames-writing-formats/" />
    <updated>2018-08-25T05:00:00Z</updated>
    <id>https://d.moonfire.us/blog/2018/08/25/mfgames-writing-formats/</id>
    <category term="programming" scheme="https://d.moonfire.us/categories/" label="Programming" />
    <category term="writing" scheme="https://d.moonfire.us/categories/" label="Writing" />
    <category term="markdown" scheme="https://d.moonfire.us/tags/" label="Markdown" />
    <category term="mfgames-writing" scheme="https://d.moonfire.us/tags/" label="MfGames Writing" />
    <summary type="html">There are a number of different formats that can be used to generate MfGames Writing output, these are the basics.
</summary>
    <content type="html">&lt;p&gt;Not everyone in the world uses EPUB. Yes, I consider it one of the best formats for me because I can change font size or layout, there is still a big need for print books and Amazon is the source of most ebook sales (though I don't care for that either).&lt;/p&gt;
&lt;p&gt;To handle that, &lt;a href="/tags/mfgames-writing/"&gt;MfGames Writing&lt;/a&gt; provides a pluggable collection of different output formats. This allows you to use only the formats that you way (EPUB2, PDF, HTML) and they can be updated separately.&lt;/p&gt;
&lt;h1&gt;Series&lt;/h1&gt;
&lt;p&gt;I appear to be writing a short series of post about the tools I use for publication and writing.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/13/publishing-processes/"&gt;Semantic Versions and Releases&lt;/a&gt;: Why semantic versioning helps with the writing process.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/21/mfgames-writing-reasons/"&gt;Evolution of MfGames Writing&lt;/a&gt;: A brief history and reasoning behind the tools.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/22/mfgames-writing-init/"&gt;First Steps Using MfGames Writing&lt;/a&gt;: Starting a new project with MfGames Writing.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/23/mfgames-writing-content/"&gt;Adding Content to MfGames Writing&lt;/a&gt;: Adding front and back matter to novels.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/24/mfgames-writing-docker-and-ci/"&gt;Working with MfGames Writing, CI, and Docker&lt;/a&gt;: Adding automatic building with commits.&lt;/li&gt;
&lt;li&gt;Additional Formats for MfGames Writing: How to create PDF, MOBI, DOCX, and HTML versions.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/26/mfgames-writing-themes/"&gt;Theming for MfGames Writing&lt;/a&gt;: A light introduction on how to customize the output.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/27/mfgames-writing-releases/"&gt;Integrating Semantic Versioning into MfGames Writing&lt;/a&gt;: Tying semantic releases into the process.&lt;/li&gt;
&lt;/ol&gt;
&lt;h1&gt;Using Formats&lt;/h1&gt;
&lt;p&gt;Formats are consumed in the edition section of the &lt;code&gt;publication.yaml&lt;/code&gt; file.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-yaml"&gt;metadata:
    title: Test Project
    author: D. Moonfire
    language: en

    theme: &amp;quot;@mfgames-writing/clean&amp;quot;
    outputDirectory: .
    outputFilename: test-project-{{edition.version}}.{{edition.editionName}}

editions:
    epub:
        format: &amp;quot;@mfgames-writing/epub2&amp;quot;
    pdf:
        format: &amp;quot;@mfgames-writing/weasyprint&amp;quot;
        isbn: 978-1-999999
    html:
        format: &amp;quot;@mfgames-writing/html&amp;quot;
        images:
            scale: 0.25
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The format is the name of the package installed with &lt;code&gt;npm install&lt;/code&gt;.&lt;/p&gt;
&lt;h1&gt;EPUB&lt;/h1&gt;
&lt;p&gt;The easiest format to use is EPUB2.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-shell"&gt;$ npm install @mfgames-writing/epub2
$ npm run build:html
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The setup for the NPM commands can be found &lt;a href="/blog/2018/08/24/mfgames-writing-docker-and-ci/"&gt;yesterday&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;When this runs, it will generate an EPUB2 file that will be verifiable with &lt;code&gt;epubcheck&lt;/code&gt;.&lt;/p&gt;
&lt;h1&gt;HTML&lt;/h1&gt;
&lt;p&gt;HTML is also pretty easy.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-shell"&gt;$ npm install @mfgames-writing/html
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;PDF&lt;/h1&gt;
&lt;p&gt;PDF is the complicated one and why I use a Docker image. I decided to use &lt;a href="https://weasyprint.org/"&gt;WeasyPrint&lt;/a&gt; for PDF generation because it creates good-quality PDF files and works with HTML, the format &lt;a href="/blog/2018/08/26/mfgames-writing-themes/"&gt;themes&lt;/a&gt; use.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-shell"&gt;$ npm install @mfgames-writing/weasyprint
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This assumes that &lt;code&gt;weasyprint&lt;/code&gt; and &lt;code&gt;pdftk&lt;/code&gt; are both in the PATH.&lt;/p&gt;
&lt;h1&gt;MOBI&lt;/h1&gt;
&lt;p&gt;There isn't a good package for generating MOBI files directly, so the best approach to creating a Amazon MOBI file for uploading is to create a EPUB file and then use &lt;code&gt;kindlegen&lt;/code&gt; to convert it.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-shell"&gt;$ npm run build:epub
$ kindlegen *.epub
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;DOCX&lt;/h1&gt;
&lt;p&gt;Like MOBI, it is hard to write a DOCX in a clean manner. To do that, we create a HTML and then convert it.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-shell"&gt;$ npm run build:html
$ sed 's@&amp;amp;#173;@@g' &amp;lt; *.html \
  | pandoc -f html -t docx -o test-package-0.0.0.docx
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We have the extra &lt;code&gt;sed&lt;/code&gt; command to remove the hypenation from &lt;code&gt;@mfgames-writing/hyphen&lt;/code&gt; which makes a cleaner file.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Working with MfGames Writing, CI, and Docker</title>
    <link rel="alternate" href="https://d.moonfire.us/blog/2018/08/24/mfgames-writing-docker-and-ci/" />
    <updated>2018-08-24T05:00:00Z</updated>
    <id>https://d.moonfire.us/blog/2018/08/24/mfgames-writing-docker-and-ci/</id>
    <category term="programming" scheme="https://d.moonfire.us/categories/" label="Programming" />
    <category term="writing" scheme="https://d.moonfire.us/categories/" label="Writing" />
    <category term="docker" scheme="https://d.moonfire.us/tags/" label="Docker" />
    <category term="markdown" scheme="https://d.moonfire.us/tags/" label="Markdown" />
    <category term="mfgames-writing" scheme="https://d.moonfire.us/tags/" label="MfGames Writing" />
    <category term="gitlab" scheme="https://d.moonfire.us/tags/" label="Gitlab" />
    <summary type="html">How to use a continual integration (CI) server to publish projects.
</summary>
    <content type="html">&lt;p&gt;One of the main points of having &lt;a href="/tags/mfgames-writing/"&gt;MfGames Writing&lt;/a&gt; is to automate the publication process.&lt;/p&gt;
&lt;h1&gt;Series&lt;/h1&gt;
&lt;p&gt;I appear to be writing a short series of post about the tools I use for publication and writing.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/13/publishing-processes/"&gt;Semantic Versions and Releases&lt;/a&gt;: Why semantic versioning helps with the writing process.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/21/mfgames-writing-reasons/"&gt;Evolution of MfGames Writing&lt;/a&gt;: A brief history and reasoning behind the tools.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/22/mfgames-writing-init/"&gt;First Steps Using MfGames Writing&lt;/a&gt;: Starting a new project with MfGames Writing.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/23/mfgames-writing-content/"&gt;Adding Content to MfGames Writing&lt;/a&gt;: Adding front and back matter to novels.&lt;/li&gt;
&lt;li&gt;Working with MfGames Writing, CI, and Docker: Adding automatic building with commits.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/25/mfgames-writing-formats/"&gt;Additional Formats for MfGames Writing&lt;/a&gt;: How to create PDF, MOBI, DOCX, and HTML versions.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/26/mfgames-writing-themes/"&gt;Theming for MfGames Writing&lt;/a&gt;: A light introduction on how to customize the output.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/27/mfgames-writing-releases/"&gt;Integrating Semantic Versioning into MfGames Writing&lt;/a&gt;: Tying semantic releases into the process.&lt;/li&gt;
&lt;/ol&gt;
&lt;h1&gt;Adding Scripts&lt;/h1&gt;
&lt;p&gt;We've installed the commands in a previous step, but hooking them up in the &lt;code&gt;package.json&lt;/code&gt; makes life a lot easier.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-json"&gt;{
  &amp;quot;name&amp;quot;: &amp;quot;test-project&amp;quot;,
  &amp;quot;private&amp;quot;: true,
  &amp;quot;version&amp;quot;: &amp;quot;0.0.0&amp;quot;
  &amp;quot;scripts&amp;quot;: {
    &amp;quot;build:epub&amp;quot;: &amp;quot;mfgames-writing-format build epub&amp;quot;,
    &amp;quot;build:pdf&amp;quot;: &amp;quot;mfgames-writing-format build pdf&amp;quot;,
    &amp;quot;build:html&amp;quot;: &amp;quot;mfgames-writing-format build html&amp;quot;,
    &amp;quot;build:docx&amp;quot;: &amp;quot;sed 's@&amp;amp;#173;@@g' &amp;lt; $npm_package_name-$npm_package_version.html | pandoc -f html -t docx -o $npm_package_name-$npm_package_version.docx&amp;quot;,
    &amp;quot;build:mobi&amp;quot;: &amp;quot;kindlegen $npm_package_name-$npm_package_version.epub&amp;quot;,
    &amp;quot;build&amp;quot;: &amp;quot;npm run build:epub &amp;amp;&amp;amp; npm run build:mobi &amp;amp;&amp;amp; npm run build:pdf &amp;amp;&amp;amp; npm run build:html &amp;amp;&amp;amp; npm run build:docx&amp;quot;
  }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Basically this sets up my basic suite of scripts that let me generate everything or one specific file.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-shell"&gt;$ npm run build:epub
$ npm run build
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can see we use a couple other programs like &lt;code&gt;pandoc&lt;/code&gt; to make DOCX files from HTML or MOBI files using the EPUB file and &lt;code&gt;kindlegen&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;I use &lt;code&gt;$npm_package_name&lt;/code&gt; to pull in the package name (as I said, I use them for consistency) which lets me produce files with a consistent pattern including the version number.&lt;/p&gt;
&lt;p&gt;The other formats (HTML, PDF, etc) will be talked about in &lt;a href="/blog/2018/08/25/mfgames-writing-formats/"&gt;tomorrow's post&lt;/a&gt;.&lt;/p&gt;
&lt;h1&gt;CI Configuration&lt;/h1&gt;
&lt;p&gt;I use &lt;a href="https://gitlab.com/"&gt;GitLab&lt;/a&gt; as my primary development platform. I like the company, the fact they open-source much of their code, and their features. Most important is that they provide private repos, which means I can have one repo for every novel I work on.&lt;/p&gt;
&lt;p&gt;GitLab has a continual integration (CI) service which will automatically run whenever I push up code. This is controlled by the &lt;code&gt;.gitlab-ci.yml&lt;/code&gt; file.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-yaml"&gt;# This Docker image contains all the libraries and tools to generate files.
image: dmoonfire/mfgames-writing-js:1.1.1

stages:
    - publish

publish:
    stage: publish
    tags:
        - docker

    # Generate the various publication files.
    script:
        - npm ci
        - npm run build

    # Keeping artifacts means we can download them after the fact.
    artifacts:
        expire_in: 1 week
        paths:
            - &amp;quot;*.pdf&amp;quot;
            - &amp;quot;*.epub&amp;quot;
            - &amp;quot;*.mobi&amp;quot;
            - &amp;quot;*.docx&amp;quot;
            - &amp;quot;*.html&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If CI is turned on in GitLab and this file is present, then it will automatically run the commands in the &lt;code&gt;script&lt;/code&gt; section. It then takes the resulting PDF, EPUB, MOBI, DOCX, and HTML files and zips them up to be found on the website. Basically this runs the same command that you can run manually which makes it easier to test.&lt;/p&gt;
&lt;p&gt;&lt;a href="/blog/2018/08/mfgames-writing-download.png"&gt;&lt;img class="img-responsive post-img-link" src="/blog/2018/08/mfgames-writing-download.png" alt="Download Button" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;Docker&lt;/h1&gt;
&lt;p&gt;In the &lt;code&gt;.gitlab-ci.yml&lt;/code&gt; file, you may notice we use a Docker image &lt;code&gt;dmoonfire/mfgames-writing-js:1.1.1&lt;/code&gt;. This is up on &lt;a href="https://hub.docker.com/r/dmoonfire/mfgames-writing-js/"&gt;DockerHub&lt;/a&gt; and includes the various programs and utilities needed to generate the files. Some of the formats, in specific &lt;a href="https://weasyprint.org/"&gt;WeasyPrint&lt;/a&gt;, have specific installations and I found that having a Docker image makes life a lot easier.&lt;/p&gt;
&lt;p&gt;The image contains:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;NPM and required packages&lt;/li&gt;
&lt;li&gt;WeasyPrint&lt;/li&gt;
&lt;li&gt;KindleGen&lt;/li&gt;
&lt;li&gt;Pandoc&lt;/li&gt;
&lt;li&gt;PdfTk (pdfcat)&lt;/li&gt;
&lt;/ul&gt;
</content>
  </entry>
  <entry>
    <title>Adding Content to MfGames Writing</title>
    <link rel="alternate" href="https://d.moonfire.us/blog/2018/08/23/mfgames-writing-content/" />
    <updated>2018-08-23T05:00:00Z</updated>
    <id>https://d.moonfire.us/blog/2018/08/23/mfgames-writing-content/</id>
    <category term="programming" scheme="https://d.moonfire.us/categories/" label="Programming" />
    <category term="writing" scheme="https://d.moonfire.us/categories/" label="Writing" />
    <category term="markdown" scheme="https://d.moonfire.us/tags/" label="Markdown" />
    <category term="mfgames-writing" scheme="https://d.moonfire.us/tags/" label="MfGames Writing" />
    <summary type="html">Introduction on how to add different types of content to a MfGames Writing project.
</summary>
    <content type="html">&lt;p&gt;In my continuing introduction to &lt;a href="/tags/mfgames-writing/"&gt;MfGames Writing&lt;/a&gt;, I've only given a very brief introduction to adding content to the publication. Like everything else, there is a lot more complexity in the process to support various components of a novel: bastard and full titles, table of contents, appendixes, and even colophons.&lt;/p&gt;
&lt;h1&gt;Series&lt;/h1&gt;
&lt;p&gt;I appear to be writing a short series of post about the tools I use for publication and writing.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/13/publishing-processes/"&gt;Semantic Versions and Releases&lt;/a&gt;: Why semantic versioning helps with the writing process.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/21/mfgames-writing-reasons/"&gt;Evolution of MfGames Writing&lt;/a&gt;: A brief history and reasoning behind the tools.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/22/mfgames-writing-init/"&gt;First Steps Using MfGames Writing&lt;/a&gt;: Starting a new project with MfGames Writing.&lt;/li&gt;
&lt;li&gt;Adding Content to MfGames Writing: Adding front and back matter to novels.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/24/mfgames-writing-docker-and-ci/"&gt;Working with MfGames Writing, CI, and Docker&lt;/a&gt;: Adding automatic building with commits.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/25/mfgames-writing-formats/"&gt;Additional Formats for MfGames Writing&lt;/a&gt;: How to create PDF, MOBI, DOCX, and HTML versions.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/26/mfgames-writing-themes/"&gt;Theming for MfGames Writing&lt;/a&gt;: A light introduction on how to customize the output.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/27/mfgames-writing-releases/"&gt;Integrating Semantic Versioning into MfGames Writing&lt;/a&gt;: Tying semantic releases into the process.&lt;/li&gt;
&lt;/ol&gt;
&lt;h1&gt;More Than Chapters&lt;/h1&gt;
&lt;p&gt;In the &lt;a href="/blog/2018/08/22/mfgames-writing-init/"&gt;previous&lt;/a&gt; blog post, I gave a short example of &lt;code&gt;publication.yaml&lt;/code&gt; that included all the chapters in a folder.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-yaml"&gt;contents:
    - element: chapter
      number: 1
      directory: chapters
      source: /^chapter-\d+.md$/
      start: true
      page: 1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This would include any number of chapters, from &lt;code&gt;01&lt;/code&gt; to &lt;code&gt;99&lt;/code&gt;.&lt;/p&gt;
&lt;h1&gt;Covers&lt;/h1&gt;
&lt;p&gt;Most EPUB files need a good graphical image for readers. Creating MOBI (via &lt;code&gt;kindlegen&lt;/code&gt;) from the EPUB also requires a graphical image. Adding one is pretty easy.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-yaml"&gt;- element: cover
  source: build/repos/fedran-covers/dist/full/0100-00-sand-and-blood-front.jpg
  linear: false
  exclude:
      editions: [pdf]
      toc: true
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;element&lt;/code&gt; is the name of the component in the &lt;a href="/blog/2018/08/26/mfgames-writing-themes/"&gt;theme&lt;/a&gt;. Basically that determines how it is rendered when we generate the files.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;source&lt;/code&gt; is the relative path to the image. It should be a JPEG image. In my example, I have it pulling from another Git repository but it can be a file checked into the Git. In general, it needs to be a file that will be accessed while building.&lt;/p&gt;
&lt;p&gt;We use &lt;code&gt;linear: false&lt;/code&gt; because covers are one of those things that reader software will occasionally rearrange. In other words, I don't know, it seems to be required.&lt;/p&gt;
&lt;p&gt;We also use &lt;code&gt;exclude:&lt;/code&gt; to exclude it from the table of contents (&lt;code&gt;toc&lt;/code&gt;) and from the &lt;a href="/blog/2018/08/25/mfgames-writing-formats/"&gt;PDF version&lt;/a&gt;.&lt;/p&gt;
&lt;h1&gt;Titles&lt;/h1&gt;
&lt;pre&gt;&lt;code class="language-yaml"&gt;- element: bastard
  source: frontmatter/bastard.html
  linear: false
  exclude:
      editions: [epub]
      toc: true
- element: title
  source: frontmatter/title.html
  linear: false
  exclude:
      toc: true
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this case, we are using the &lt;code&gt;bastard&lt;/code&gt; and &lt;code&gt;title&lt;/code&gt; templates (nearly identical) from the theme. I put my front matter files in a directory creatively called &lt;code&gt;frontmatter&lt;/code&gt;. You can probably guess where the back matter goes. I could use a number in the front (like chapters) and a pattern but I like to be explicit with my matters.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;exclude.toc&lt;/code&gt; is because title pages don't show up in the table of contents.&lt;/p&gt;
&lt;h1&gt;Legal Page&lt;/h1&gt;
&lt;pre&gt;&lt;code class="language-yaml"&gt;- element: legal
  source: frontmatter/legal.markdown
  liquid: true
  linear: false
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The legal page introduces a new concept. The &lt;code&gt;liquid&lt;/code&gt; flag lets me use Liquid templates on the page. The variables available for the tags are combined from three places: the &lt;code&gt;package.json&lt;/code&gt; file, the &lt;code&gt;metadata&lt;/code&gt; section in &lt;code&gt;publication.yaml&lt;/code&gt;, and then the edition being generated from the same file. This means you can store variables like the version from &lt;code&gt;package.json&lt;/code&gt; but an ISBN from the edition.&lt;/p&gt;
&lt;p&gt;Since we are using Liquid, we can also have some simple logic such as the optional ISBN which only shows up in the &lt;code&gt;pdf&lt;/code&gt; edition. This would allow us to have two different versions of the book (say hardcover and paperback) with different formats and edition names.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-markdown"&gt;---
title: Legal
---

Broken Typewriter Press\
[https://broken.typewriter.press/](https://broken.typewriter.press/)

{% if edition.isbn %}
ISBN {{ edition.isbn }}
{% endif %}

Version {{ edition.version }}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Using versions like this could also be used to create site-specific buy links for the different editions (such as a Amazon or Smashwords-specific edition of the same file).&lt;/p&gt;
&lt;h1&gt;Table of Contents&lt;/h1&gt;
&lt;p&gt;The table of contents (&lt;code&gt;element: toc&lt;/code&gt;) has a special code to generate one if a source isn't given. However, the generated code doesn't do page numbers which is why I currently have it turned off in PDF. For EPUB and MOBI, it will generated a properly linked table for each chapter.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-yaml"&gt;- element: toc
  linear: false
  title: Contents
  exclude:
      editions: [pdf]
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;Pipelines&lt;/h1&gt;
&lt;p&gt;The last interesting component to point out is the pipelines. A pipeline is something that modifies the original Markdown before it is converted into HTML (I've needed a post conversion one also but I haven't coded it). These are used to handle word hyphenation (we don't do it by default), either for generic languages or for specific languages (such as the Fedran one to handle &lt;a href="https://fedran.com/miwafu/"&gt;Miwāfu&lt;/a&gt; names). There is also &lt;a href="https://www.npmjs.com/package/@mfgames-writing/guillemet"&gt;one&lt;/a&gt; to convert &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; into &lt;code&gt;«&lt;/code&gt; and &lt;code&gt;»&lt;/code&gt; (I use this for telepathy in my books).&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-yaml"&gt;- element: chapter
  number: 1
  directory: chapters
  source: /^chapter-\d+.markdown$/
  start: true
  page: 1
  pipeline: &amp;amp;pipelines
      - module: &amp;quot;@fedran/writing-hyphen&amp;quot;
      - module: mfgames-writing-hyphen
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;Sand and Blood example&lt;/h1&gt;
&lt;p&gt;Using &lt;a href="https://gitlab.com/fedran/sand-and-blood/blob/master/publication.yaml"&gt;Sand and Blood&lt;/a&gt; as an example:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-yaml"&gt;contents:
    - element: cover
      source: build/repos/fedran-covers/dist/full/0100-00-sand-and-blood-front.jpg
      linear: false
      exclude:
          editions: [pdf]
          toc: true
    - element: bastard
      source: frontmatter/bastard.html
      linear: false
      exclude:
          editions: [epub]
          toc: true
    - element: title
      source: frontmatter/title.html
      linear: false
      exclude:
          toc: true
    - element: legal
      source: frontmatter/legal.markdown
      liquid: true
      linear: false
    - element: dedication
      source: frontmatter/dedication.markdown
      linear: false
    - element: toc
      linear: false
      title: Contents
      exclude:
          editions: [pdf]
    - element: preface
      source: frontmatter/miwafu.html
      linear: false
    - element: chapter
      number: 1
      directory: chapters
      source: /^chapter-\d+.markdown$/
      start: true
      page: 1
      pipeline: &amp;amp;pipelines
          - module: &amp;quot;@fedran/writing-hyphen&amp;quot;
          - module: &amp;quot;@mfgames-writing/hyphen&amp;quot;
    - element: appendix
      source: backmatter/about.markdown
    - element: appendix
      source: backmatter/fedran.markdown
    - element: appendix
      id: license
      source: backmatter/license.markdown
    - element: appendix
      source: backmatter/patrons.markdown
    - element: appendix
      source: backmatter/credits.markdown
    - element: colophon
      source: backmatter/colophon.markdown
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;EPUBCHECK&lt;/h1&gt;
&lt;p&gt;Once you get the basics in (cover, table of contents, and chapters), the resulting EPUB file will easily get through &lt;code&gt;epubcheck&lt;/code&gt; which makes it easier to then convert that into a MOBI file using &lt;code&gt;kindlegen&lt;/code&gt;.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>First Steps Using MfGames Writing (GitLab, NPM)</title>
    <link rel="alternate" href="https://d.moonfire.us/blog/2018/08/22/mfgames-writing-init/" />
    <updated>2018-08-22T05:00:00Z</updated>
    <id>https://d.moonfire.us/blog/2018/08/22/mfgames-writing-init/</id>
    <category term="programming" scheme="https://d.moonfire.us/categories/" label="Programming" />
    <category term="writing" scheme="https://d.moonfire.us/categories/" label="Writing" />
    <category term="git" scheme="https://d.moonfire.us/tags/" label="Git" />
    <category term="gitlab" scheme="https://d.moonfire.us/tags/" label="GitLab" />
    <category term="markdown" scheme="https://d.moonfire.us/tags/" label="Markdown" />
    <category term="mfgames-writing" scheme="https://d.moonfire.us/tags/" label="MfGames Writing" />
    <summary type="html">The initial steps for setting up a new project for publication.
</summary>
    <content type="html">&lt;p&gt;Getting started with &lt;a href="/tags/mfgames-writing/"&gt;MfGames Writing&lt;/a&gt; can be a bit overwhelming. This is the beginning of how to get started. These directions are mainly focused toward technical users who already have a basic skill in Git.&lt;/p&gt;
&lt;h1&gt;Series&lt;/h1&gt;
&lt;p&gt;I appear to be writing a short series of post about the tools I use for publication and writing.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/13/publishing-processes/"&gt;Semantic Versions and Releases&lt;/a&gt;: Why semantic versioning helps with the writing process.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/21/mfgames-writing-reasons/"&gt;Evolution of MfGames Writing&lt;/a&gt;: A brief history and reasoning behind the tools.&lt;/li&gt;
&lt;li&gt;First Steps Using MfGames Writing: How to get started with a project.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/23/mfgames-writing-content/"&gt;Adding Content to MfGames Writing&lt;/a&gt;: Adding front and back matter to novels.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/24/mfgames-writing-docker-and-ci/"&gt;Working with MfGames Writing, CI, and Docker&lt;/a&gt;: Adding automatic building with commits.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/25/mfgames-writing-formats/"&gt;Additional Formats for MfGames Writing&lt;/a&gt;: How to create PDF, MOBI, DOCX, and HTML versions.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/26/mfgames-writing-themes/"&gt;Theming for MfGames Writing&lt;/a&gt;: A light introduction on how to customize the output.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/27/mfgames-writing-releases/"&gt;Integrating Semantic Versioning into MfGames Writing&lt;/a&gt;: Tying semantic releases into the process.&lt;/li&gt;
&lt;/ol&gt;
&lt;h1&gt;Setting up Git&lt;/h1&gt;
&lt;p&gt;I always start by creating a new Git project on &lt;a href="https://gitlab.com/"&gt;GitLab&lt;/a&gt;. You can do the same with GitHub, BitBucket, or just locally. Since I'm focusing on the tools, I'm going to assume you know how to create those projects.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-shell"&gt;$ git checkout https://oauth2:SecretPassword@gitlab.com/dmoonfire/test-project.git
... stuff happens
$ cd test-project
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You could create a new folder, it doens't really matter.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-shell"&gt;$ mkdir test-project
$ cd test-project
$ git init
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;Setting up .gitignore&lt;/h1&gt;
&lt;p&gt;The way builds work, there are quite a few files that will be generated that wouldn't be checked into the repository. This is one thing that makes NPM so powerful. To avoid that, we create a &lt;code&gt;.gitignore&lt;/code&gt; file that ignores those files.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Emacs and VI creates these files and I'm too lazy to turn it off.
*~
\#*
.#*

# This is the output of the various build processes.
*.pdf
*.mobi
*.epub
*.docx

# Sometimes I use `build` for my output but most of the time I just put it in the root.
build/

# This is where Node/NPM puts its file.
node_modules/
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;Setting up .editorconfig&lt;/h1&gt;
&lt;p&gt;&lt;a href="https://editorconfig.org/"&gt;EditorConfig&lt;/a&gt; is a tool for providing some consistency in formatting. For novels, it doesn't make sense but I like to have it there to make sure the supporting files are consistent. This is an optional file, I just like having it.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
charset = utf-8
end_of_line = lf
indent_brace_style = K&amp;amp;R
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 80
tab_width = 4
trim_trailing_whitespace = true
curly_bracket_next_line = false

[*.{js,ts}]
quote_type = double

[*.yaml]
indent_size = 2
tab_width = 2

[package.json]
indent_size = 2
tab_width = 2
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;Setting up package.json&lt;/h1&gt;
&lt;p&gt;The versioning and management comes from &lt;code&gt;package.json&lt;/code&gt;. This is the file that says &lt;em&gt;which&lt;/em&gt; version of which utilities to use. Now, you can use &lt;code&gt;npm init&lt;/code&gt; to figure it out but this is the basic file.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-json"&gt;{
    &amp;quot;name&amp;quot;: &amp;quot;test-project&amp;quot;,
    &amp;quot;private&amp;quot;: true,
    &amp;quot;version&amp;quot;: &amp;quot;0.0.0&amp;quot;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There is other stuff, but these are the key parts. The name is the &lt;em&gt;slug&lt;/em&gt; of the file. For me, it is always the name of the folder in the website and the Git repository. I also use this to build my website, so it is a pretty consistent format. You can call it whatever you want and change it as you need.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;private&lt;/code&gt; is to prevent you from accidently publishing your novel on &lt;a href="https://www.npmjs.com/"&gt;NPM&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Finally the &lt;code&gt;version&lt;/code&gt; is used for the &lt;a href="/blog/2018/08/13/publishing-processes/"&gt;semantic release&lt;/a&gt; and populates data on the legal page of the resulting book. In general, I start with &amp;ldquo;0.0.0&amp;rdquo; and then bump it to &amp;ldquo;1.0.0&amp;rdquo; when I finalize the book and publish it for the first time.&lt;/p&gt;
&lt;h1&gt;Write a Chapter&lt;/h1&gt;
&lt;p&gt;Now, we need somethig to put into the story or novel. Since I've started this, I organize even my short story into chapters. To do that, you can put it anywhere, but I always put my chapters in (unoriginally) the &lt;code&gt;chapters/&lt;/code&gt; folder. I also use two-digit numbers with zero padding so it sorts correctly (this is useful). You can see this at &lt;a href="https://gitlab.com/fedran/sand-and-blood/"&gt;Sand and Blood's Git Repository&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For example, &lt;code&gt;chapters/chapter-01.md&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-markdown"&gt;---
title: Mistakes Were Made
---

It was a bright and terribly sunny day.

I didn't like it.
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;Setting up publication.yaml&lt;/h1&gt;
&lt;p&gt;Because of the flexibility (if you don't want to use &lt;code&gt;chapters/&lt;/code&gt;, want to spread it out across deeper folders), nothing is automatic when it comes to formatting the books. To control it, we have a simple file called &lt;code&gt;publication.yaml&lt;/code&gt; which tells the system &lt;em&gt;how&lt;/em&gt; to create the output. This would go at the top-level file.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-yaml"&gt;metadata:
    title: Test Project
    author: D. Moonfire
    language: en

    theme: &amp;quot;@mfgames-writing/clean&amp;quot;
    outputDirectory: .
    outputFilename: test-project-{{edition.version}}.{{edition.editionName}}

editions:
    epub: # This is the edition.editionName.
        format: &amp;quot;@mfgames-writing/epub2&amp;quot;

contents:
    - element: chapter
      number: 1
      directory: chapters
      source: /^chapter-\d+.md$/
      start: true
      page: 1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, since this file is the core of MfGames Writing, it needs a bunch of details.&lt;/p&gt;
&lt;h2&gt;Liquid&lt;/h2&gt;
&lt;p&gt;Many of the fields use &lt;a href="https://shopify.github.io/liquid/"&gt;Liquid&lt;/a&gt; templates. That is the stuff between &lt;code&gt;{{&lt;/code&gt; and &lt;code&gt;}}&lt;/code&gt;. The main reason we use it is so we can simplify some of our logic. For example, instead of putting &lt;code&gt;outputFilename&lt;/code&gt; in every edition, we can use variables to fill it in. Also, we can substitute &lt;code&gt;{{ edition.version }}`` to have the version from the &lt;/code&gt;package.json&lt;code&gt;file. The&lt;/code&gt;{{edition.editionName}}&lt;code&gt;will have&lt;/code&gt;epub&lt;code&gt;for the&lt;/code&gt;epub:&lt;code&gt;line. This means it wil produce a file&lt;/code&gt;test-project-0.0.0.epub` when it runs.&lt;/p&gt;
&lt;h2&gt;Theme&lt;/h2&gt;
&lt;p&gt;The formatting is driven around the idea of a &amp;ldquo;theme&amp;rdquo;. Right now, there are only three themes. Two are private or require custom fonts, the other is &lt;a href="https://www.npmjs.com/package/@mfgames-writing/clean"&gt;@mfgames-writing/clean&lt;/a&gt; which is a utilitarian theme based on SASS and some templates. These themes are used to create a consistent style. I also have more specialized themes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.npmjs.com/package/@fedran/writing-theme/"&gt;Fedran&lt;/a&gt;: For the books and stories at &lt;a href="https://fedran.com/"&gt;https://fedran.com/&lt;/a&gt;. This also is used for my print books.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.npmjs.com/package/@typewriter-press/efferding-writing-theme"&gt;Efferding&lt;/a&gt;: For Randy Roeder's &lt;a href="https://typewriter.press/randy-roeder/sins-of-intent/"&gt;Sins of Intent&lt;/a&gt; and the sequel coming out next month.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Both of these have custom fonts (Corda and Mr. Eaves) with a bit of logic. I could easily see this being expanded by anyone to create a gallery of formatting for books. Right now, I'm focusing on these three because they are functional enough.&lt;/p&gt;
&lt;p&gt;See the later post on theme specifics.&lt;/p&gt;
&lt;h2&gt;Editions&lt;/h2&gt;
&lt;p&gt;Editions are basically versions of the output. For &lt;em&gt;Sand and Blood&lt;/em&gt;, I have one for EPUB, HTML, and PDF. MOBI and DOCX are generated from those three sources. You can have any number of editions, different file names, different output directories, even different variables like ISBN numbers.&lt;/p&gt;
&lt;h2&gt;Content&lt;/h2&gt;
&lt;p&gt;Content is what goes into the file. Right now, we only have a single element, all the files in the chapter folder.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-yaml"&gt;- element: chapter
  number: 1
  directory: chapters
  source: /^chapter-\d+.md$/
  start: true
  page: 1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;element&lt;/code&gt; tells the theme how to format it. Later examples will include more but you can have things like &lt;code&gt;preface&lt;/code&gt; or &lt;code&gt;appendix&lt;/code&gt; or titles and the like.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;number&lt;/code&gt; property basically is used if you want to have &amp;ldquo;Chapter 1&amp;rdquo; in the theme but with a custom title. If your chapter is just &amp;ldquo;One&amp;rdquo;, &amp;ldquo;Two&amp;rdquo;, &amp;ldquo;Three&amp;rdquo;, you wouldn't define this. My books do since I use chapter titles.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;directory&lt;/code&gt; and &lt;code&gt;source&lt;/code&gt; work together to figure out which files are to be included.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;start&lt;/code&gt; is used by EPUB and MOBI to figure out where to automatically navigate when the reader first goes into the page.&lt;/p&gt;
&lt;p&gt;Finally &lt;code&gt;page&lt;/code&gt; is used by the PDF system to restart page numbering. Usually this would be left blank.&lt;/p&gt;
&lt;h1&gt;Installing Tools&lt;/h1&gt;
&lt;p&gt;At this point, I have a minimum novel project. Time to make it actually produce something. Like in the &lt;a href="/blog/2018/08/21/mfgames-writing-reasons/"&gt;previous&lt;/a&gt;, everything is self-contained in the directory. We use &lt;code&gt;npm&lt;/code&gt; to install the packages needed to build the project.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-shell"&gt;$ npm install @mfgames-writing/format @mfgames-writing/clean @mfgames-writing/epub2
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;@mfgames-writing/format&lt;/code&gt; provides the command-line tools and does the work. There is also the &amp;ldquo;clean&amp;rdquo; theme and a third for the output (EPUB2).&lt;/p&gt;
&lt;p&gt;Once these install, running the output should work with the following command.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-shell"&gt;$ npx mfgames-writing-format build
... lots of colorful output
$ ls *.epub
test-project-0.0.0.epub
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If all goes well, you'll see &lt;code&gt;test-project-0.0.0.epub&lt;/code&gt; in the root directory. It won't pass &lt;code&gt;epubcheck&lt;/code&gt; check (we are missing a few things), but this is the basics of the publishing system.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>The Evolution of MfGames Writing</title>
    <link rel="alternate" href="https://d.moonfire.us/blog/2018/08/21/mfgames-writing-reasons/" />
    <updated>2018-08-21T05:00:00Z</updated>
    <id>https://d.moonfire.us/blog/2018/08/21/mfgames-writing-reasons/</id>
    <category term="programming" scheme="https://d.moonfire.us/categories/" label="Programming" />
    <category term="writing" scheme="https://d.moonfire.us/categories/" label="Writing" />
    <category term="markdown" scheme="https://d.moonfire.us/tags/" label="Markdown" />
    <category term="mfgames-writing" scheme="https://d.moonfire.us/tags/" label="MfGames Writing" />
    <summary type="html">A brief history and reasoning behind MfGames Writing.
</summary>
    <content type="html">&lt;p&gt;If I wrote the reasons and methods I got to this point, I haven't either &lt;a href="/tags/mfgames-writing/"&gt;tagged&lt;/a&gt; properly or never got around to writing it. Regardless, here is a very brief history of these tools and how they evolved up to this point. Hopefully it will explain &lt;em&gt;why&lt;/em&gt; I did certain things and which problems I was trying to solve.&lt;/p&gt;
&lt;h1&gt;Series&lt;/h1&gt;
&lt;p&gt;I appear to be writing a short series of post about the tools I use for publication and writing.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/13/publishing-processes/"&gt;Semantic Versions and Releases&lt;/a&gt;: Why semantic versioning helps with the writing process.&lt;/li&gt;
&lt;li&gt;Evolution of MfGames Writing: A brief history and reasoning behind the tools.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/22/mfgames-writing-init/"&gt;First Steps Using MfGames Writing&lt;/a&gt;: Starting a new project with MfGames Writing.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/23/mfgames-writing-content/"&gt;Adding Content to MfGames Writing&lt;/a&gt;: Adding front and back matter to novels.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/24/mfgames-writing-docker-and-ci/"&gt;Working with MfGames Writing, CI, and Docker&lt;/a&gt;: Adding automatic building with commits.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/25/mfgames-writing-formats/"&gt;Additional Formats for MfGames Writing&lt;/a&gt;: How to create PDF, MOBI, DOCX, and HTML versions.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/26/mfgames-writing-themes/"&gt;Theming for MfGames Writing&lt;/a&gt;: A light introduction on how to customize the output.&lt;/li&gt;
&lt;li&gt;&lt;a href="/blog/2018/08/27/mfgames-writing-releases/"&gt;Integrating Semantic Versioning into MfGames Writing&lt;/a&gt;: Tying semantic releases into the process.&lt;/li&gt;
&lt;/ol&gt;
&lt;h1&gt;Markdown and YAML&lt;/h1&gt;
&lt;p&gt;Let's start with the start of this: I write in Markdown. I've written a &lt;a href="/tags/markdown/"&gt;few posts&lt;/a&gt; about the process and reasons, so I won't go into those. If you want a short version: text files don't corrupt and source control means I can work across multiple machines without accidently deleting an entire chapter.&lt;/p&gt;
&lt;p&gt;The problem with Markdown is that most people don't want to read a text file. It has no formatting. It doesn't look pretty. It also doesn't go into books very well. Normally, to get around this, many authors use tools like Microsoft Word or &lt;a href="https://www.literatureandlatte.com/scrivener/overview"&gt;Scrivner&lt;/a&gt; (which I recommend to non-technical writers) which allow for writing a story/novel and then formatting it into something usable for readers. I don't use Scrivner myself because it uses binary files (doesn't play well with Git) and doesn't run nicely on Linux (my primary platform).&lt;/p&gt;
&lt;p&gt;Most people aren't burdened by these self-inflicted limitations.&lt;/p&gt;
&lt;p&gt;I also use YAML to keep track of useful information about the page.&lt;/p&gt;
&lt;h1&gt;Model-View-Controller as Applied to Writing&lt;/h1&gt;
&lt;p&gt;In development, there is the concept of the &lt;a href="https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller"&gt;Model-View-Controller&lt;/a&gt;. This consists of three parts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The model is the logic and data.&lt;/li&gt;
&lt;li&gt;The view renders/formats the model into something useful.&lt;/li&gt;
&lt;li&gt;The controller changes the model.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The nice thing is that when writing in Markdown, I don't worry about formatting. I have four basic things: bold, italic, blockquotes, and section breaks. I don't really need anything else because of my writing style. I also think this contributes to my productivity, if I can't play with it, I can't distract myself. This is basically the &lt;em&gt;model&lt;/em&gt; of my novel; the chunky bits in a text file that constitute the contents of the novel.&lt;/p&gt;
&lt;p&gt;The &lt;em&gt;view&lt;/em&gt; is what takes that Markdown + YAML file and generates something useful or pretty out of it. That can include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://fedran.com/sand-and-blood/chapter-01/"&gt;Online Reading&lt;/a&gt;: HTML pages for reading online&lt;/li&gt;
&lt;li&gt;&lt;a href="https://fedran.com/sand-and-blood/dmoonfire-100-00-sand-and-blood-3.1.0.pdf"&gt;PDF&lt;/a&gt;: PDF for print-ready output.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://fedran.com/sand-and-blood/dmoonfire-100-00-sand-and-blood-3.1.0.epub"&gt;EPUB&lt;/a&gt;: Ebook formats for those who like readers.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;em&gt;controller&lt;/em&gt; is what I write with the novel. I basically use &lt;a href="https://atom.io/"&gt;Atom&lt;/a&gt; or Notepad++. This is also where &lt;a href="/tags/author-intrusion/"&gt;Author Intrusion&lt;/a&gt; will fit into the process.&lt;/p&gt;
&lt;p&gt;The nice part about having the contents (the &lt;em&gt;model&lt;/em&gt;) and the output (the &lt;em&gt;view&lt;/em&gt;) is that they are completely separate in this step. If I decided to change the font of my books, I just update the view and reformat the books. All the words and everything will come over and I will just have a new appearance. The same if I want to change how epigraphs are formatted or want to support a new ebook format.&lt;/p&gt;
&lt;h1&gt;Automation&lt;/h1&gt;
&lt;p&gt;Having a separate view from the model also means I can &lt;em&gt;automate&lt;/em&gt; the process of formatting and typesetting the book. This is useful because it is a tedious job formatting the book. Yes, I don't do it that often but I also like consistency. So as my &amp;ldquo;style&amp;rdquo; evolves, I also find that I go back and tweak the previous versions for consistency. For example, I moved from a 2 cm lead on the chapter pages to a 4 cm because I thought it looked better. I also made the epigraph a little larger because I can read 8 pt font easily but not everyone else.&lt;/p&gt;
&lt;p&gt;Automation also takes out the little details that throw me. I know some books that start with &amp;ldquo;Chapter 1&amp;rdquo; and &amp;ldquo;Chapter 2&amp;rdquo;, but somewhere in the middle they switch to &amp;ldquo;Chapter Twenty-Two&amp;rdquo;. Or sometimes using typographical quotes and other time using ticks. These are things that will throw out a detail-oriented person (like me) but I also feel make an unprofessional looking book.&lt;/p&gt;
&lt;p&gt;These are things that Microsoft Word and Scrivner will do, some better than others. I want the same thing because my goal is to create as technically correct and beautiful book as I can possibly create.&lt;/p&gt;
&lt;p&gt;MfGames Writing sits in this place, to automate the formatting and handle all of the little details while giving me the ability to focus on one thing&amp;mdash;the words&amp;mdash;and let computers handle the rest.&lt;/p&gt;
&lt;h1&gt;Early Versions&lt;/h1&gt;
&lt;p&gt;When I started this epic quest of trying to automate formatting and typesetting, I started with a simple program: Make. It basically used a few tools in Linux to transform the Markdown into something usable. Shell scripts ended up not being enough, so I supplemented those with a combination of Perl, Python, and C# tools. Each language had its strengths and weaknesses (the biggest is how they handle Unicode since I use accents heavily).&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Where most people write a little game or card program with new languages, I write a publication system.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;At the time, those languages didn't have good support for installation. Both Perl and Python have a tendency to install packages for the entire machine or a user. C# didn't have NuGet at the time, so it was copying files around (plus it was always the weakest of the three implementations). This meant I could only have one version at a time, so I basically directed everything to my &lt;code&gt;/home/mfgames-writing/&lt;/code&gt; folder and used that.&lt;/p&gt;
&lt;p&gt;Which&amp;hellip; was good enough until I started changing my build process. I've been using this for about a hundred books and short stories now. The novels were the hardest because I would add features for fancy headers (like the PlayStation controller on top of &lt;a href="https://typewriter.press/shannon-ryan/fangs-for-nothing/"&gt;Fangs for Nothing&lt;/a&gt;) or epigraphs in my page. As I went along, the process got better.&lt;/p&gt;
&lt;p&gt;It also broke older versions. A template would change, or the flow. I started having to have &lt;code&gt;v1&lt;/code&gt;, &lt;code&gt;v2&lt;/code&gt;, and &lt;code&gt;v6&lt;/code&gt; hanging around because of the drastic changes as the tools got better at formatting and typesetting. Every time I would rewrite it, I would have slightly different input because of the language changes, and that would break older ones.&lt;/p&gt;
&lt;p&gt;That's when I realized I needed to be able to &amp;ldquo;pin&amp;rdquo; a version of the tools for a specific book.&lt;/p&gt;
&lt;p&gt;The latest attempt at C# was to take advantage of NuGet but then I realized the default NuGet implementation also created a machine-wide version.&lt;/p&gt;
&lt;p&gt;I'm aware there are virtual environments for Python. I didn't know about them at the time. After I've played with them, I still find them a bit cumbersome compared to using the approach I went with.&lt;/p&gt;
&lt;h1&gt;TypeScript and NPM&lt;/h1&gt;
&lt;p&gt;I finally figured it out when I started playing with TypeScript. I like learning new languages and I was looking for a replacement for my scripting language (I'm &lt;em&gt;very&lt;/em&gt; good at Perl and pretty good at Python). One of the tools with JavaScript based languages is &lt;a href="https://npmjs.com/"&gt;NPM&lt;/a&gt; which is the package management (much like NuGet).&lt;/p&gt;
&lt;p&gt;The beauty of NPM is that it is &lt;em&gt;self-contained&lt;/em&gt; inside the development projects. All of the required files go into &lt;code&gt;node_modules/&lt;/code&gt; which means that each project is a folder that contains everything it needs to run and build. This also means that different projects can have different versions of the same library.&lt;/p&gt;
&lt;p&gt;This ended up being the solution I went with. A self-contained, project-level packaging system that would let me evolve the tools for one version but still keep another novel at an earlier vesion so it doesn't break.&lt;/p&gt;
&lt;p&gt;Fast-forward about a year of coding and tooling and we get to where we are, MfGames Writing.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>State of writing with Markdown, YAML, and Git 2017</title>
    <link rel="alternate" href="https://d.moonfire.us/blog/2017/05/24/git-and-writing/" />
    <updated>2017-05-24T05:00:00Z</updated>
    <id>https://d.moonfire.us/blog/2017/05/24/git-and-writing/</id>
    <category term="programming" scheme="https://d.moonfire.us/categories/" label="Programming" />
    <category term="writing" scheme="https://d.moonfire.us/categories/" label="Writing" />
    <category term="markdown" scheme="https://d.moonfire.us/tags/" label="Markdown" />
    <category term="wiscon" scheme="https://d.moonfire.us/tags/" label="Wiscon" />
    <category term="gitlab" scheme="https://d.moonfire.us/tags/" label="Gitlab" />
    <summary type="html">A year ago, at one of my more successful panels at [WisCon](http://wiscon.info/), I was on a panel with [K. Tempest Bradford](https://tempest.fluidartist.com/find-a-tempest-wiscon-40/) and [Kristine Smith](http://www.kristine-smith.com/index.php/2016/05/home-5/) talking about writing processes. I got to see a lot of cool gadgets but I also got a chance to talk about my processes of writing with Markdown, YAML, and Git.</summary>
    <content type="html">&lt;p&gt;A year ago, at one of my more successful panels at &lt;a href="http://wiscon.info/"&gt;WisCon&lt;/a&gt;, I was on a panel with &lt;a href="https://tempest.fluidartist.com/find-a-tempest-wiscon-40/"&gt;K. Tempest Bradford&lt;/a&gt; and &lt;a href="http://www.kristine-smith.com/index.php/2016/05/home-5/"&gt;Kristine Smith&lt;/a&gt; talking about writing processes. I got to see a lot of cool gadgets but I also got a chance to talk about my processes of writing with Markdown, YAML, and Git.&lt;/p&gt;
&lt;p&gt;I'm not going to WisCon this year, but I thought this would be a good opportunity to write up where I am using all those technologies to write, both for my personal projects and as a &lt;a href="https://broken.typewriter.press/"&gt;publisher&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This is a long post in a single part. If you've read my blog, there is some rehashed information.&lt;/p&gt;
&lt;h1&gt;Markdown and YAML&lt;/h1&gt;
&lt;p&gt;Probably the one part that hasn't changed is my use of &lt;a href="https://daringfireball.net/projects/markdown/"&gt;Markdown&lt;/a&gt; and &lt;a href="http://yaml.org/"&gt;YAML&lt;/a&gt;. I originally used Creole with a makeshift header but after playing with &lt;a href="https://jekyllrb.com/"&gt;Jekyll&lt;/a&gt; for a while, I jumped whole-heartedly on Markdown with a YAML header.&lt;/p&gt;
&lt;p&gt;Below is an example of one of the files. I'll be referencing it a bit in this post so please forgive the length.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;---
availability: public
when: 1471/3/28 MTR
duration: 25 gm
date: 2012-02-18
title: Rutejìmo
locations:
  primary:
    - Shimusogo Valley
characters:
  primary:
    - Shimusogo Rutejìmo
  secondary:
    - Shimusogo Hyonèku
  referenced:
    - Funikogo Ganósho
    - Shimusogo Gemènyo
    - Shimusogo Chimípu
    - Shimusogo Yutsupazéso
concepts:
  referenced:
    - The Wait in the Valleys
purpose:
  - Introduce Rutejìmo
  - Introduce Hyonèku
  - Introduce naming conventions
  - Introduce formality rules
  - Introduce the basic rules of politeness
summary: &amp;gt;
  Rutejìmo was on top of the clan's shrine roof trying to sneak in and steal his grandfather's ashes. It was a teenage game, but also one to prove that he was capable of becoming an adult. He ended up falling off the roof.

  The shrine guard, Hyonèku, caught him before he hurt himself. After a few humiliating comments, he gave Rutejìmo a choice: tell the clan elder or tell his grandmother. Neither choice was good, but Rutejìmo decided to tell his grandmother.
---

&amp;gt; When a child is waiting to become an adult, they are subtly encouraged to prove themselves ready for the rites of passage. In public, however, they are to remain patient and respectful. --- Funikogo Ganóshyo, *The Wait in the Valleys*

Rutejìmo's heart slammed against his ribs as he held himself still. The cool desert wind blew across his face, teasing his short, dark hair. In the night, his brown skin was lost to the shadows, but he would be exposed if anyone shone a lantern toward the top of the small building. Fortunately, the shrine house was at the southern end of the Shimusogo Valley, the clan's ancestral home, and very few of the clan went there except for meetings and prayers.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I seem to be moving from the &lt;code&gt;.markdown&lt;/code&gt; to &lt;code&gt;.md&lt;/code&gt; extension. It's minor but I haven't quite jumped on it; I've only done it for the last two new projects.&lt;/p&gt;
&lt;h1&gt;Atom&lt;/h1&gt;
&lt;p&gt;My current editor of choice for novels is &lt;a href="https://atom.io/"&gt;Atom&lt;/a&gt; with a backup of Emacs. Unlike Emacs, Atom has standard keyboards and looks good with the fonts I use. It is a little slow, but for the most part, works pretty well for belting out words.&lt;/p&gt;
&lt;p&gt;I'm writing some extensions for it including a modified spell check (&lt;code&gt;project-spell&lt;/code&gt;) that can handle project-specific dictionaries (&lt;code&gt;language.json&lt;/code&gt;). This lets me tell the spell-checker not to mark character names as misspelled.&lt;/p&gt;
&lt;p&gt;Later, I'll integrate my work into Author Intrusion with this but that isn't nearly ready for prime time even for my purposes.&lt;/p&gt;
&lt;h1&gt;Metadata&lt;/h1&gt;
&lt;p&gt;Over the last year I noticed I am putting lot more information in the header than before. Some of it is done long after the project but even while writing, I'll put in notes about the characters, the reason I'm writing the chapter, time of day, even the outline which I remove as I write.&lt;/p&gt;
&lt;p&gt;I just redid the &lt;a href="https://fedran.com/"&gt;Fedran&lt;/a&gt; website, otherwise I'd show you how the &lt;code&gt;characters&lt;/code&gt; and related fields show up in the sidebar. I'll get that worked in the next few months, but it let me cross-link things into my wiki. Having it in the header also means I can query it to get a summary of the page using a TypeScript tool I wrote called &lt;a href="https://www.npmjs.com/package/markdowny"&gt;markdowny&lt;/a&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-shell"&gt;$ markdowny table *.markdown -f _basename title when
| _basename           | title                   | when          |
| :------------------ | :---------------------- | :------------ |
| chapter-01.markdown | Rutejìmo                | 1471/3/28 MTR |
| chapter-02.markdown | Confession              | 1471/3/28 MTR |
| chapter-03.markdown | Morning                 | 1471/3/29 MTR |
| chapter-04.markdown | Rivals                  | 1471/3/29 MTR |
| chapter-05.markdown | Decisions               | 1471/3/29 MTR |
$
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Another nice thing about &lt;code&gt;markdowny&lt;/code&gt; is that it also lets me show those YAML lists in a useful manner.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-shell"&gt;$ markdowny table -f _basename characters.secondary
| _basename           | characters.secondary
| :------------------ | :-------------------------------------------------
| chapter-01.markdown | Hyonèku
| chapter-02.markdown | Somiryòki, Tejíko, Gemènyo
| chapter-03.markdown | Desòchu, Gemènyo, Hyonèku, Mapábyo, Opōgyo, Panédo
| chapter-04.markdown | Desòchu, Karawàbi, Tsubàyo
$
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I also has writing synopsis at the end, so what I can do is put each individual chapter in its header (in my case &lt;code&gt;summary&lt;/code&gt;) and then use &lt;code&gt;markdowny&lt;/code&gt; to pull them out. That way, I can write the synopsis as I go and not be overwhelemed at the end.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-shell"&gt;$ markdowny sections *.markdown | head -n 5
# Rutejìmo

Rutejìmo was on top of the clan's shrine roof trying to sneak in and steal his grandfather's ashes. It was a teenage game, but also one to prove that he was capable of becoming an adult. He ended up falling off the roof.

The shrine guard, Hyonèku, caught him before he hurt himself. After a few humiliating comments, he gave Rutejìmo a choice: tell the clan elder or tell his grandmother. Neither choice was good, but Rutejìmo decided to tell his grandmother.
$
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The final bit is word counting. Because of the YAML metadata, I can't get good word counts using most tools becaues the header skews the number. So I use the tool to get me counts of the content minus the YAML header.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-shell"&gt;$ markdowny count *.markdown
chapter-01.markdown:   1520
chapter-02.markdown:   2144
chapter-03.markdown:   2905
chapter-04.markdown:   1173
chapter-05.markdown:   2570
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I also have an alias for &lt;code&gt;mdwc&lt;/code&gt; to the count since I use it pretty heavily.&lt;/p&gt;
&lt;h1&gt;Directory Structure&lt;/h1&gt;
&lt;p&gt;I'm leaning toward a semi-standard layout for my projects. Some of this was built up over the last few years but even my short stories have been migrating over to it.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;root&gt;
  * `README.md` contains a summary of the project and my tasks list.
  * `chapters/` contains all the chapters in `chapter-01.md`. I have never had a project with more than 89 chapters, so I stick with two digit zero pad so it remains alphabetical.
  * `frontmatter/` contains the frontmatter (dedication, legal) files.
  * `backmatter/` contains the backmatter (colophon, about, also by).
  * `characters/` has one Markdown file per character, for future use with [Author Intrusion](/tags/author-intrusion/).
  * `covers/v1`: The first variant of the cover. I have a couple and each one goes into a different `vX` folder so I can keep them apart.
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Even with short stories, I have a &lt;code&gt;chapters/&lt;/code&gt; folder. I'm just picking up a &amp;ldquo;muscle memory&amp;rdquo; of going into chapters. I consider switching to putting things into a &lt;code&gt;src/&lt;/code&gt; like most of my programming projects I just haven't because I couldn't see the advantage other than having a neat folder.&lt;/p&gt;
&lt;h1&gt;Renumbering&lt;/h1&gt;
&lt;p&gt;One drawback of having &lt;code&gt;chapter-01.md&lt;/code&gt;, &lt;code&gt;chapter-02.md&lt;/code&gt;, etc is when I have to add a new chapter. I wrote a &lt;code&gt;renumber&lt;/code&gt; script that lets me inject a chapter.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-shell"&gt;$ ls -l
total 8
-rw-r--r-- 1 dmoonfire dmoonfire  22 May 24 08:06 chapter-01.md
-rw-r--r-- 1 dmoonfire dmoonfire 127 May 24 08:06 chapter-02.md
$ touch chapter-01a.md
$ renumber *.md
$ ls -l
total 8
-rw-r--r-- 1 dmoonfire dmoonfire   0 May 24 08:07 chapter-01.md
-rw-r--r-- 1 dmoonfire dmoonfire  22 May 24 08:06 chapter-02.md
-rw-r--r-- 1 dmoonfire dmoonfire 127 May 24 08:06 chapter-03.md
$
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, using &lt;code&gt;01a&lt;/code&gt; puts it before the first chapter. It works the same with deleting chapters. Sadly, this script isn't very clean but eventually I'll merge it into &lt;code&gt;markdowny&lt;/code&gt;.&lt;/p&gt;
&lt;h1&gt;Git&lt;/h1&gt;
&lt;p&gt;One of the biggest advantages of using Markdown (text files in general) is how well is plays with source control, Git in specific. I can't stress how much Git has helped me over the years. I still remember accidentally losing a chapter because I copied the wrong file in the wrong direction. Or the painful way of tracking versions (&lt;code&gt;chapter-01a.doc&lt;/code&gt;, &lt;code&gt;chapter01b.doc&lt;/code&gt;, &lt;code&gt;chapter-01b-final.doc&lt;/code&gt;, etc.).&lt;/p&gt;
&lt;p&gt;At one point, I had a single master repository which all completed pieces in the &lt;code&gt;master&lt;/code&gt; branch and branches off that for the works-in-progress. That actually worked out pretty well&amp;hellip; until I started publishing. While working with text is great, the binary files of working through the covers ended up creating huge repositories which took forever to clone.&lt;/p&gt;
&lt;p&gt;Last year, I hadn't quite split apart all of my repositories but that's pretty much done now. This also meant I can give access to editors and others to a single novel without exposing the other ones. I don't have to worry about Git modules or jumping through hoops to have the binaries.&lt;/p&gt;
&lt;p&gt;I tried LFS (large file system) for a while but then dropped it. With it not baked in, it was a little difficult to coordinate with continuous integration servers. I think in another year or so, it could work out fairly well. I also suspect it has to do with my comfort with LFS more than technical issues.&lt;/p&gt;
&lt;h1&gt;Gitlab&lt;/h1&gt;
&lt;p&gt;Related to LFS is where I'm hosting Git. A year ago, I used Git over SSH with my ISP. However, &lt;a href="https://gitlab.com/"&gt;Gitlab&lt;/a&gt; has been fantastic, both as their hosted environment and also on an instance running on Dreamhost (my provider). There are a lot of reasons to use Gitlab as a writer (and a publisher).&lt;/p&gt;
&lt;p&gt;Probably the biggest is private repositories. Even if I didn't how it on my own site, being able to make each of the novels private is &lt;em&gt;fantastic&lt;/em&gt;. Github, which is only slightly slicker, doesn't allow private repositories. Even if they did, I have over a hundred projects when you count works-in-progress, completed novels, and websites. Hosting that on Github would be expensive.&lt;/p&gt;
&lt;p&gt;I also have a Gitlab instance. The &lt;a href="https://broken.typewriter.press/"&gt;Broken Typewriter Press&lt;/a&gt; business and my private novels on there. This gives me full control over the site (though I trust Gitlab) and I like it. The only people on the site are me, authors, and editors.&lt;/p&gt;
&lt;p&gt;Like Github, Gitlab has some pretty nice features. When publishing the last few books, we've used the issue tab for authors to ask for me to order books or make corrections to their book. I can give them access to make their own typo corrections, which reduces the amount of work. At the same time, because of Git, I can be doing other changes and I don't have to worry about losing or screwing up their work. For the latest book, &lt;em&gt;Sins of Intent&lt;/em&gt;, the author did a fantastic job of using the features.&lt;/p&gt;
&lt;p&gt;I use the milestones for the various tasks of publishing a book. That way I can set up milestones for when the book has to be done, when the release it done, and various conventions. The issues are assigned to the milestones for both the author and myself and we can track what is missing or remaining to do. In effect, we can use a public project management to handle a book's release.&lt;/p&gt;
&lt;p&gt;I normally turn off wiki and snippets though, they usually don't help.&lt;/p&gt;
&lt;p&gt;One of the things with using Gitlab this way is that the author has full access to the raw files. Typically, I get a Word document and break it into individual Markdown files. Corrections are done against the Markdown as my baseline format for everything else. If they want to leave BTP or something catastropic happens, they can have exactly what I published. This is because I've been through cases where local edits were made but I couldn't get them back myself. In this case, they get and can see everything I do.&lt;/p&gt;
&lt;p&gt;Which leads to the last feature of Gitlab which I use heavily, their Continious Integration service. This was difficult to set up at first, mainly because I had to educate myself. For most novels, the &lt;code&gt;.gitlab-ci.yml&lt;/code&gt; looks like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;image: dmoonfire/mfgames-writing-js:0.4.0

stages:
    - review
    - publish

review:
    stage: review
    only:
        - master
    tags:
        - docker
    script:
        - git lfs pull # Yeah, I'm using LFS with this project.
        - npm install
        - npm run build
    artifacts:
        expire_in: 1 week
        paths:
            - &amp;quot;*.pdf&amp;quot;
            - &amp;quot;*.epub&amp;quot;
            - &amp;quot;*.mobi&amp;quot;

publish:
    stage: publish
    script: &amp;quot;echo published&amp;quot;
    when: manual
    artifacts:
        paths:
            - &amp;quot;*.pdf&amp;quot;
            - &amp;quot;*.epub&amp;quot;
            - &amp;quot;*.mobi&amp;quot;
    dependencies:
        - review
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Every time I check in, this rebuilds the project. For the little changes, the &amp;ldquo;staging&amp;rdquo; lets me and authors test the results of the file which show up underneath the build. They expire after a week but that's okay. &amp;ldquo;Releases&amp;rdquo; are done by moving a task to &amp;ldquo;publish&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;The nice part is I can grab the resulting PDF, MOBI, and PDF about 5-10 minutes after I check in. This is good to ensure that not only I have a reproducible build and also that I won't lost the ability to recover the output if my laptop catches on fire (it is almost seven years old, four majors cracks, and has a hernia).&lt;/p&gt;
&lt;p&gt;This ability to see the final version is great because me or another author can make changes and see it, test it, and make sure it is exactly what they want. If I change formatting, I can see the results without overloading my computer.&lt;/p&gt;
&lt;h1&gt;mfgames-writing-js&lt;/h1&gt;
&lt;p&gt;Of course, using CI requires some way of actually formatting the books. Markdown is fantastic for some things but there are relatively few tools to format it into good-looking EPUB, MOBI, and PDF files.&lt;/p&gt;
&lt;p&gt;Over the years, I have &lt;em&gt;many&lt;/em&gt; variants of this. The original few were based on Makefiles and various Python or Perl tools. I've also integrated &lt;a href="http://pandoc.org/"&gt;pandoc&lt;/a&gt; into the mix. Nothing ever worked &lt;em&gt;quite&lt;/em&gt; the way I wanted for what I considered to be a &amp;ldquo;proper&amp;rdquo; book. Files were put in the wrong place, dedications don't need titles, making sure chapters start on the right. There were little things that pushed me closer to making something more specific.&lt;/p&gt;
&lt;p&gt;I also had a problem that extending the features for a later book broke the generation of older books. I had to start over or rebuild (usually copy/paste/edit). Now this is a problem that has been addressed by NuGet and NPM, having the build process inside the project instead of using shared programs and libraries.&lt;/p&gt;
&lt;p&gt;Between this and using Gitlab CI runner, I decided to create a new framework that specifically was geared toward having specific versions that could be used to reproduce the book even if the underlying libraries were updated. I ended up using NPM, mainly because I'm learning TypeScript for the last few months. It also had a better story for installing (&lt;code&gt;npm install&lt;/code&gt;), wasn't whitespace-based, and specifically designed to be isolated to the project.&lt;/p&gt;
&lt;p&gt;The result is &lt;a href="https://gitlab.com/mfgames-writing-js"&gt;mfgames-writing-js&lt;/a&gt;, a framework for creating EPUB and PDF files from Markdown files. This entire thing is controlled by a single file checked into the Git repository.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;editions:
    epub:
        format:             mfgames-writing-epub
        theme:              ./lib/efferding
        outputDirectory:    .
        outputFilename:     sins-of-intent-{{edition.version}}.epub

    pdf:
        format:             mfgames-writing-weasyprint
        theme:              ./lib/efferding
        outputDirectory:    .
        outputFilename:     sins-of-intent-{{edition.version}}.pdf
        isbn:               978-1-940509-24-2

metadata:
    title:      Sins of Intent
    series:     Cletus Efferding
    author:     Randy Roeder
    language:   en

contents:
    - element: cover
      source: covers/v2/front.jpg
      linear: false
      exclude:
        editions: [pdf]
        toc: true
    - element: bastard
      source: frontmatter/bastard.html
      linear: false
      exclude:
        toc: true
    - element: title
      source: frontmatter/title.html
      linear: false
      exclude:
        toc: true
    - element: legal
      source: frontmatter/legal.md
      liquid: true
      linear: false
      exclude:
        toc: true
    - element: dedication
      source: frontmatter/dedication.md
      linear: false
      exclude:
        toc: true
    - element: toc
      linear: false
      exclude:
        editions: [pdf]
    - element: chapter
      number: 1
      directory: chapters
      source: /^chapter-\d+.md$/
      start: true
      page: 1
      pipeline: &amp;amp;pipelines
          - module: mfgames-writing-hyphen
            exceptions:
                # https://www.hyphenation24.com/word/driving/ says &amp;quot;driv-ing&amp;quot;
                - driving
                - drive
    - element: acknowledgement
      source: backmatter/acknowledgments.md
      pipeline: *pipelines
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This actually has turned out better than I expected. Yeah, I had trouble with using WeasyPrint for PDF generation, but it has almost all the features I needed to do right-side chapter openings, first page headers differently, and stitching everything into a single PDF with properly embedded fonts.&lt;/p&gt;
&lt;p&gt;The one thing I &lt;em&gt;can't&lt;/em&gt; do is create Smashword's Microsoft Word. I'm still trying to decide if it is worth it.&lt;/p&gt;
&lt;h1&gt;Website&lt;/h1&gt;
&lt;p&gt;I also release chapters every week. I used to use WordPress but it got cumbersome to add new chapters so I switched to a static site generator over the years. I started with DocPad, then Jekyll, and then extended Jekyll with Python and Perl programs to handle my requirements.&lt;/p&gt;
&lt;p&gt;Well&amp;hellip; I decided to write my own. This uses the same input files as the rest of my system (Markdown + YAML). It also lets me change a header to release the chapter and include it into the build.&lt;/p&gt;
&lt;p&gt;One of the complexities I had to figure out is the different repository for each novel. In the building process, I actually clone every project I'm publishing or have published, then use scripts to pull them into a single website before generating it. Jekyll couldn't handle it easily which is one reason I created my own.&lt;/p&gt;
&lt;p&gt;The tool for making the website is &lt;a href="https://gitlab.com/cobblestone-js/"&gt;CobblestoneJS&lt;/a&gt; but it has no documentation and I'm still fumbling through it. On the other hand, it handles the ten or so repositories needed to build &lt;a href="https://fedran.com/"&gt;fedran.com&lt;/a&gt; without my conlang, world data, and individual novels.&lt;/p&gt;
&lt;p&gt;As part of the weekly release, I've gotten the tasks down to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Update a header in the YAML (or use the scheduler to do it once)&lt;/li&gt;
&lt;li&gt;Write a blog post about the chapter&lt;/li&gt;
&lt;li&gt;Copy the chapter and the post over to &lt;a href="https://ello.co/dmoonfire/"&gt;Ello&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Copy the chapter from fedran.com to Wattpad&lt;/li&gt;
&lt;li&gt;Copy the post over to Patreon&lt;/li&gt;
&lt;li&gt;Run the diaspora sync post&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It takes about 1-2 hours which is much shorter than the 4 is used to be.&lt;/p&gt;
&lt;h1&gt;Summary&lt;/h1&gt;
&lt;p&gt;Well, there it is, my current state of writing with Git. You have everything from writing the chapters, supplying metadata, how to store it, various tools for getting through the publication process, and even formatting it for the various vendors.&lt;/p&gt;
&lt;p&gt;I've gotten lost trying to automate and simplify a lot of this, but I think the current state is mostly usable by others and has been pretty solid for my own needs. I'm sure I'll improve and expand on it.&lt;/p&gt;
&lt;p&gt;If you have question or comments, please ask. I love talking about processes, looking for improvements, or explaining in more detail why I do these things.&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Writing with Markdown and YAML</title>
    <link rel="alternate" href="https://d.moonfire.us/blog/2016/10/31/writing-with-markdown/" />
    <updated>2016-10-31T05:00:00Z</updated>
    <id>https://d.moonfire.us/blog/2016/10/31/writing-with-markdown/</id>
    <category term="writing" scheme="https://d.moonfire.us/categories/" label="Writing" />
    <category term="programming" scheme="https://d.moonfire.us/categories/" label="Programming" />
    <category term="markdown" scheme="https://d.moonfire.us/tags/" label="Markdown" />
    <category term="markdowny" scheme="https://d.moonfire.us/tags/" label="markdowny" />
    <category term="sand-and-blood" scheme="https://d.moonfire.us/tags/" label="Sand and Blood" />
    <category term="yaml" scheme="https://d.moonfire.us/tags/" label="YAML" />
    <summary type="html">I realized that it's been a while since I wrote up how I write with Markdown and YAML. This is the current state of my technique of writing.</summary>
    <content type="html">&lt;p&gt;Four years ago, I wrote a &lt;a href="https://www.reddit.com/r/writing/comments/un2x9/how_plain_text_editors_became_my_writing_tool_of/"&gt;Reddit post&lt;/a&gt; about why I switched to pure text files instead of using Microsoft Word, Libreoffice, or even Google Docs. The short answer is: text is forever and it is &lt;em&gt;really&lt;/em&gt; hard to corrupt a text document.&lt;/p&gt;
&lt;p&gt;There was a secondary reason for using text format and that was because I like keeping track of metadata while I write. A lot of authors do, actually, but I didn't care for the more common methods of keeping a spreadsheet in sync with the writing or getting &lt;a href="https://www.literatureandlatte.com/scrivener.php"&gt;Scrivner&lt;/a&gt; to behave. At the time, it wasn't so great, from what I've seen, a lot of what I do here can also be done in that program. That said, I still don't use it because of their file format doesn't play well with Git (I wrote a &lt;a href="/blog/2015/05/09/gitlab-projects/"&gt;post about that&lt;/a&gt; last year).&lt;/p&gt;
&lt;p&gt;Now, I have been doing this for a while. However, last year, someone at WisCon asked me about it and I &lt;em&gt;thought&lt;/em&gt; I made the post but apparently I didn't. Today, someone asked me the same question (&amp;quot;how do you use Markdown and YAML to write?&amp;quot;) and I went to point them to my article I didn't write last year and realized that I didn't write it.&lt;/p&gt;
&lt;p&gt;So&amp;hellip; here it is.&lt;/p&gt;
&lt;h1&gt;Format&lt;/h1&gt;
&lt;p&gt;When I write, the basic file looks like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;---
title: Rutejìmo
---

&amp;gt; When a child is waiting to become an adult, they are subtly encouraged
&amp;gt; to prove themselves ready for the rites of passage. In public, however,
&amp;gt; they are to remain patient and respectful. --- Funikogo Ganósho, *The
&amp;gt; Wait in the Valleys*

Rutejìmo's heart slammed against his ribs as he held himself still. The
cool desert wind blew across his face, teasing his short, dark hair. In the
night, his brown skin was lost to the shadows, but he would be exposed if
anyone shone a lantern toward the top of the small building. Fortunately,
the shrine house was at the southern end of the Shimusogo Valley, the
clan's ancestral home, and very few of the clan went there except for
meetings and prayers.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;&amp;gt;&lt;/code&gt; is a block quote which I use for my epigraphs. There is a quote at the beginning of every chapter for world building. Everything after that is &lt;a href="https://daringfireball.net/projects/markdown/"&gt;Markdown&lt;/a&gt;. I use &lt;code&gt;*italics*&lt;/code&gt; and &lt;code&gt;**bold**&lt;/code&gt; but otherwise not a lot.&lt;/p&gt;
&lt;h1&gt;Front Matter&lt;/h1&gt;
&lt;p&gt;The really important part is the &lt;a href="http://yaml.org/"&gt;YAML&lt;/a&gt; front matter. I picked YAML because it was really easy to read and change. It also parsed very well by computers. The only thing I don't like is that it doesn't like tabs&amp;hellip; but can't be perfect.&lt;/p&gt;
&lt;p&gt;There is a lot more in this header than I showed above. For the first chapter of &lt;a href="https://fedran.com/sand-and-blood/"&gt;Sand and Blood&lt;/a&gt;, the front matter looks like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;---
availability: public
when: 1471/3/28 MTR
duration: 25 gm
title: Rutejìmo
locations:
  primary:
    - Shimusogo Valley
characters:
  primary:
    - Shimusogo Rutejìmo
  secondary:
    - Shimusogo Hyonèku
purpose:
  - Introduce Rutejìmo
  - Introduce Hyonèku
  - Introduce naming conventions
  - Introduce formality rules
summary: &amp;gt;
  Rutejìmo was on top of the clan's shrine roof trying to sneak in and
  steal his grandfather's ashes. It was a teenage game, but also one to
  prove that he was capable of becoming an adult. He ended up falling off
  the roof.

  The shrine guard, Hyonèku, caught him before he hurt himself. After a
  few humiliating comments, he gave Rutejìmo a choice: tell the clan elder
  or tell his grandmother. Neither choice was good, but Rutejìmo decided to
  tell his grandmother.
---
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you might be able to tell, I keep a fair amount of information in the top of my files. This basically contains references to characters, locations, why the chapter exists. I could also put tone (action scene, introspection), scene types (scene or sequel), or anything else I want.&lt;/p&gt;
&lt;p&gt;The nice reason for this is when I rename or arrange the file, the header goes with it. If I need to list all chapters that have a character references, I can with a simple &amp;ldquo;find in files&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;I also have it tied into a future plan of creating a master book that has every novel I have with the chapters interspersed so the entire world is chronological. I think it will be cool once I start overlapping these stories. I also plan on having locations so I can show them on the map, if I ever write it down.&lt;/p&gt;
&lt;h1&gt;Tools&lt;/h1&gt;
&lt;p&gt;Now, &amp;ldquo;find in files&amp;rdquo; can only go so far. Over the years, I've written a number of tools to help me work with these type of files. I've tried it out in &lt;a href="https://github.com/dmoonfire/mfgames-writing-python"&gt;Python&lt;/a&gt;, &lt;a href="https://github.com/dmoonfire/mfgames-writing-perl"&gt;Perl&lt;/a&gt;, &lt;a href="https://github.com/dmoonfire/mfgames-writing-cil"&gt;C#&lt;/a&gt;. Most of them have bits and pieces that work, I actually use a combination of all of them.&lt;/p&gt;
&lt;p&gt;Today, I realized I was tired of working with tools from three different languages so I decided to add a fourth language that works with some future plans I have: Typescript. So, over my lunch and while kids were showing up the door for treating, I got the first version of &lt;a href="https://git.mfgames.com/author-intrusion/markdowny"&gt;Markdowny&lt;/a&gt; written.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;npm install --global markdowny
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;markdowny&lt;/code&gt; basically duplicates the most common functionality I use from the other languages and puts it into a fairly generic framework that can show off the usefulness of using YAML.&lt;/p&gt;
&lt;h1&gt;Counting&lt;/h1&gt;
&lt;p&gt;The major drawback of YAML headers is that it is hard to figure out how many words something is. The built-in word count features of most editors counts the large YAML. So, &lt;code&gt;markdowny&lt;/code&gt; has a simple feature for giving me a chapter-by-chapter breakdown of word lengths without the headers.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;markdowny count chapters/*.markdown --total
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The output is pretty simple actually. I mostly use this to select the chapters I want to submit to the writing group; we have a four thousand word limit with submissions.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;chapter-01.markdown:  1,520
chapter-02.markdown:  2,144
chapter-03.markdown:  2,908
chapter-04.markdown:  1,173
chapter-05.markdown:  2,570
Totals             : 10,315
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you don't include the &lt;code&gt;--total&lt;/code&gt; parameter, you don't get the Totals line.&lt;/p&gt;
&lt;p&gt;It is also useful for other submissions or finding out how big the novel is.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;markdowny count chapters/*.markdown --total | tail -n 1
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;Synopsis&lt;/h1&gt;
&lt;p&gt;The &lt;code&gt;summary&lt;/code&gt; key is a useful one. I write the chapter synopses as I go. It isn't nearly as overwhelming then trying to write the entire book in a single shot. That means when I have to come up with a chapter-by-chapter synopsis, I can do it fairly easily.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;markdowny sections chapters/*.markdown &amp;gt; synopsis.markdown
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The above command line goes through all of the chapter files, pulls out the title and summary block and creates a new Markdown file that contains all the summaries.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Rutejìmo

Rutejìmo was on top of the clan's shrine roof trying to sneak in and
steal his grandfather's ashes. It was a teenage game, but also one to
prove that he was capable of becoming an adult. He ended up falling off
the roof.

The shrine guard, Hyonèku, caught him before he hurt himself. After a
few humiliating comments, he gave Rutejìmo a choice: tell the clan elder
or tell his grandmother. Neither choice was good, but Rutejìmo decided
to tell his grandmother.

# Confession

Rutejìmo returned to his grandmother's cave. He tried to sneak around,
but she caught him entering. When she asked what he had done, he told
her that he had been up at the shrine. His grandmother got upset and
began to berate and beat him, chasing him out of the cave.

Gemènyo interrupted her beating to ask if it was justified. When Tejíko
explained the reason, he agreed but she had lost her anger. As she went
back into the cave, Gemènyo sat down with Rutejìmo and asked
questions. The discussion came to the upcoming rite of passage and how
Rutejìmo would gain magical powers once he experienced it. Gemènyo
wouldn't give details about the rite, but he did tell Rutejìmo that
magic wouldn't change him.

Rutejìmo snapped back, saying that Gemènyo wasn't the greatest warrior
in the clan. Gemènyo didn't seem bothered, but suggested that if
Rutejìmo wanted to be the best, he needed to do something. Rutejìmo
agreed, even knowing he wouldn't.

# Morning

Rutejìmo was sent out to get breakfast for his grandparents. Along the
way to the valley floor, he got distracted by Mapábyo, Hyonèku's adopted
daughter, riding on top of Opōgyo, one of the clan's mechanical dogs
used for dragging heavy loads around. They talk for a short while before
she asked him to come with her to take the load up to her father, who is
at the lookout above the valley entrance.

Even though Hyonèku had caught him the night before, Rutejìmo
agreed. When they get there, Hyonèku started to read a naughty letter
from his wife before Gemènyo interrupted him. Embarrassed, Hyonèku
focused on his daughter while Gemènyo talked with Rutejìmo more.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A little bit of effort ahead of time and I have a chapter-by-chapter breakdown without getting overwhelmed.&lt;/p&gt;
&lt;h1&gt;Table&lt;/h1&gt;
&lt;p&gt;The final thing &lt;code&gt;markdowny&lt;/code&gt; does is give me that summary table. I use this to compare chapters with each other and try to get an idea of what is going on with the &amp;ldquo;big picture&amp;rdquo;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;markdowny table chapters/*.markdown markdowny table -f _basename title _words characters.secondary -t File Title Words:rs &amp;quot;Secondary Characters&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;-f&lt;/code&gt; selects the fields inside the YAML. The &lt;code&gt;-t&lt;/code&gt; lets me have a pretty name for them. The results happen to be a Markdown table, so it looks a bit prettier if I just show the end results.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style="text-align: left;"&gt;Filename&lt;/th&gt;
&lt;th style="text-align: left;"&gt;Title&lt;/th&gt;
&lt;th style="text-align: left;"&gt;When&lt;/th&gt;
&lt;th style="text-align: left;"&gt;Duration&lt;/th&gt;
&lt;th style="text-align: left;"&gt;Location&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="text-align: left;"&gt;chapter-01.markdown&lt;/td&gt;
&lt;td style="text-align: left;"&gt;Rutejìmo&lt;/td&gt;
&lt;td style="text-align: left;"&gt;1471/3/28 MTR&lt;/td&gt;
&lt;td style="text-align: left;"&gt;25 gm&lt;/td&gt;
&lt;td style="text-align: left;"&gt;Shimusogo Valley&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align: left;"&gt;chapter-02.markdown&lt;/td&gt;
&lt;td style="text-align: left;"&gt;Confession&lt;/td&gt;
&lt;td style="text-align: left;"&gt;1471/3/28 MTR&lt;/td&gt;
&lt;td style="text-align: left;"&gt;35 gm&lt;/td&gt;
&lt;td style="text-align: left;"&gt;Shimusogo Valley&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align: left;"&gt;chapter-03.markdown&lt;/td&gt;
&lt;td style="text-align: left;"&gt;Morning&lt;/td&gt;
&lt;td style="text-align: left;"&gt;1471/3/29 MTR&lt;/td&gt;
&lt;td style="text-align: left;"&gt;2 m&lt;/td&gt;
&lt;td style="text-align: left;"&gt;Shimusogo Valley&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align: left;"&gt;chapter-04.markdown&lt;/td&gt;
&lt;td style="text-align: left;"&gt;Rivals&lt;/td&gt;
&lt;td style="text-align: left;"&gt;1471/3/29 MTR&lt;/td&gt;
&lt;td style="text-align: left;"&gt;1 m&lt;/td&gt;
&lt;td style="text-align: left;"&gt;Shimusogo Valley&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align: left;"&gt;chapter-05.markdown&lt;/td&gt;
&lt;td style="text-align: left;"&gt;Decisions&lt;/td&gt;
&lt;td style="text-align: left;"&gt;1471/3/29 MTR&lt;/td&gt;
&lt;td style="text-align: left;"&gt;3 m&lt;/td&gt;
&lt;td style="text-align: left;"&gt;Shimusogo Valley&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Okay, the format is based on the browser, but overall it is somewhat useful. Of course, the early chapters of that book is in the same location. Likewise, I could show the POV (which is useful for some writers) but it doesn't help much since I write single POV novels.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;markdowny table chapters/*.markdown -f title _words:r characters.primary purpose
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This gives me a decent summary of how long each chapter is, who the main character is, and a list of reasons for that chapter. From there, I have a decent idea of where I need to trim or expand the piece.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style="text-align: left;"&gt;title&lt;/th&gt;
&lt;th style="text-align: right;"&gt;_words&lt;/th&gt;
&lt;th style="text-align: left;"&gt;characters.primary&lt;/th&gt;
&lt;th style="text-align: left;"&gt;purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="text-align: left;"&gt;Rutejìmo&lt;/td&gt;
&lt;td style="text-align: right;"&gt;1520&lt;/td&gt;
&lt;td style="text-align: left;"&gt;Shimusogo Rutejìmo&lt;/td&gt;
&lt;td style="text-align: left;"&gt;Introduce Rutejìmo, Introduce Hyonèku, Introduce naming conventions, Introduce formality rules&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align: left;"&gt;Confession&lt;/td&gt;
&lt;td style="text-align: right;"&gt;2144&lt;/td&gt;
&lt;td style="text-align: left;"&gt;Shimusogo Rutejìmo&lt;/td&gt;
&lt;td style="text-align: left;"&gt;Introduce Tejíko, Introduce Gemènyo, Introduce Rutejìmo lack of talent, Introduce style of punishment, Second chapter to get used to names&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h1&gt;Other Tools&lt;/h1&gt;
&lt;p&gt;I have some other tools. There are ones that take these files and create EPUB, MOBI, and PDF files. I've been using those programs since &lt;em&gt;Sand and Blood&lt;/em&gt; was first published. There are others that I've started wht convert the in-world dates (MTR in the above example) into a master timeline or identify every chapter of every novel that happen in a given location.&lt;/p&gt;
&lt;p&gt;I also use these chapters to build up the various pages on my &lt;a href="https://fedran.com/"&gt;Fedran&lt;/a&gt; website so &lt;a href="https://fedran.com/patrons/"&gt;patrons&lt;/a&gt; can read ahead (that is the &lt;code&gt;availability&lt;/code&gt; in the YAML).&lt;/p&gt;
&lt;h1&gt;Using Markdown&lt;/h1&gt;
&lt;p&gt;Using Markdown isn't fancy but I find it is easier. Since there is so little control over format, it is easier to focus on the words that need to be written instead of making it pretty.&lt;/p&gt;
&lt;p&gt;Also, it is a text file. It plays &lt;em&gt;very&lt;/em&gt; well with Git and source control. I don't have to worry about an editor corrupting the file and losing it, it takes up little space, and I can easily switch between Notepad++, Emacs, or Atom without a second thought. I can use the best tool for the job.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Messing with Markdown</title>
    <link rel="alternate" href="https://d.moonfire.us/blog/2014/11/23/messing-with-markdown/" />
    <updated>2014-11-23T06:00:00Z</updated>
    <id>https://d.moonfire.us/blog/2014/11/23/messing-with-markdown/</id>
    <category term="programming" scheme="https://d.moonfire.us/categories/" label="Programming" />
    <category term="c-sharp" scheme="https://d.moonfire.us/tags/" label="C#" />
    <category term="markdown" scheme="https://d.moonfire.us/tags/" label="Markdown" />
    <category term="mfgames-text-markup-cil" scheme="https://d.moonfire.us/tags/" label="MfGames Text Markup CIL" />
    <category term="mfgames-writing-cil" scheme="https://d.moonfire.us/tags/" label="MfGames Writing CIL" />
    <category term="mfgames-writing-python" scheme="https://d.moonfire.us/tags/" label="MfGames Writing Python" />
    <summary type="html">I spent the last few weeks working on the beginning of an event-based Markdown parser. I know why, but I've fallen into a rabbit hole that threatens to swallow me.</summary>
    <content type="html">&lt;p&gt;I have a lot of projects in my head, which is one reason why I try to avoid starting new things while working on others. It got too easy to start a project and then never finish it when I got bored or just moved on.&lt;/p&gt;
&lt;p&gt;At the same time, many of my ideas don't &amp;ldquo;stick.&amp;rdquo; They seem like they will, but then it either doesn't work out, the ideas don't really gel, or simply I lose the passion. Some of them, like my &lt;a href="https://mfgames.com/comics/glorious-saber/"&gt;old Exalted webcomic&lt;/a&gt;, haunt me for years with the nagging voice of &amp;ldquo;finish me&amp;rdquo; but I keep not doing it. Others end up being bigger projects, but suffer through constant revisions as I try to figure it out.&lt;/p&gt;
&lt;p&gt;I do have some major projects that I haven continued to update and maintain quite a few years after I start them. One of the biggest is &lt;a href="https://github.com/dmoonfire/mfgames-writing-python"&gt;MfGames Writing Python&lt;/a&gt; which I started in 2010 when my father said I'd love Python. Even though I've long-since decided that &lt;a href="/blog/2012/10/17/two-years-of-python/"&gt;I don't like Python&lt;/a&gt;, I've still been writing updates to the tools in support of my own writing efforts.&lt;/p&gt;
&lt;p&gt;Like &lt;em&gt;Glorious Saber&lt;/em&gt;, I've been thinking about converting my Python writing tools over to C#, but never really got to it. I had a couple stabs at it but nothing really &amp;ldquo;stuck.&amp;rdquo;&lt;/p&gt;
&lt;h1&gt;The Side Project&lt;/h1&gt;
&lt;p&gt;After ICON, something &lt;a href="http://www.jimchines.com/"&gt;Jim C. Hines&lt;/a&gt; and &lt;a href="http://www.scottlynch.us/"&gt;Scott Lynch&lt;/a&gt; said during their &amp;ldquo;Beyond SF 101&amp;rdquo; panel was still echoing in my head.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write more words and don't be a dick.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Now, &lt;a href="/tags/sand-and-ash/"&gt;Sand and Ash&lt;/a&gt; is still stuck in limbo, so I couldn't really do anything with that. So I had this idea for a writing project that would be complimentary to my &lt;a href="https://fedran.com/"&gt;Fedran&lt;/a&gt; world and let me get different ideas out. It involved smaller pieces, short stories and essays and lessons, so I was trying to figure out how to pull it all together.&lt;/p&gt;
&lt;p&gt;For some reason, my Python tools just choked. They are optimized toward writing novels and single-file &lt;a href="http://www.docbook.org/tdg5/en/html/docbook.html"&gt;DocBook 5&lt;/a&gt; files, but not a multitude of smaller DocBook XML files which would these individual pieces.&lt;/p&gt;
&lt;p&gt;I started to look into my C# version, which had a different &amp;ldquo;gather&amp;rdquo; utility and, once again, realized that I probably wasn't &lt;em&gt;that&lt;/em&gt; far off from getting the C# version working with its flaws and maybe move away from the Python.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;One of my major difficulties with Python is that it doesn't handle UTF-8 characters natively. I seem to have a lot of non-ANSI characters in my desert world (macros are a killer) and it kept choking on them.&lt;/em&gt;&lt;/p&gt;
&lt;h1&gt;MfGames Writing CIL&lt;/h1&gt;
&lt;p&gt;So I shifted from my side project to &lt;a href="https://github.com/dmoonfire/mfgames-writing-cil"&gt;MfGames Writing CIL&lt;/a&gt; which is the C# version of the Python tools &amp;ldquo;plus&amp;rdquo; additional functionality. The biggest is that I wrote the Python around &lt;a href="http://www.wikicreole.org/"&gt;Creole&lt;/a&gt; instead of &lt;a href="http://en.wikipedia.org/wiki/Markdown"&gt;Markdown&lt;/a&gt;, which is the markup language I've migrated my writing to.&lt;/p&gt;
&lt;p&gt;While I was working with writing up a Markup conversion utility for the tools, I came upon &lt;a href="http://commonmark.org/"&gt;CommonMark&lt;/a&gt; which is an attempt at a well-documented specification. I figured I could use that to help guide my effort on the conversion utility.&lt;/p&gt;
&lt;p&gt;It didn't take long before I realized that I was duplicating my work with &lt;a href="/tags/author-intrusion/"&gt;Author Intrusion&lt;/a&gt; for handling Markdown. Usually when that happens, I figure I should start up a new project to handle the common logic and write it once.&lt;/p&gt;
&lt;h1&gt;MfGames Text Markup CIL&lt;/h1&gt;
&lt;p&gt;And then I moved from &lt;em&gt;MfGames Writing CIL&lt;/em&gt; to &lt;a href="https://github.com/dmoonfire/mfgames-text-markup-cil"&gt;MfGames Text Markup CIL&lt;/a&gt;. This is an attempt to create a single, centralized reader (and eventually writer) of markup languages in general and Markdown in specific.&lt;/p&gt;
&lt;p&gt;There were a couple reasons I went this project instead of another library:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Most Markdown libraries only convert to HTML, which meant I was parsing HTML to get into Author Intrusion or DocBook format. I wanted something that had an intermediate output that was ideal for converting to other formats.&lt;/li&gt;
&lt;li&gt;Again, most libraries seem to load the entire Markdown file into memory at once (mainly because of the deferred links) and then writing it out. I haven't tested this completely, but I already know that I have 640k word series that have to be parsed; I do not want to have this loaded into memory. This implies a callback interface (SAX verses DOM).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I decided to write this in a similar style to C#'s XmlReader. Instead of loading everything into memory and then writing out the results, it just translates the Markdown file into element types.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// Loop through the Markdown and process each one.
while (markdown.Read())
{
    switch (markdown.ElementType)
    {
        case MarkupElementType.BeginDocument:
            this.WriteBeginDocument(xml);
            break;

        case MarkupElementType.EndDocument:
            xml.WriteEndElement();
            xml.WriteEndDocument();
            break;

        case MarkupElementType.BeginMetadata:
        case MarkupElementType.EndMetadata:
        case MarkupElementType.BeginContent:
        case MarkupElementType.EndContent:
            break;

        case MarkupElementType.BeginCodeSpan:
            this.WriteForeignPhrase(markdown, xml);
            break;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The system seemed to work out pretty well for my test cases, but when I started to throw &amp;ldquo;real&amp;rdquo; chapters at it, it started to crumble. Not from the foundation, but simply because I didn't write a good enough Markdown parser to translate them.&lt;/p&gt;
&lt;h1&gt;CommonMark&lt;/h1&gt;
&lt;p&gt;And here is where I started down the rabbit hole. The callback system worked great, but I needed to get my parser to be competent enough to handle what I wrote. Once I get that, converting to DocBook is trivial (as the above example probably shows).&lt;/p&gt;
&lt;p&gt;A few days ago, I noticed that the &lt;a href="https://github.com/jgm/CommonMark/blob/master/spec.txt"&gt;CommonMark spec&lt;/a&gt; was a Markdown file with some magic for handling the input/output examples. Well, I could write a bunch of unit tests or&amp;hellip; I could write a program that converted the 500+ examples into unit tests for me.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Why write things out by hand when I can write a program to do it for me?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Last night, I finished converting most of the unit tests over. Now, I just have to solve 508 unit tests, or at least 300 of them.&lt;/p&gt;
&lt;h1&gt;Rabbit Holes&lt;/h1&gt;
&lt;p&gt;I'm pretty sure this is going to be overwhelming but I think it will still further my goal of finishing up my writing tools and get back to my side project. We'll see how it ends up, but I still have a mountain to climb.&lt;/p&gt;
&lt;p&gt;This is also the reason I haven't really posted for a few weeks to. I was lost in a rabbit hole.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Author Intrusion - Names</title>
    <link rel="alternate" href="https://d.moonfire.us/blog/2014/08/07/author-intrusion-names/" />
    <updated>2014-08-07T05:00:00Z</updated>
    <id>https://d.moonfire.us/blog/2014/08/07/author-intrusion-names/</id>
    <category term="programming" scheme="https://d.moonfire.us/categories/" label="Programming" />
    <category term="writing" scheme="https://d.moonfire.us/categories/" label="Writing" />
    <category term="author-intrusion" scheme="https://d.moonfire.us/tags/" label="Author Intrusion" />
    <category term="markdown" scheme="https://d.moonfire.us/tags/" label="Markdown" />
    <category term="docbook" scheme="https://d.moonfire.us/tags/" label="DocBook" />
    <category term="c-sharp" scheme="https://d.moonfire.us/tags/" label="C#" />
    <summary type="html">One of the complexities of authors is their names. I want to avoid making an assumption of how they are displayed and used. At the same time, I want to reuse the logic to handle character names within the story.</summary>
    <content type="html">&lt;p&gt;I was slowly making my way through the Markdown and DocBook file processing when I hit an interesting snag: names.&lt;/p&gt;
&lt;p&gt;Author names are a strange thing. It would be easy to just stick with the Western approach, which is what Amazon uses in their KDP program: first and last name. Smashwords does the same but they add suffix. No mention of title, which some people really hang up on (I almost went through a Ph.D. program just so I could be Dr. Moonfire).&lt;/p&gt;
&lt;h1&gt;Complexity of names&lt;/h1&gt;
&lt;p&gt;The problem is that I work with Japanese people who have family name first and given name second. There are others too, I just happen to know Japanese culture a little better than most others. Most websites I know don't actually handle this because they assume the first/last name approach.&lt;/p&gt;
&lt;p&gt;You have some cultures where many people have two last names, one from the mother and one from the father.&lt;/p&gt;
&lt;p&gt;The other interesting problem comes in with single name authors, let's go with Madonna or Teller for examples. Some websites allow you to go without both names, but there are a lot that don't. Google, for example, insists on something and NFN (No First Name) looks horrible when they say &amp;quot;Hello, NFN!&amp;quot;.&lt;/p&gt;
&lt;p&gt;An interesting one is Goodreads. Goodreads lets you have an account with only one name, but you can't sign up for a raffle without both names filled out.&lt;/p&gt;
&lt;p&gt;There are also names that start with a lowercase character or have an apostrophe in the middle. Or a slew of other Unicode characters that most developers make assumptions that aren't true.&lt;/p&gt;
&lt;p&gt;This bothers me, but that shouldn't be a surprise. One of the principals of Author Intrusion is &amp;ldquo;Author Know Best&amp;rdquo;. It means that the author knows what they are doing and we don't tell them how to work. This includes how format their own name. If they want a Unicode symbol, that's fine. I'll probably draw the line at images for authors, simply because I don't want to code that. I'm all for it, it's just low in my priority list.&lt;/p&gt;
&lt;h1&gt;Solving the problem&lt;/h1&gt;
&lt;p&gt;Normally, I use DocBook for inspiration on handling things. I figured after so many decades, they've solved most of the problems. And, in this case, I think &lt;a href="http://www.docbook.org/tdg5/en/html/personname.html"&gt;they have&lt;/a&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-xml"&gt;&amp;lt;author&amp;gt;
  &amp;lt;personname&amp;gt;Madonna&amp;lt;/personname&amp;gt;
&amp;lt;/author&amp;gt;
&amp;lt;author&amp;gt;
  &amp;lt;personname&amp;gt;
	&amp;lt;honorific&amp;gt;Not-Dr&amp;lt;/honorific&amp;gt;
	&amp;lt;firstname&amp;gt;Dylan&amp;lt;/firstname&amp;gt;
	&amp;lt;othername role=&amp;quot;middle&amp;quot;&amp;gt;Robert Evans&amp;lt;/othername&amp;gt;
	&amp;lt;surname&amp;gt;Moonfire&amp;lt;/surname&amp;gt;
  &amp;lt;/personname&amp;gt;
&amp;lt;/author&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There are no specific conventions for &lt;code&gt;othername&lt;/code&gt;, but it's better than most. It also lets me enter full names for the author and figure out how to format them later.&lt;/p&gt;
&lt;p&gt;In my Markdown files, my author tag is usually a preferred name.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;---
Title: Amazon Piece
Author: D. Moonfire
---

It was a dark and stormy tea cup...
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This caused me some trouble with formatting ebooks because I occasionally need to know first name and last name to figure out sorting.&lt;/p&gt;
&lt;h1&gt;Reusing concepts&lt;/h1&gt;
&lt;p&gt;While I was in the process of figuring out names, I realized that I'm going to have the same problem with one of my future plans: characters. One of the reasons I'm writing this is to highlight character names. All of them, including possessives and nicknames. There is some other ideas around this, but I needed to handle a highly flexible approach there also.&lt;/p&gt;
&lt;p&gt;From there, it was easy to figure out that I'm going to use the same class to represent an author name as well as character (location, objects, etc) names. And then I came up with &lt;code&gt;NameInfo&lt;/code&gt;. This is a &lt;code&gt;Dictionary&amp;lt;string, string&amp;gt;&lt;/code&gt; that uses interned key strings.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-csharp"&gt;NameInfo name = new NameInfo();
name.PreferredName = &amp;quot;Shimusogo Rutejìmo&amp;quot;;
// or name[&amp;quot;Preferred Name&amp;quot;] = &amp;quot;Shimusogo Rutejìmo&amp;quot;;
name[&amp;quot;First Name&amp;quot;] = &amp;quot;Rutejìmo&amp;quot;;
// or name.FirstName = &amp;quot;Rutejì&amp;quot;;
name[&amp;quot;Clan&amp;quot;] = &amp;quot;Shimusìgo;
name[&amp;quot;Surname&amp;quot;] = &amp;quot;Shimusogo;
name[&amp;quot;Nickname&amp;quot;] = &amp;quot;Jìmo&amp;quot;;
name[&amp;quot;Possessive&amp;quot;] = &amp;quot;Rutejìmo's&amp;quot;;
name[&amp;quot;Possessive Nickname&amp;quot;] = &amp;quot;Jìmo's&amp;quot;;

NameInfo author = new NameInfo() { PreferredName = &amp;quot;D. Moonfire&amp;quot; };
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When I write these out in DocBook, it will become a full XML block.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-xml"&gt;&amp;lt;personname&amp;gt;
	&amp;lt;firstname&amp;gt;Rutejìmo&amp;lt;/firstname&amp;gt;
	&amp;lt;surname&amp;gt;Shimusogo&amp;lt;/surname&amp;gt;
	&amp;lt;othername role=&amp;quot;Clan&amp;quot;&amp;gt;Shimusì/othername&amp;gt;
	&amp;lt;othername role=&amp;quot;Preferred Name&amp;quot;&amp;gt;Shimusogo Rutejìmo&amp;lt;/othername&amp;gt;
	&amp;lt;othername role=&amp;quot;Nickname&amp;quot;&amp;gt;Jìmo&amp;lt;/othername&amp;gt;
	&amp;lt;othername role=&amp;quot;Possessive&amp;quot;&amp;gt;Rutejìmo's&amp;lt;/othername&amp;gt;
	&amp;lt;othername role=&amp;quot;Possessive Nickname&amp;quot;&amp;gt;Jìmo's&amp;lt;/othername&amp;gt;
&amp;lt;/personname&amp;gt;

&amp;lt;personname&amp;gt;D. Moonfire&amp;lt;/personname&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the Markdown formatter, I get this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;---
name:
  PreferredName: &amp;quot;Shimusogo Rutejìmo&amp;quot;
  FirstName: &amp;quot;Rutejìmo&amp;quot;
  Clan: &amp;quot;Shimusìgo&amp;quot;
  Surname: &amp;quot;Shimusogo&amp;quot;
  Nickname: &amp;quot;Jìmo&amp;quot;
  Possessive: &amp;quot;Rutejìmo's&amp;quot;
  PossessiveNickname: &amp;quot;Jìmo's&amp;quot;
author: D. Moonfire
---
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;Overall, this seems to work. If you have a simple name, as some authors do, it will create a neat output file and they just have to enter the name. For those who are a bit pickier about names, it will let them have a complex name or set of names. It also means that when I put in name highlighting and refactoring (I rename characters a lot, but I want to also change possessive and nicknames at the same time), I'll have the infrastructure to do so.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Author Intrusion - A black triangle CLI</title>
    <link rel="alternate" href="https://d.moonfire.us/blog/2014/08/02/author-intrusion-cli-and-black-triangle/" />
    <updated>2014-08-02T05:00:00Z</updated>
    <id>https://d.moonfire.us/blog/2014/08/02/author-intrusion-cli-and-black-triangle/</id>
    <category term="programming" scheme="https://d.moonfire.us/categories/" label="Programming" />
    <category term="author-intrusion" scheme="https://d.moonfire.us/tags/" label="Author Intrusion" />
    <category term="mfgames-writing-python" scheme="https://d.moonfire.us/tags/" label="MfGames Writing Python" />
    <category term="markdown" scheme="https://d.moonfire.us/tags/" label="Markdown" />
    <category term="docbook" scheme="https://d.moonfire.us/tags/" label="DocBook" />
    <category term="git" scheme="https://d.moonfire.us/tags/" label="Git" />
    <summary type="html">I reached the first visible moment in Author Intrusion with command-line tool that does one thing, convert Markdown into DocBook formats.</summary>
    <content type="html">&lt;p&gt;Over the last week, I've been working on the current version of &lt;a href="/tags/author-intrusion/"&gt;Author Intrusion&lt;/a&gt;. It can get pretty discouraging since there is so much to do, so I'm focusing on a single task at a time and building out along the way so I will &lt;em&gt;hopefully&lt;/em&gt; get a complete project by the end.&lt;/p&gt;
&lt;h1&gt;Formatting&lt;/h1&gt;
&lt;p&gt;One of the hardest things about coding is the GUI. There are so many things for getting events hooked up and the interface running smoothly. Being that GUIs are my weakest area of code, plus the state of the cross-platform .NET UI libraries is still a little weak, I'm going to work on other things.&lt;/p&gt;
&lt;p&gt;I ended up deciding on project IO. For those who have read my blog in the post, you probably remember that I spend a lot of time working on automated the creation of ebooks and print from my source documents. Not to mention a lot of time working on creating a format that works the way I like to work.&lt;/p&gt;
&lt;p&gt;That lead into my first goal: transforming a source project into another format. Eventually, this is going to lead into system used to create ODT, Microsoft Word, EPUB, MOBI, and everything else. Not to mention importing from other formats.&lt;/p&gt;
&lt;p&gt;While I'm going to eventually have a GUI interface for it, I can also write a command-line interface (CLI) version which lets me get the functionality written without getting distracted by the GUI.&lt;/p&gt;
&lt;h1&gt;Progress&lt;/h1&gt;
&lt;p&gt;This weekend, I actually saw the beginning of my ideas show up. The initial framework for converting a &lt;a href="http://daringfireball.net/projects/markdown/"&gt;Markdown&lt;/a&gt; file into &lt;a href="http://www.docbook.org/tdg5/en/html/docbook.html"&gt;DocBook 5&lt;/a&gt; worked via the CLI.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-shell"&gt;$ aicli transform sample.markdown sample.xml
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I went with &lt;code&gt;aicli&lt;/code&gt; (Author Intrusion CLI) for the tool. The interface is inspired by &lt;a href="http://git-scm.com/"&gt;Git&lt;/a&gt; with sub-commands and a somewhat flexible way of adding new tools.&lt;/p&gt;
&lt;p&gt;The cool part is that the above command actually worked. It doesn't look like much, but there weeks of effort to get to that point. It's a &lt;a href="http://philosophistry.com/archives/2009/01/what-is-a-black.html"&gt;black triangle&lt;/a&gt; moment in this development.&lt;/p&gt;
&lt;h1&gt;Formats&lt;/h1&gt;
&lt;p&gt;I arranged the file formats into, creatively enough, &lt;code&gt;IBufferFormat&lt;/code&gt; objects. They are discovered via an &lt;a href="http://en.wikipedia.org/wiki/Inversion_of_control"&gt;IoC&lt;/a&gt; container (&lt;a href="http://docs.structuremap.net/"&gt;StructureMap&lt;/a&gt;) and represent a single type of input or output.&lt;/p&gt;
&lt;p&gt;The initial ones to get the above code working were:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Markdown (input only)&lt;/li&gt;
&lt;li&gt;DocBook (output only)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I'll get these to be both input and output, that way anyone can use either Markdown or DocBook files for their primary project format. I'll also use these for the output formats:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;EPUB&lt;/li&gt;
&lt;li&gt;MOBI&lt;/li&gt;
&lt;li&gt;Libreoffice (ODT)&lt;/li&gt;
&lt;li&gt;Microsoft Word (DOCX)&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;And it has options too!&lt;/h1&gt;
&lt;p&gt;Yeah, the other bit I like is the single configurable option.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-shell"&gt;$ aicli transform sample.markdown sample.xml -ORootElement=chapter
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There may be more, but that puts me one step closer to replacing &lt;code&gt;mfgames-creole docbook&lt;/code&gt; that I originally wrote for &lt;a href="https://github.com/dmoonfire/mfgames-writing-python"&gt;MfGames Writing Python&lt;/a&gt;.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Personal branching model</title>
    <link rel="alternate" href="https://d.moonfire.us/blog/2013/04/03/personal-branching-model/" />
    <updated>2013-04-03T05:00:00Z</updated>
    <id>https://d.moonfire.us/blog/2013/04/03/personal-branching-model/</id>
    <category term="technology" scheme="https://d.moonfire.us/categories/" label="Technology" />
    <category term="writing" scheme="https://d.moonfire.us/categories/" label="Writing" />
    <category term="fonts" scheme="https://d.moonfire.us/tags/" label="Fonts" />
    <category term="markdown" scheme="https://d.moonfire.us/tags/" label="Markdown" />
    <category term="sand-and-ash" scheme="https://d.moonfire.us/tags/" label="Sand and Ash" />
    <content type="html">&lt;p&gt;Discipline is one of those things I struggle with. The biggest is how I use source control for both my programming and my writing projects. As we start to implement Git at works, some of my lazy habits at home are becoming more (painfully) obvious.&lt;/p&gt;
&lt;p&gt;&lt;!--more--&gt;&lt;/p&gt;
&lt;h1&gt;Noise&lt;/h1&gt;
&lt;p&gt;I commit a lot, mostly at the end of a thought. So, once I finish a chapter or a good scene, or write a series of methods and tests, I'll commit locally. I don't always give "good" messages for those commits, but enough to give me a hint of what is going on.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Checking in so I can move downstairs.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The problem with this is noise. There are a ton of check-ins that don't have useful comments. After a day or three, I won't care about those comments since they are basically just a progression to figure out something.&lt;/p&gt;
&lt;p&gt;In the past, I usually worked on the &lt;em&gt;master&lt;/em&gt; branch and cringed at the noise. Occasionally I would rebase to squash them down so I don't have quite as much noise, but overall I just suffered with them.&lt;/p&gt;
&lt;h1&gt;Seeing it differently&lt;/h1&gt;
&lt;p&gt;With the migration to Git at work, I realized that I need to actually use branches more effectively. Noise commits aren't so bad if they are put into a task branch and then later squashed once they get to the master root. So, I don't have to worry about going downstairs if I know those will be collapsed into a single useful commit later.&lt;/p&gt;
&lt;p&gt;It also lets me work without too many restrictions during the creative process. Which is good since I find committing frequently to be critical to my process.&lt;/p&gt;
&lt;h1&gt;Where to put it&lt;/h1&gt;
&lt;p&gt;Now, the really big question is where to put it. I'm normally not fond of airing my "dirty laundry" as it were. I figured no one cares if I'm switching computers during the process and I don't blame them.&lt;/p&gt;
&lt;p&gt;However, if I'm working between two machines, it seems silly to create an entirely different repository purely for the purpose of working between machines. This came up while working on the &lt;a href="https://github.com/dmoonfire/fedran-fontforge"&gt;Fedran fonts&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;At the moment, I decided to take a chance and just push it up to Github. There is going to be noise but it won't be on the master branch. I might prefix the branches with "drem-" to indicate they are task branches.&lt;/p&gt;
&lt;p&gt;This lets me take advantage of Github's ability to manage branches but also to let other people join in (in the unlikely chance someone wants to help me work on something).&lt;/p&gt;
&lt;h1&gt;Novels&lt;/h1&gt;
&lt;p&gt;Since I also recently started my next novel (&lt;a href="http://wiscon.info"&gt;WisCon&lt;/a&gt; has a deadline for the writing group on the 15th), I decided to explore this process with the novel. I'm doing most of the work on the 'sal' branch because novel writing is pretty much independent of everything else I write. Same with the commissions and other WIPs (which I have a number of them).&lt;/p&gt;
&lt;p&gt;Doing it this way means I can put novels in their proper place in my directory tree as a WIP instead of a dedicated folder. It's a minor thing, but I like the Fedran stuff underneath the "moonfire/fedran/" directory instead of in the "wip/" folder.&lt;/p&gt;
&lt;h1&gt;Markdown&lt;/h1&gt;
&lt;p&gt;I'm planning on switching my entire writing repository over to Markdown within a few &lt;em&gt;(mumble)&lt;/em&gt;. I need to finish a little bit of programming, but I already have the Perl script to do the conversion. If I go with this approach, then I can easily create a "markdown" branch and do the conversion until everything is ready to migrate.&lt;/p&gt;
&lt;p&gt;The biggest hangup on the Markdown conversion is a good conversion to DocBook. I have the beginning of one in my writing tools, I just haven't finished it yet. It needs to be done so I can integrate the new code into my workflow.&lt;/p&gt;
&lt;h1&gt;New ideas hurt&lt;/h1&gt;
&lt;p&gt;I think the branching model will work out, though it feels strange. I just don't know if the strangeness is because I'm not used to it or because it is wrong. I think I'll have an answer in a few months.&lt;/p&gt;
</content>
  </entry>
</feed>
