How I use Wiki-Links and Aliases (pt.2)

You might want to take a look at pt. 1 and later on at pt.3.

All classical texts have a numbering system to allow for precise referencing regardless of the translation one is using. (A popular exemple of this is the Bible). This system refers to the edition of the original text in the original language (e.g. greek, latin, sanskrit, syriac and so forth) (in the case of the Bible, or at least the NT, the numbering refers to the edition of the greek text).

The universal referencing system for Aristotle’s texts is the numbering present in the 1834 edition of the greek text by a German fellow named Immanuel Bekker. This system follows a continuous numbering from 1 up to round 1500, which are the pages in this edition, while each page, in turn, is divided in two columns (“a” and “b”).

What this means for me, is that whenever I am writing an academic paper and want to reference some line of text, I have to indicate the exact page, column and line where it can be found. So I will probably end up with something like 1094a13 - 15 (page 1094, column a lines 13 thru 15).

How this comes into play in DEVONthink…

Over the past few months, I have been laboriously and meticulously gathering all of Aristotle’s texts in plain text files and splitting them up into smaller thematic units, usually following a different division one can find, that is, of the texts into works, books and chapters (books here is the ancient book, which was a papyri roll and which is about the size of our modern day chapter).

Aristotle’s Historia Animalium: I.1 means book I, chapter 1.

Once I had this in place, my goal was to be able to have all my references to Aristotle’s text, following the Bekker system explained above, to automatically lead me, via Wiki-Links, towards the correct line of text (or at least, close enough to the correct line). In practice, this meant trying to turn the whole numbering system into aliases to the appropriate markdown files. Now, the Bekker system is perfect for fitting into an aliases scheme, seeing that there will never be a conflict. Had I been working mainly with Plato, that would have be different since each work has a numbering that starts back from 1a, instead of all of them being continuously numbered one after the other.

With the threat of conflict out of the way, it was just a matter of getting the Bekker numbering into the alias field for each md file (easier said than done!).

Now whenever I am writing, and using DT to do it (or at least indexing what I wrote with DT afterwards), I can be sure to waste no time checking to see if I referenced the correct passage in my paper and, likewise, to be never more than a click away from the appropriate context.

My goal with this post was to inspire different uses for the Wiki-Links and Aliases features. In an upcoming thread I will share the macros I used to perform the job of turning the numbering into aliases.


A fascinating read, @Bernardo_V. and very cool stuff :slight_smile:

1 Like

Thanks @Bernardo_V. This is giving me some ideas for future DT3 usages.

1 Like

I very much enjoy seeing expertise in areas where I have none. Thanks for sharing what you are doing, providing not only inspiration, but (for me) a brief look into something completely different!


Thanks for sharing more of the details @Bernardo_V ! Looking forward to the next part!

1 Like

Thank you for the sharing.
I have two questions:
(1) I guess all aliases have to be unique else the wiki-link won’t be able to pointing to the right reference file? How do you check whether you have wrong/duplicated aliases?
(2) Is there any performance issue (ie spinning beachballs) when you have accumulated a certain number of links?

Thanks in advance

Hi @ngan,


So far I will find that out only if I use the link and it takes me somewhere other than where I want.

No issues in this regard. I was expecting to have some, but it works like a charm. (I must say, however, that I decided to keep my Wiki with plain texts separated from my pdf files, but this was more due to clutter than anything else.)

Let me know if you have any other questions :slightly_smiling_face:

Thanks a lot for the valuable info!

1 Like


I try to use that and I saw it is fantastic.

My problem is, I input the first line manually in some of my files.

But now, I really want to have this first line in all files of a specific data database. I believe that I simple command could do that, but I do not know how to do that.

The line I wish to input as the first line in all files is:

V1MT | V2MC | V3LC | V4JO | V5AA | V6PA | V7CA

This script will do it.

tell application id "DNtp"
set theRecords to the selection
repeat with theRecord in theRecords

set theFirstLine to "V1MT | V2MC | V3LC | V4JO | V5AA | V6PA | V7CA"
the theText to the plain text of theRecord
set theText to theFirstLine & linefeed & linefeed & theText

set the plain text of theRecord to theText

end repeat
end tell

I’m interested in implementing something like this for legal texts (specifically, judicial opinions), which have unique citations assigned at publication (or, if only informally published, have unique identifiers assigned by the legal-research publisher). Generally, the citation will be written somewhere at the beginning of the PDF of the text and follows a definite format that can be found using RegEx. But where I get stuck is making the citation an alias for the text so that [[citation]] will link me back to the text when I use it elsewhere in my writing.

Any ideas for automatically finding the citation within the text of the PDF and then populating the alias field with that value?

Using Applescript.

What is the pattern that will match the id?

Would this have to be triggered on each and every item, or can it be done en masse?

(\d{1,3} (U\.S\.|S\. ?Ct\.|F\.[23]?d?|F\. ?App\'?x|F\. ?Supp\. ?2?d?) \d{1,3} \(\d{4}\))|[1290]\d{2} (WL|LEXIS) \d{5,6}

This will get the job done. But first you will have to take a look at how to set up smart-rules. Also, you need to place the script “RegexAndStuffLib” in ~/Library/Script Libraries. It should be easy to find (look through my old posts).

use AppleScript version "2.4" -- Yosemite (10.10) or later
use script "RegexAndStuffLib"
use scripting additions

property thePattern : "(\\d{1,3} (U\\.S\\.|S\\. ?Ct\\.|F\\.[23]?d?|F\\. ?App\\'?x|F\\. ?Supp\\. ?2?d?) \\d{1,3} \\(\\d{4}\\))|[1290]\\d{2} (WL|LEXIS) \\d{5,6}"

on performSmartRule(theRecords)
	tell application id "DNtp"
		repeat with theRecord in theRecords
			set theText to the plain text of theRecord
			set theID to regex search once theText search pattern thePattern replace template "$1"
			set theAliases to the aliases of theRecord
			set the aliases of theRecord to theID & ", " & theAliases
			log message "Aliases of " & (the name of theRecord) & " updated"
		end repeat
	end tell
end performSmartRule

1 Like

Thanks so much–I will give this a try!

Many thanks. I will try it.