pttk

This is a pandoc preprocessor toolkit based on my experiment pdtmpl

https://github.com/rsdoiel/pttk

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.1%) to scientific vocabulary

Keywords

text-processing
Last synced: 4 months ago · JSON representation ·

Repository

This is a pandoc preprocessor toolkit based on my experiment pdtmpl

Basic Info
Statistics
  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • Open Issues: 5
  • Releases: 6
Topics
text-processing
Created over 3 years ago · Last pushed 5 months ago
Metadata Files
Readme Changelog License Citation Codemeta

README.md

Project Status: Concept – Minimal or no implementation has been done yet, or the repository is only intended to be a limited example, demo, or proof-of-concept.

pttk

pttk is a plain text tool kit for writing. The main focus is on static site generation supplementing tools like Pandoc. The metaphor behind the tool kit is a deconstructed content management system. It is easily scripted from your favorite POSIX shell or Makefile. It provides a number of functions including a blogging tool called blogit, phlogit, JSONfeed, RSS generations and rudimentary support for sitemap.xml. Combined with Pandoc and Pagefind you can easily build rich websites and blogs.

A command line tool kit

pttk is a program that works on the command line or shell. pttk usage is structured around the idea "verbs" or actions. Each "verb" can have it's own set of options and command syntax.

The basic usage is as follows

pttk VERB [OPTIONS]

Currently there are four verbs supported by pttk.

blogit : A tool for manage a blog directory structure and a "blog.json" metadata file

rss : A tool for generating RSS files from blogit

sitemap : A tool for generating a sitemap.xml file.

include : A "include" text preprocessor including files with via an "#include();" directive.

blogit is a tool to make it easy to separate website generation from where you might want to write your blog posts. It will generate and maintain a blog style directory structure. A blog directory structure is usually in the form of /YYYY/MM/DD/ where "YYYY" is a year, "MM" is a two digit month and "DD" is a two digit day representation. It also maintains a "blog.json" document that describes the metadata and layout for your blog. blogit uses the front matter in your Markdown documents to know things like titles, post dates and authorship. The two pttk verbs "rss" and "sitemap" know how to interpret the blog.json to generate RSS and sitemap.xml respectively.

The form of the blogit command is

shell pttk blogit PATH_TO_DOCUMENT_TO_IMPORT [YYYY_MM_DD]

In this example I have a Markdown document I want to use as a blog post in $HOME/Documents/pttk-tutorial.md. I'm generating my blog in a directory called $HOME/Sites/my-website/blog. If I want to "blog" the document I first change to "my-website" directory and use blogit to update my blog.

shell cd $HOME/Sites/my-website/blog pttk blogit $HOME/Documents/pttk-tutorial.md

The blogit verb assumes you are in the current working directory where you have your blog.

By default blogit will use the current date in "YYYY-MM-DD" format for the blog post. If you want to have the post on a specific day then you include the date for the post in "YYYY-MM-DD" format. Here's an example of posting the tutorial on 2022-08-01 (August 8th, 2022).

shell cd $HOME/Sites/my-website/blog pttk blogit $HOME/Documents/pttk-tutorial.md 2022-08-08

rss is the verb used to generate an RSS feed from a blogit blog.json file. The format of the command is

shell pttk rss PATH_TO_BLOG_JSON PATH_TO_RSS_FILE

If I want my blog feed to be feeds/index.xml in the WordPress style for my blog in the blog directory I would change to my-website directory and then use the rss as follows.

shell cd $HOME/Sites/my-website pttk rss blog/blog.json feeds/index.xml

This will generate our feeds/index.xml document. If the feeds directory doesn't exist it'll get created. Updating the RSS picking up new post is just a matter of invoking pttk rss the command again.

sitemap generates a "sitemap.xml" file that describes the site layout to searching crawlers. The specification for sitemap.xml stipulates a maximum number of entries in the sitemap.xml. For large websites this used to be a problem but the specification allows for multiple sitemaps to be used. The sitemap verb will generate a sitemap.xml in the root website directory and in any sub-directories of the website. If Markdown documents are found then it'll use front matter for the matching HTML files and "blog.json" file for the blog content.

The form for sitemap is simple.

ptdk sitemap [ROOT_WEBSITE_DIRECTORY]

Here's an example for our "my-website" directory.

pttk sitemap $HOME/Sites/my-website

This wold generate a sitemap file of $HOME/Sites/my-website/sitemap.xml and if necessary ones in the sub directories like blog.

Go package

Here's some simple use examples of the three functions supplied in the pttk package.

Given a JSON Object document as a slice of bytes render formatted output based on the Pandoc template example.tmpl

