Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pmbauer committed May 25, 2020
0 parents commit c10dc89
Show file tree
Hide file tree
Showing 15 changed files with 33,448 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
release/
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
NAME ?= av-roam
VERSION ?= $(shell git rev-parse --short HEAD)
ARTIFACT ?= $(NAME)_$(VERSION).tar.gz
export

.DEFAULT_GOAL := build
.PHONY: build test clean

release:
mkdir release
release/*.md: release
cd release; ../generate.awk ../av.input
release/$(ARTIFACT): release/*.md
cd release; tar czf $(ARTIFACT) *.md
build: release/$(ARTIFACT)

test/output:
mkdir test/output
test: test/output
test/run.sh

clean:
rm -f release/* test/output/*
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# av-roam
Generates a King James ([Authorized Version](https://en.wikipedia.org/wiki/King_James_Version)) text that is formatted for import into a Roam Research database.

It uses Roam markdown and [LaTeX](https://en.wikipedia.org/wiki/LaTeX) features to approximate the original print as much as possible.

![note italicized words, section headers, and special treatment of YHWH](doc/example.png)

## Features

1. One chapter per note, one verse per block.
1. Navigational metadata: *Previous/Next* chapter links and `#<Book>` tags
1. _italicized_ words to indicate translation additions
1. _yhwh_ formatted LORD as in the original print
1. original print paragraph markings and chapter notes
1. KJV Cambridge
1. Table of Contents Page: `KJV`

## Usage

1. [Download the current release](https://github.com/pmbauer/av-roam/releases/download/5fa7989/av-roam_5fa7989.tar.gz) and extract locally
2. Use Roam Research `...` menu and select `Import Files`
3. Choose chapters you wish to import.

## Import Everything
Note that importing a corpus as large as the entire Bible *will* impact your database's performance, so for now it's recommended to import chapters ad-hoc.

But if you still wish to import everything, there is a [public KJV Roam](https://roamresearch.com/#/app/KJV).
From there you can JSON-export the contents and import into your personal database.
N.B. that version is missing a number of features from the original AV translation: _italicized_ words to indicate translation word additions, footnotes, chapter and section headings (e.g. Psalms 119)

## Building
```bash
# builds release artifact
make
make build

# run tests
make test

# clean up
make clean
```
32,581 changes: 32,581 additions & 0 deletions av.input

Large diffs are not rendered by default.

Binary file added doc/example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions generate.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env gawk -f

function acopy(a, b) {
delete b
for (k in a) {
b[k] = a[k]
}
}

BEGIN {
delete verses; delete current; delete previous;
kjv_toc = "KJV.md"
OFS=""
}

# collect :::SET K V state
match($0, /^:::SET\s+(\w+)\s+(.*)/, ord) {
if (length(verses) > 0 && length(current)==0) {
acopy(meta, current)
}
meta[ord[1]] = ord[2];
}

# begin TOC
match($0, /^:::SET\s+TESTAMENT\s+(.*)/, ord) {
print "- [[", ord[1], " Testament]]" >> kjv_toc
}

match($0, /^:::SET\s+BOOK\s+(.*)/, ord) {
meta["BOOKCHAPTER"] = ord[1]
print " - [[", ord[1], "]]" >> kjv_toc
}

match($0, /^:::SET\s+CHAPTER\s+(.*)/, ord) {
if (ord[1] != "END") {
print " - [[", meta["BOOKCHAPTER"], " ", ord[1], "]]" >> kjv_toc
}
}
# end TOC

# flush signal, print chapter
/^:::SET\s+CHAPTER\s.*/ {
if (length(verses) > 0) {
of = current["BOOKCHAPTER"] " " current["CHAPTER"] ".md";
if (length(previous)!=0) {
print "- Previous:: [[", previous["BOOKCHAPTER"], " ", previous["CHAPTER"], "]]" >> of
}
if (meta["CHAPTER"]!="END") {
print "- Next:: [[", meta["BOOKCHAPTER"], " ", meta["CHAPTER"], "]]" >> of
}
print "- Tags:: #Bible #KJV #[[", current["BOOK"], "]]" >> of
for (i = 1; i <= length(verses); i++) {
print "- ", verses[i] >> of
}
delete verses

acopy(current, previous)
delete current
}
}

/^:::.*/ { next }

# push a verse
{ verses[length(verses)+1]=$0 }
1 change: 1 addition & 0 deletions test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
output/
5 changes: 5 additions & 0 deletions test/expected/1 Testing 1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Next:: [[1 Testing 2]]
- Tags:: #Bible #KJV #[[1 Testing]]
- 1 THIS is the first verse of chapter 1
- 2 A second verse
- > a footnote
6 changes: 6 additions & 0 deletions test/expected/1 Testing 2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- Previous:: [[1 Testing 1]]
- Next:: [[Psalm 1]]
- Tags:: #Bible #KJV #[[1 Testing]]
- **a non-verse heading**
- 1 A second chapter verse
- 2 A second chapter second verse
3 changes: 3 additions & 0 deletions test/expected/A Book 1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Previous:: [[Psalm 1]]
- Tags:: #Bible #KJV #[[A Book]]
- 1 Not much more to go
8 changes: 8 additions & 0 deletions test/expected/KJV.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- [[Test Testament]]
- [[1 Testing]]
- [[1 Testing 1]]
- [[1 Testing 2]]
- [[Psalms]]
- [[Psalm 1]]
- [[A Book]]
- [[A Book 1]]
6 changes: 6 additions & 0 deletions test/expected/Psalm 1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- Previous:: [[1 Testing 2]]
- Next:: [[A Book 1]]
- Tags:: #Bible #KJV #[[Psalms]]
- 1 Verse the first
- 2 Verse the second
- 3 Verse the third
23 changes: 23 additions & 0 deletions test/fixture.input
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
:::SET TESTAMENT Test
:::SET BOOK 1 Testing
:::SET TITLE The First Test General of Testing
:::SET CHAPTER 1
1 THIS is the first verse of chapter 1
2 A second verse
> a footnote
:::SET CHAPTER 2
**a non-verse heading**
1 A second chapter verse
2 A second chapter second verse
:::SET BOOK Psalms
:::SET TITLE Book Of Psalms
:::SET BOOKCHAPTER Psalm
:::SET CHAPTER 1
1 Verse the first
2 Verse the second
3 Verse the third
:::SET BOOK A Book
:::SET TITLE A Book
:::SET CHAPTER 1
1 Not much more to go
:::SET CHAPTER END
10 changes: 10 additions & 0 deletions test/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -euo pipefail

pushd test/output
rm -f *.md
../../generate.awk ../fixture.input
popd

diff -bur test/expected test/output

0 comments on commit c10dc89

Please sign in to comment.