Organising The Bible in Obsidian

In case it’s useful to anyone else, here is my substitution command for converting a “regular Scripture reference” to a wiki link Scripture reference using vim:

:%s/\v( ?[1-3]? [A-Z][a-z]*) ([0-9][0-9]?[0-9]?:[0-9][0-9]?-?[0-9]?[0-9]?)/ [[\1#\2]]/g

The above will sometimes leave an extra space after the opening [[ so then I run this to remove that:

:%s/\[\[ /[[/g

I typically run this while editing multiple files, something like vim notes/*.md and then use bufdo to run the substitutions on all the files at once and save to disk.

:bufdo execute '%s/\v( ?[1-3]? [A-Z][a-z]*) ([0-9][0-9]?[0-9]?:[0-9][0-9]?-?[0-9]?[0-9]?)/ [[\1#\2]]/g' | update

and then:

:bufdo execute ':%s/\[\[ /[[/g' | update

For reference, the above turns text like this:

Paul refers to Genesis 15:6 in Galatians 3:6.

1 John 4:5 and 2 Chronicles 7:11 and also Psalm 119:9-11

into text like this:

Paul refers to [[Genesis#15:6]] in [[Galatians#3:6]].

[[1 John#4:5]] and [[2 Chronicles#7:11]] and also [[Psalm#119:9-11]].

Of course, if you use a similar reference syntax for anything else the above commands will convert them as well. It does not convert Galatians 4 or Galatians.

To round out the setup I have, I’m using 1 file per book for Scripture, like this:

Ephesians

Chapter 1

Paul Addresses The Ephesians
1:1

Paul, an apostle of Christ Jesus by the will of God,
To the saints who are in Ephesus, and are faithful in Christ Jesus:

1:2

Grace to you and peace from God our Father and the Lord Jesus Christ.

Overall, this is really suiting my use case, which is mostly speaking notes with references into my mobile app while studying Scripture. These are pushed into a private Github repository which Obsidian then pulls down on startup. I think the next step for me is to automate the reference conversion, maybe via a git hook on my repository so that the references get linkified before a commit.

2 Likes

Nice work! Any chance of turning that into a plug-in that us mere mortals could execute by setting up a hot key for it?

2 Likes

I see in 0.9.18 that CSS snippets are going to be officially supported. That seems like it would be an ideal way to set up the override for any theme. What do you think?

Here is at least a one line script you could run on the command line, only tested on a Mac:

gsed -i -e 's/\([1-3]\? \?[A-Z][a-z]*\) \([0-9][0-9]\?[0-9]\?:[0-9][0-9]\?-\?[0-9]\?[0-9]\?\)/ \[\[\1#\2\]\]/g' -e 's/\[\[ /\[\[/g' *.md

That will run the substitution on any file ended in .md in the current working directory.

1 Like

I went ahead and created a pre-commit script that I thought I’d share in case anyone else is using git for their Obsidian vault and wants to try it out. The script is more complicated now but also more precise since I’m explicitly listing the full name of each book. I also updated it to work for chapter only references, like “Genesis 12”.

I uploaded the file as a gist here: https://gist.github.com/jag3773/5797912d1fc6616e55af88a6d10c6d41

Note that you’ll need to download that file to the .git/hooks/ directory in your vault’s git repository and make sure it is executable. Once in place it will run every time you do a commit in your repo.

I’m using the Obsidian Git plugin which I have set to auto commit every 2 minutes and this seems to be working well.

1 Like

I thought I’d share the method I’ve been using for Bible Notes. I use @Lithou 's method for having one note per chapter and then headings for paragraphs and I’ve loved that! The thing I added to it, is I tag each paragraph with the themes I recognize to better help me find verses in the future when I’m writing my sermons or study notes on topics. I also tend to just paste the whole chapter from biblestudytools.com and then format it, instead of using a script that’s above my technical level.

5 Likes

Thank @Lithou and @Chaulk5 for sharing your approaches. I am amazed by the responses in this whole thread.

To make it easy to find different approaches and snippets for newcomers, I’ll edit the first post into a summary. → Summary here!
For reference, I’ll repost my original first post here though:

First Post

I just finished writing a script to import the Bible into Obsidian.

Before I start importing over 700 000 words into Obsidian, I am thinking about how to organise this book. The Bible is structured in Books, Chapters, Verses. My initial thought is to create a Note for each book with a ## Heading for each Chapter and a ### Header for each verse.
That makes referencing and embedding possible without cluttering the graph in an excessive way.

I would be interested to hear thoughts on how to organise this amount of information while being able to easily embed, read and backlink to it.


An example note containing a book of the Bible:

A verse embedded:

3 Likes

I am close with this CSS running as a css-snippet on the Minimal theme, but I can’t get the spacing between the embedded verses to collapse to zero. The goal is to have two verses embedded on the same line (e.g., ![[Titus 1#1]] ![[Titus 1#2]]) show up as a single embed, with no space between them. Any ideas? The goal is a CSS snippet that accomplishes a display for Minimal (and possibly other themes) like what @Lithou developed here.

.markdown-preview-sizer
{ 
  padding-left: 40px;
  padding-right: 20px;
  nested-padding: 0;
}

.markdown-preview-view h6
{
  position: relative;
  left: -6%;
  top: 23px;
  line-height: 0px;
  margin-top: -18px;
  font-family: var(--font-family-preview);
  font-weight: 500;
  font-size: 10px;
  font-weight: bold;
  color: var(--text-faint) !important;
}

So I want to understand what you are going for here. If I load up minimal theme with your snippets there then this in edit mode:

Yields this in preview mode:

Is the problem just margins being too large? and you want less empty space between the lines? Something like this:

Mostly the issue you are running into is your positioning of the verse headers. You have them as position: relative which allows the you to move it relative to where it would normally be in the flow. That normal spot where it was still exists and takes up space which causes the containers to be taller.
If you use position: absolute, however, the element is removed from the normal flow and no longer affects the positioning or sizes of the other elements.

Here is the snippet I used for the example above. (You can adjust the distance from the top/left to suit your own visual style):

.markdown-preview-view h6 {
  position: absolute;
  left: 5px;
  top: 1px;
  margin: 0px;
}

The other thing to keep in mind is that the first paragraph (<p>) element will have extra margin on the top so setting that to zero will also move things tighter. You can do this with:

.markdown-preview-view .markdown-embed-content p:first-child {
    margin: 0px;
}

You also have your links going across the whole first line. You can change the width and position if you want or you can hide them if you want with a visibility attribute.

div.markdown-embed-link {
    visibility: hidden;
}

Let me know if you have any questions.

2 Likes

So I used @Lithou’s code suggestions and embedded verses now work like a charm.
However, in normal preview mode all verse numbers are now crowded in the upper left corner, as seen below:

I understand that preview-view and embed-view are somehow connected and the issue is due to the absolute position of h6.

If I once again copy in my previous code for preview h6 then the verse numbers in the embed will again be effected.

.markdown-preview-view h6 {
position: relative;
left: -3%;
top: 26px;
line-height: 0px;
margin-top: -20px;
margin-right: 0px;

Any suggestions?
Thanks.

Joe,

This issue has to do with how CSS rules are run.

CSS rules cascade according to specificity. The rule that is more specific will take precedence over one that is less specific. If two rules have the same level of specificity, then the latter one will take precedence.

With the code above it will affect any H6 that is inside a preview-view box. This will apply to anything in preview mode. In order to only apply to H6 elements inside an embed, you will want two rule sets. One less specific that effects all preview H6 elements. Then one more specific that effects all H6 elements inside embedded content.

There is already a general rule in the minimal theme so if you like that then no need to change it. If you want to change it you can create a selector as below:

.markdown-preview-view h6 {
    CSS for all H6 preview elements goes here
 }

Then to make a more specific rule for the embedded H6 elements:

div.markdown-embed .markdown-preview-view h6 {
    position: absolute;
    left: 5px;
    top: 1px;
    margin: 0px;
  }

If you only use this second rule and use minimal theme as your general rule it looks like this:

For reference, here’s the entire snippet:

div.markdown-embed .markdown-preview-view h6 {
    position: absolute;
    left: 5px;
    top: 1px;
    margin: 0px;
  }

.markdown-preview-sizer
{ 
  padding-left: 40px;
  padding-right: 20px;
}

.markdown-preview-view .markdown-embed-content p:first-child {
    margin: 0px;
}

div.markdown-embed-link {
    visibility: hidden;
}
3 Likes

Lithou,
thanks a lot! Now it works :upside_down_face:

Great work, @Lithou and thanks! This works as expected. One final question: what is the selector (and CSS) to slightly adjust the background color of the embed? In light mode, the background should be darkened… It might need to be lightened in dark mode. Any suggestions?

Any clue why the PDF export of embedded verses includes so much spacing before and after? This embed code (displayed in Obsidian using the CSS from your post above):

...passages are included verbatim. The outline is based on Luke's "six books" structure of Acts, showing the progressive completion of the Acts 1:8 mandate:

![[Acts 1#1:8]]

## Context of Acts

exports like this:

Just to add to the conversation with a different, albeit less elegant and organized, method that I’ve decided to use.

I set up a Keyboard Maestro workflow that basically does the following:

  1. I type /ref(space) to add in ![[]] enabling me to type my reference, James 1.12-14 for example. If it has been added already it’ll pop up, if not I continue.
  2. Highlight the link and press the hotkey to run the workflow. The workflow copies the text, creates a new Obsidian page, pastes the text as the note title, replaces the . with a : and adds that as an alias.
  3. the workflow then switches over to Accordance Bible Software and searches for the verse. I highlight and copy the verse and the workflow waits until I shift-tab back to Obsidian. It then pastes the content into the new page. From there I just close out the new page and the reference is shown without flaw.

Like I said, this is much less elegant and I don’t have the entire Bible in my vault, only select verses. However, by leaving Accordance open the entire time I’m doing my study, the process to create a new reference takes all of 7 seconds. I had to tinker a little bit with Accordance, but since I tried multiple ways to even import the Bible in markdown and failed, this turned out to be the easiest, quickest, and most frictionless process for me personally.

P.S. Because the /ref hotkey and the verse-finder hotkey are separate, the verse-finder works even when simply creating a new verse page. I use the same workflow for cross-references in footnotes, only using /foot to insert ^[ ![[]] ] instead of ![[]].

P.S.S. I would not use this workflow if I needed the verses to be organized. I keep all of my references in a “Bible References” folder and there is absolutely no rhyme or reason to their order. However, I’m not reading the Bible through Obsidian, only using Obsidian as a tool for notes, so for me the organization doesn’t matter. I don’t even look in that folder.

Hey, @tward09 I noticed you used Accordance and KBM.

Further up in that thread, I posted two comments about an Applescript I use to capture verse references directly from Accordance using TextExpander. The same could be done using KBM. It didn’t get much attention from folks when I first posted the script but maybe the Applescript might help you in your workflow.

Here are my comments about the Applescript and the workflow I use if you are interested.

https://forum.obsidian.md/t/organising-the-bible-in-obsidian/1490/11?u=mik
https://forum.obsidian.md/t/organising-the-bible-in-obsidian/1490/14?u=mike

Good luck to you!
@Mike

2 Likes

Hey @Mike - I think it was your comment that made me check out Accordance in the first place! I’ll definitely take a look at the scripts. Thanks!

The issue there is that the render puts in several line returns which are normally hidden via CSS. When the export to pdf happens, it adds back in the original space. As the pdf export gets better options, it should resolve the problem.

I use e-sword. I’m wondering if anyone else has had a chance to convert the topx / notex files into something md-like. It’d be cool to have a tie-in to e-sword since it’s so powerful. Even the possibility of importing my old topic notes into Obsidian would make me a happy camper. Of course, I know there’s a million different bible software out there, so doing it just for one would be pointless, but maybe finding a workflow that would support several at one blow would be nice. Then, we could have a list of “suggested software” that could be used. (E-sword is at www.e-sword.net)

1 Like

Yes I too use e-sword and would really like the compatibility.

1 Like