go src, err := ioutil.ReadFile("example.json") if err != nil { // ... handle error } // options passed to Pandoc opt := []string{"--template", "example.tmpl"} src, err = pttk.Apply(src, opt) if err != nil { // ... handle error } fmt.Fprintf(os.Stdout, "%s", src)

Using an io.Reader to retrieve the JSON content, process with the example.tmpl template and write standard output

go f, err := Open("example.json") if err != nil { // ... handle error } defer f.Close() // options passed to Pandoc opt := []string{"--template", "example.tmpl"} src, err := pttk.ReadAll(f, opt) if err != nil { // ... handle error } fmt.Fprintf(os.Stdout, "%s", src)

Using an io.Reader and io.Writer to read JSON source from standard input and write the processed Pandoc templated standard output.

go // options passed to Pandoc opt := []string{"--template", "example.tmpl"} err := pttk.ApplyIO(os.Stdin, os.Stdout, opt) if err != nil { // ... handle error }

Requirements

  • Pandoc 3.1 or better
  • Go 1.21.4 or better to compile from source
  • GNU Make (optional) to automated compilation
  • Git or other Git client to retrieve this repository

Installation

  1. Clone https://github.com/rsdoiel/pttk to your local machine
  2. Change directory into the git repository (i.e. pttk
  3. Compile using go build
  4. Install using go install

shell git clone https://github.com/rsdoiel/pttk cd pttk git fetch origin git pull origin main go build -o bin/pttk cmd/pttk/pttk.go go install

NOTE: This recipe assumes' you are familiar with setting up a Go development environment (e.g. You've set GOPATH environment appropriately). See the go website for details about setting up and compiler programs.

License

pttk, a plain text toolkit Copyright (C) 2023 R. S. Doiel

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.

Owner

  • Name: R. S. Doiel
  • Login: rsdoiel
  • Kind: user
  • Location: California
  • Company: California Institute of Technology

I am a human. Once upon a time I wrote music and prose. I write software.

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
type: software
title: pttk
abstract: "pttk is a plain text tool kit for writing. The main focus is on static web using Markdown documents.  The metaphor behind the tool kit is a deconstructed content management system. It is easily scripted from your favorite POSIX shell or Makefile. It provides a number of functions including a sitemapper, rss generator, blogging tool call blogit, a tool that can form series based on Markdown front matter. To preview your site a "ws" action is included that functions as a localhost web server. Between tools like pttk, PageFind and Flatlake you can provide much of the dynamic capability you'd find in a traditional CMS like Wordpress without running one."
authors:
  - family-names: Doiel
    given-names: R. S.
    orcid: https://orcid.org/0000-0003-0900-6903
    email: rsdoiel@gmail.com


repository-code: "git+https://github.com/rsdoiel/pttk"
version: 0.0.19
date-released: 2025-03-13

license-url: "https://spdx.org/licenses/AGPL-3.0-or-later"
keywords:
  - text-processing
  - site-generator

CodeMeta (codemeta.json)

{
  "@context": "https://doi.org/10.5063/schema/codemeta-2.0",
  "type": "SoftwareSourceCode",
  "codeRepository": "git+https://github.com/rsdoiel/pttk",
  "author": [
    {
      "id": "https://orcid.org/0000-0003-0900-6903",
      "type": "Person",
      "givenName": "R. S.",
      "familyName": "Doiel",
      "email": "rsdoiel@gmail.com"
    }
  ],
  "dateCreated": "2022-07-22",
  "dateModified": "2025-03-13",
  "datePublished": "2025-03-13",
  "description": "pttk is a plain text tool kit for writing. The main focus is on static web using Markdown documents.  The metaphor behind the tool kit is a deconstructed content management system. It is easily scripted from your favorite POSIX shell or Makefile. It provides a number of functions including a sitemapper, rss generator, blogging tool call blogit, a tool that can form series based on Markdown front matter. To preview your site a \"ws\" action is included that functions as a localhost web server. Between tools like pttk, PageFind and Flatlake you can provide much of the dynamic capability you'd find in a traditional CMS like Wordpress without running one.",
  "keywords": [
    "text-processing",
    "site-generator"
  ],
  "name": "pttk",
  "license": "https://spdx.org/licenses/AGPL-3.0-or-later",
  "operatingSystem": [
    "Linux",
    "Windows",
    "macOS"
  ],
  "programmingLanguage": [
    "Go",
    "TypeScript"
  ],
  "relatedLink": [
    "https://github.com/rsdoiel/pdtmpl",
    "https://github.com/caltechlibrary/mkpage"
  ],
  "runtimePlatform": "- Deno >= 2.2",
  "softwareRequirements": [
    "GNU Make >= 3.8",
    "Pandoc >= 3.1",
    "SQLite3 >= 3.43",
    "Go >= 1.24",
    "Deno >= 2.2"
  ],
  "version": "0.0.19",
  "developmentStatus": "wip",
  "issueTracker": "https://github.com/rsdoiel/pttk/issues",
  "releaseNotes": "Pttk is still an experiment. Features may come and go. v0.0.18 is a hybrid codebase. Legacy pttk is in Go. New experiments in TypeScript. Separate Makefiles provided for each."
}

GitHub Events

Total
  • Release event: 1
  • Push event: 22
  • Create event: 2
Last Year
  • Release event: 1
  • Push event: 22
  • Create event: 2

Issues and Pull Requests

Last synced: 8 months ago

All Time
  • Total issues: 5
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 1
  • Total pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • rsdoiel (5)
Pull Request Authors
Top Labels
Issue Labels
enhancement (4) bug (1)
Pull Request Labels

Dependencies

go.mod go
  • github.com/rsdoiel/fountain v0.0.3
  • github.com/rsdoiel/stngo v0.0.12
  • golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa
  • golang.org/x/sys v0.0.0-20211019181941-9d821ace8654
  • gopkg.in/yaml.v3 v3.0.1
go.sum go
  • github.com/caltechlibrary/cli v0.0.16
  • github.com/rsdoiel/fountain v0.0.3
  • github.com/rsdoiel/stngo v0.0.12
  • golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa
  • golang.org/x/sys v0.0.0-20211019181941-9d821ace8654
  • gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
  • gopkg.in/yaml.v3 v3.0.1