GithubHelp home page GithubHelp logo

alphapapa / sword-to-org Goto Github PK

View Code? Open in Web Editor NEW
34.0 6.0 5.0 78 KB

Convert Sword modules to Org-mode outlines

License: GNU General Public License v3.0

Emacs Lisp 100.00%
emacs org-mode bible esword

sword-to-org's Introduction

sword-to-org

This package uses =diatheke= to convert Sword modules to Org-mode outlines. For example, you can make an Org file containing the entire text of the ESV module as an outline structured by book/chapter/verse. Then you can add top-level headings for Old/New Testaments, and then you have the whole Bible as an Org file. Then you can do everything you can do in Org with the text of the Bible! Add footnotes, links, tags, properties, write your own commentaries under subheadings, organize research with TODO items, export with org-export, search with helm-org-rifle, etc. The list is endless.

screenshot.png

Usage

First install =diatheke=. On Debian/Ubuntu it’s in the diatheke package.

Open a buffer and run the command sword-to-org-insert-outline. Choose the module (e.g. Bible translation) to use, then input a passage reference or range (e.g. Gen 1, Jn 1:1, or even Gen-Rev —that last one will take a few moments), and an Org outline will be inserted in book/chapter/verse/text structure. Call the command with a universal prefix (C-u) to choose a different module.

The command sword-to-org-insert-passage inserts a passage as plain text with one-verse-per-line. Use prefix arguments to choose a different Sword module, and a double-prefix argument to insert as a single paragraph with reference at the end.

You may customize sword-to-org-default-module so you don’t have to pick a module every time.

You may also use any of the sword-to-org-- support functions in your own programs. Consult the docstrings for instructions and examples.

Export with Org Babel code block and macro

By including this code in your Org file, you can easily insert passages when exporting:

#+MACRO: refPara #+CALL: Diatheke(ref=$1, paragraph="t")
#+MACRO: refLines #+CALL: Diatheke(ref=$1, paragraph="")

#+NAME: Diatheke
#+BEGIN_SRC emacs-lisp :var ref="" paragraph="" :exports results :results raw
  (concat "#+BEGIN_QUOTE" "\n"
          (sword-to-org--passage ref :paragraph (s-present? paragraph))
          (when (s-present? paragraph)
            (concat "  (" ref ")")) "\n" 
          "#+END_QUOTE" "\n")
#+END_SRC

Now you can use macros to insert references, like this:

John explains that Jesus was with God in the beginning:

{{{refPara("John 1:1-3")}}}

And that Jesus is victorious:

{{{refLines("John 1:4-5")}}}

Which is exported as:

John explains that Jesus was with God in the beginning:

      In the beginning was the Word, and the Word was with God,
      and the Word was God. He was in the beginning with God. All
      things were made through him, and without him was not any
      thing made that was made.  (John 1:1-3)

And that Jesus has conquered darkness:

      John 1:4 In him was life, and the life was the light of men.

      John 1:5 The light shines in the darkness, and the darkness
      has not overcome it.

Development

Contributions are welcome!

Ideas

MAYBE Rename, expand

Might want to rename to, say, org-sword, and add commands to search diatheke for keywords, etc.

Credits

  • Thanks to Syohei YOSHIDA and Steve Purcell for their tireless work curating MELPA.
  • Thanks to @clyde100 for reporting a bug in the parsing and inspiring the insert-passage command and the Babel/export code above.

License

GPLv3

sword-to-org's People

Contributors

alphapapa avatar dakrone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

sword-to-org's Issues

Parsing Issues when using KJV modules

When using KJV modules, verses are being "missed". This is caused by how diatheke outputs verses that contain pilcrow symbols in the OSIS milestone element. This is not an issue that occurs when using ESV modules, so probably was not experienced during testing.

