aygjiay / obsidian-link-to-verse

MIT License
3 stars 0 forks source link

Olive Tree deep linking #1

Open tryonkus opened 1 week ago

tryonkus commented 1 week ago

The Olive Tree Bible study app supports deep linking to any verse with the following format: https://github.com/OliveTreeBible/OliveTreeUrlExample

I am trying to configure Link to Verse with the following template: olivetree://bible/{{verse}}

There are a few issues with this:

Would it be possible to support this format or add book, chapter, and verse number tokens in the template?

aygjiay commented 1 week ago

I can create a new release to support a template based on book chapter verse as follows:

olivetree://bible/{{book}}.{{chapter}}.{{verse`}}

Supporting the spaces encoding in the book name.

But it is important to clarify that version or verse ranges won't be supported for this template. One possible work around is that whenever a verse range is found, Link Verse to create a link to the first verse of the range.

Let me know if that works for your needs.

tryonkus commented 1 week ago

I don’t believe Olive Tree urls support versions or verse ranges, so that won’t be an issue. They function more like bookmarks at a particular verse. I’d love if they would enhance their URL support, but I don’t expect that to be a high priority—they are working on a complete rewrite to build both the Mac and iOS apps from a single code base (I’ve been on the beta). I did ask if they could provide a right click function to grab the URL of the current verse.

If you could encode spaces as %20, that would be very helpful. I also found a plugin that does just that—fixes spaces in urls: obsidian://show-plugin?id=markdown-link-space-encoder

FYI, found these with this search: https://www.google.com/search?q=verse+parser

I also created a Templater template which will work with most references.

<%*  
// Prompt for series title  
const reference = await tp.system.prompt('Reference');  

// Build link components  
// Start with leading digit, if it exists  
let book = reference.match(/^\d?/);  
// Add %20 if leading digit exists  
if (reference.match(/^\d/)) {  
  book = book + '%20';  
};  
// Add alpha portion of book name  
// (?<=^\d? ?) skips 0-1 digits and 0-1 spaces at the beginning of the string  
book = book + reference.match(/(?<=^\d? ?)[A-z]+/);
// Skip digit, space, and characters up to a digit
let chapter = reference.match(/(?<=^\d? ?.+)\d+/);
//skip digit, space and characters including a colon
let verse = reference.match(/(?<=^\d? ?.+:)\d+/);  