Executing "diatheke -b KJV -k John 1:1-8" in a terminal window will show the John 1:6 reference on one line and its text on the following line. This verse has a pilcrow symbol. Executing (sword-to-org-insert-outline "KJV" "John 1:1-8") in an org-mode buffer will result in John 1:6 "missing" in the generated output. It is actually appended to the end of John 1:5's text.

Calling diatheke as follows: diatheke -b KJV -f OSIS -k John 1:1-8 | perl -pe 's/<.*?>//'
will result in every verse being available with the same output format.

I have added "-f OSIS" to the call-process sexps and proven that all the verses appear as expected in the org-mode buffer (albeit with all the OSIS related markup). I don't have the elisp chops needed to properly add something, as suggested via my google-fu, like: (while (re-search-forward "<.*?>" nil t) (replace-match "")) in the right location.

I did a quick search through the diatheke source code, but couldn't locate the code causing the pilcrow related issue to begin with, so I think for now this is the best solution.

Thank you for your initial work on this module.

sword-to-org-insert-outline; many lines have "David's Psalm of Praise." appended

Invoking Gen-Rev as option for sword-to-org-insert-outline results in muddled output?

Sword 1.9.0, Diatheke 4.8

Sample:

**** Revelation of John 18:10

Standing afar off for the fear of her torment, saying, Alas, alas, that great city Babylon, that mighty city! for in one hour is thy judgment come.David's Psalm of praise.

**** Revelation of John 18:11

And the merchants of the earth shall weep and mourn over her; for no man buyeth their merchandise any more:David's Psalm of praise.

Possible support for sword module add ins?

Dear Alphapapa,

Many thanks for this package, it's really helpful! (Your org-web-tools is also a lifesaver)

Best thing about .org format bibles is that backlinks (in the context of org-brain or org-roam) means when I view a verse or chapter I can see where else it was referenced.

I hope I'm not being too greedy when I ask if it's possible to support .bdt files. Ex. The module I have in mind is from: http://crosswire.org/sword/modules/ModInfo.jsp?modName=AquinasSummaTheologica&tester=true&beta=true

An excerpt:
<title type="x-h4" osisID="ii.i.i.i.p0.1">Whether, besides philosophy, any further doctrine is required?</title>

<p osisID="ii.i.i.i.p1"/>

<p osisID="ii.i.i.i.p2">Objection 1: It seems that, besides philosophical science, we have no need of any further knowledge. For man should not seek to know what is above reason: "Seek not the things that are too high for thee" (<reference type="annotateRef" osisID="ii.i.i.i.p2.1" osisRef="Bible.VUL:Ecclus.3.22">Ecclus. 3:22</reference>). But whatever is not above reason is fully treated of in philosophical science. Therefore any other knowledge besides philosophical science is superfluous.</p>

I checked through some other sword modules and it does seem the majority are in .bzs, .bzv etc. So I understand that my use case is uncommon. I confess I do not have any elisp skills, so perhaps you are the right person to ask. I did try dtk.el from this issue #4 List related projects including dtk, but it seems like .bdt doesn't show up when using their select module function.

It's no big deal if it's not possible. Still happy to have the content, having nice headers is really just a nice extra. Thanks for your time.

Best,

Hanshen

Verse references incorrectly contain Strong's Numbers, Greek, etc.

Hi, thanks for this package. I especially like the export with linked verses.

I'm experiencing a strange issue where the Bible verse(s) printed by sworg-to-org-insert-outline produce a ridiculously long printed text with Strong's numbers, Greek, etc. Below is the results of M-x sword-to-org-insert-outline [RET] John 1:1-3 [RET]. Does anyone have a clue why this would be?

I'm on MacOS Monterey (M1) with diatheke installed via brew install sword.

* John

** John 1

*** John 1:1

<w  savlm="strong:G1722 lemma.TR:εν" src="1">In</w> <w  savlm="strong:G746 lemma.TR:αρχη" src="2">the beginning</w> <w  savlm="strong:G2258 lemma.TR:ην" src="3">was</w> <w  savlm="strong:G3588 strong:G3056 lemma.TR:ο lemma.TR:λογος" src="4 5">the Word</w>, <w  savlm="strong:G2532 lemma.TR:και" src="6">and</w> <w  savlm="strong:G3588 strong:G3056 lemma.TR:ο lemma.TR:λογος" src="7 8">the Word</w> <w  savlm="strong:G2258 lemma.TR:ην" src="9">was</w> <w  savlm="strong:G4314 lemma.TR:προς" src="10">with</w> <w  savlm="strong:G3588 strong:G2316 lemma.TR:τον lemma.TR:θεον" src="11 12">God</w>, <w  savlm="strong:G2532 lemma.TR:και" src="13">and</w> <w  savlm="strong:G3588 strong:G3056 lemma.TR:ο lemma.TR:λογος" src="16 17">the Word</w> <w  savlm="strong:G2258 lemma.TR:ην" src="15">was</w> <w  savlm="strong:G2316 lemma.TR:θεος" src="14">God</w>.

*** John 1:2

<w  savlm="strong:G3778 lemma.TR:ουτος" src="1">The same</w> <w  savlm="strong:G2258 lemma.TR:ην" src="2">was</w> <w  savlm="strong:G1722 lemma.TR:εν" src="3">in</w> <w  savlm="strong:G746 lemma.TR:αρχη" src="4">the beginning</w> <w  savlm="strong:G4314 lemma.TR:προς" src="5">with</w> <w  savlm="strong:G3588 strong:G2316 lemma.TR:τον lemma.TR:θεον" src="6 7">God</w>.

*** John 1:3

<w  savlm="strong:G3956 lemma.TR:παντα" src="1">All things</w> <w  savlm="strong:G1096 lemma.TR:εγενετο" src="4">were made</w> <w  savlm="strong:G1223 lemma.TR:δι" src="2">by</w> <w  savlm="strong:G846 lemma.TR:αυτου" src="3">him</w>; <w  savlm="strong:G2532 lemma.TR:και" src="5">and</w> <w  savlm="strong:G5565 lemma.TR:χωρις" src="6">without</w> <w  savlm="strong:G846 lemma.TR:αυτου" src="7">him</w> <w  savlm="strong:G1096 lemma.TR:εγενετο" src="8" type="x-split-1772">was</w> <w  savlm="strong:G3761 lemma.TR:ουδε" src="9">not</w> <w  savlm="strong:G1520 lemma.TR:εν" src="10">any thing</w> <w  savlm="strong:G1096 lemma.TR:εγενετο" src="8" type="x-split-1772">made</w> <w  savlm="strong:G3739 lemma.TR:ο" src="11">that</w> <w  savlm="strong:G1096 lemma.TR:γεγονεν" src="12">was made</w>.

Installation and MELPA

It is not really a issue, but a suggestion of putting this package in MELPA,
and writing better instructions on how to install it in emacs init.el
Also, how to export a Greek Bible passage into a PDF file?
Have some example?
Thx for this really useful tool...

insert mechanisms yield xml-like markup rather than plain text

The sword-to-org-insert-* mechanisms insert the content as xml-like markup[fn:1]. The -outline method does indeed make an org outline with headlines and subtrees, but the content for each verse is markup[fn:1] rather than plain text.

Do you have any trips for troubleshooting and solving?

Thank you.

[fn:1] James 1:1 using sword-to-org-insert-passage from KJVA module yields:
James, a servant of God and of the Lord Jesus Christ, to the twelve tribes which are scattered abroad, greeting. (James 1:1)

Cannot find diatheke - Win10

Is there a way to hard code a path to diatheke in your code? It cannot find it even though I installed it with Xiphos and also copied it to several directories that are in the path and then created a directory for it with its own path. Its a windows thing of course. Perhaps if it had a stated path like "c:/sword/diatheke.exe", my problem would be solved.
Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.