// Build link  
%>[<% reference %>](olivetree://bible/<% book %>.<% chapter %>.<% verse %>) 

I assigned it to a hotkey, and it will prompt for a reference and build the Olive tree link.

aygjiay commented 1 week ago

Just pushed a new version 1.1.0 supporting the Olive Tree template. Give it a try and let me know how it works for you. I also updated the documentation—apologies for the misunderstanding about how the plugin works. To use it, first select text in the note, which the plugin will then use as input. Because of this, there’s no pop-up asking for text. A modal may be added in a future release, but it's not supported at the moment.

tryonkus commented 1 week ago

Thanks so much for doing this--I was able to get the plugin to work once I read the updated documentation. I'd used it before and forgotten that was how it worked. A few notes:

aygjiay commented 1 week ago

New version available 1.1.1

[
  { "bookName": "Genesis", "abbreviations": ["Gen", "Ge", "Gn"] },
  { "bookName": "Exodus", "abbreviations": ["Exod", "Ex"] },
  { "bookName": "Leviticus", "abbreviations": ["Lev", "Lv", "Le"] },
  { "bookName": "Numbers", "abbreviations": ["Num", "Nm", "Nu"] },
  { "bookName": "Deuteronomy", "abbreviations": ["Deut", "Dt", "De", "Du"] },
  { "bookName": "Joshua", "abbreviations": ["Josh", "Jos", "Jo"] },
  { "bookName": "Judges", "abbreviations": ["Judg", "Jdg", "Jgs"] },
  { "bookName": "Ruth", "abbreviations": ["Ruth", "Ru"] },
  { "bookName": "1 Samuel", "abbreviations": ["1 Sam", "1Sm", "1Sa"] },
  { "bookName": "2 Samuel", "abbreviations": ["2 Sam", "2Sm", "2Sa"] },
  { "bookName": "1 Kings", "abbreviations": ["1 Kgs", "1Kg", "1Ki"] },
  { "bookName": "2 Kings", "abbreviations": ["2 Kgs", "2Kg", "2Ki"] },
  { "bookName": "1 Chronicles", "abbreviations": ["1 Chr", "1 Chron", "1Ch"] },
  { "bookName": "2 Chronicles", "abbreviations": ["2 Chr", "2 Chron", "2Ch"] },
  { "bookName": "Ezra", "abbreviations": ["Ezra", "Ezr"] },
  { "bookName": "Nehemiah", "abbreviations": ["Neh", "Ne"] },
  { "bookName": "Tobit", "abbreviations": ["Tob", "Tb"] },
  { "bookName": "Judith", "abbreviations": ["Jdt", "Jth"] },
  { "bookName": "Esther", "abbreviations": ["Esth", "Est", "Es"] },
  { "bookName": "1 Maccabees", "abbreviations": ["1 Macc", "1Mc", "1Ma"] },
  { "bookName": "2 Maccabees", "abbreviations": ["2 Macc", "2Mc", "2Ma"] },
  { "bookName": "Job", "abbreviations": ["Job", "Jb"] },
  { "bookName": "Psalms", "abbreviations": ["Ps", "Pss"] },
  { "bookName": "Proverbs", "abbreviations": ["Prov", "Prv", "Pr"] },
  { "bookName": "Ecclesiastes", "abbreviations": ["Qoheleth", "Eccl", "Eccles", "Ec", "Qoh"] },
  { "bookName": "Song of Songs", "abbreviations": ["Song of Solomon", "Canticle of Canticles", "Song", "SS", "So", "Sg", "Cant", "Can"] },
  { "bookName": "Wisdom", "abbreviations": ["Wisdom of Solomon", "Wis", "Ws"] },
  { "bookName": "Sirach", "abbreviations": ["Ecclesiasticus", "Sir", "Ecclus"] },
  { "bookName": "Isaiah", "abbreviations": ["Isa", "Is"] },
  { "bookName": "Jeremiah", "abbreviations": ["Jer", "Je"] },
  { "bookName": "Lamentations", "abbreviations": ["Lam", "La"] },
  { "bookName": "Baruch", "abbreviations": ["Bar", "Ba"] },
  { "bookName": "Ezekiel", "abbreviations": ["Ezek", "Ezk", "Ez"] },
  { "bookName": "Daniel", "abbreviations": ["Dan", "Dn", "Da"] },
  { "bookName": "Hosea", "abbreviations": ["Hos", "Ho"] },
  { "bookName": "Joel", "abbreviations": ["Joel", "Joe", "Jl"] },
  { "bookName": "Amos", "abbreviations": ["Amos", "Am"] },
  { "bookName": "Obadiah", "abbreviations": ["Obad", "Ob"] },
  { "bookName": "Jonah", "abbreviations": ["Jonah", "Jon"] },
  { "bookName": "Micah", "abbreviations": ["Mic", "Mi"] },
  { "bookName": "Nahum", "abbreviations": ["Nah", "Na"] },
  { "bookName": "Habakkuk", "abbreviations": ["Hab", "Hb"] },
  { "bookName": "Zephaniah", "abbreviations": ["Zeph", "Zep"] },
  { "bookName": "Haggai", "abbreviations": ["Hag", "Hg"] },
  { "bookName": "Zechariah", "abbreviations": ["Zech", "Zec"] },
  { "bookName": "Malachi", "abbreviations": ["Mal", "Ml"] },
  { "bookName": "Matthew", "abbreviations": ["Matt", "Mat", "Mt"] },
  { "bookName": "Mark", "abbreviations": ["Mark", "Mar", "Mk"] },
  { "bookName": "Luke", "abbreviations": ["Luke", "Lk", "Lu"] },
  { "bookName": "John", "abbreviations": ["John", "Jn", "Jo"] },
  { "bookName": "Acts", "abbreviations": ["Acts of the Apostles", "Acts", "Ac"] },
  { "bookName": "Romans", "abbreviations": ["Rom", "Rm", "Ro"] },
  { "bookName": "1 Corinthians", "abbreviations": ["1 Cor", "1 Co", "1C"] },
  { "bookName": "2 Corinthians", "abbreviations": ["2 Cor", "2 Co", "2C"] },
  { "bookName": "Galatians", "abbreviations": ["Gal", "Ga"] },
  { "bookName": "Ephesians", "abbreviations": ["Eph", "Ep"] },
  { "bookName": "Philippians", "abbreviations": ["Phil", "Php"] },
  { "bookName": "Colossians", "abbreviations": ["Col", "Co"] },
  { "bookName": "1 Thessalonians", "abbreviations": ["1 Thess", "1 Thes", "1Th"] },
  { "bookName": "2 Thessalonians", "abbreviations": ["2 Thess", "2 Thes", "2Th"] },
  { "bookName": "1 Timothy", "abbreviations": ["1 Tim", "1 Tm", "1 Ti", "1T"] },
  { "bookName": "2 Timothy", "abbreviations": ["2 Tim", "2 Tm", "2 Ti", "2T"] },
  { "bookName": "Titus", "abbreviations": ["Titus", "Tit", "Ti"] },
  { "bookName": "Philemon", "abbreviations": ["Phlm", "Philem", "Phm"] },
  { "bookName": "Hebrews", "abbreviations": ["Heb", "He"] },
  { "bookName": "James", "abbreviations": ["Jas", "Ja"] },
  { "bookName": "1 Peter", "abbreviations": ["1 Pet", "1 Pt", "1P"] },
  { "bookName": "2 Peter", "abbreviations": ["2 Pet", "2 Pt", "2P"] },
  { "bookName": "1 John", "abbreviations": ["1 John", "1 Jn", "1 Jo", "1J"] },
  { "bookName": "2 John", "abbreviations": ["2 John", "2 Jn", "2 Jo", "2J"] },
  { "bookName": "3 John", "abbreviations": ["3 John", "3 Jn", "3 Jo", "3J"] },
  { "bookName": "Jude", "abbreviations": ["Jude", "Ju"] },
  { "bookName": "Revelation", "abbreviations": ["Revelation to John", "Apocalypse", "Rev", "Re", "Rv", "Apoc", "Ap"] },
]
tryonkus commented 1 week ago

Thanks again for the changes—I’m a bit too good at breaking stuff. 😏 I agree that keeping validation off will work best for Olive Tree, unless they fix that bug.

As an FYI, Olive tree and some online Bibles allow the book to be encoded as an integer corresponding with its position in the TOC. I don’t know if this works with apocryphal or deuterocannonical books or if it works with the Tanakh or Septuagint, which have different book orders. You might consider an option to validate the books and map them onto the appropriate numbers. This would allow the link display to be correct while using the simpler numeric URLs.

Some similar plugins prompt with a list once enough of the reference has been entered, but requires an interface based on either a hot key or special character triggering a prompt—wouldn’t work on selected text like your plugin. These both work around the URL format issue by supporting only one Bible site or sites chosen from a list. They will also preview or pull the text into the Obsidian note, which they can do because they know how those sites are formatted. I don't believe there is any way to return a value from Olive Tree.

You may already be familiar with these—just thinking they might give you some good ideas. https://github.com/tim-hub/obsidian-bible-reference https://github.com/jaanonim/obsidian-youversion-linker