Editorial Workflows

Detectar Textos Bíblicos

public workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: Detectar Textos Bíblicos

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import editor

workflow.set_variable('ScrollPosition', repr(editor.get_scroll_position()))
Selected Text ?
Entire Line(s)
OFF
Empty Selection Output
  • No Output
  • All Text
  • Closest Word
Folded Text
  • Include
  • Replace with:
Set Variable ?
Variable Name
initialInput
Value
Input
Repeat… ?
Repeat with
  • Every Line
  • Every Match of Regular Expression:
([\[=])?([1-3])?(?:\s*)([\w+]{2,})[.]?(?:\s*)(\d+)(?:\s*)[:]((?:\s*)(?:\d+)(?:(?:[,-])?(?:\s*)(?:\d+)?)*)
Match Group
0 (entire match)
Reverse
OFF
If… ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
^[^\[=]
Remove Whitespace ?
  • Trim leading/trailing whitespace
  • Remove empty lines
Set Variable ?
Variable Name
scriptureBefore
Value
Input
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import re
import console

action_in = workflow.get_input()

bible = [
    ['Es'],
    ['Génesis', 'Gé', 'Ge', 'Gé', 'Gene', 'Gen', 'Gén', 'Génesis'],
    ['Éxodo', 'Éx', 'Ex', 'Exodo', 'Exo'],
    ['Levítico', 'Le', 'Lev', 'Levítico', 'Levitico'],
    ['Números', 'Nú', 'Nu', 'Num', 'Numeros'],
    ['Deuteronomio', 'Dt', 'Deu', 'De'],
    ['Josué', 'Jos', 'Josue'],
    ['Jueces', 'Jue'],
    ['Rut', 'Ru'],
    ['1 Samuel', '1Sa', '1 Sam'],
    ['2 Samuel', '2Sa', '2 Sam'],
    ['1 Reyes', '1Re', '1 Rey'],
    ['2 Reyes', '2Re', '2 Rey'],
    ['1 Crónicas', '1Cr', '1 Cro', '1 Cr'],
    ['2 Crónicas', '2Cr', '2 Cro', '2 Cr'],
    ['Esdras', 'Esd'],
    ['Nehemías', 'Ne', 'Neh'],
    ['Ester', 'Est'],
    ['Job', 'Job'],
    ['Salmos', 'Sl', 'Sal', 'Salmo'],
    ['Proverbios', 'Pr', 'Pro', 'Prov'],
    ['Eclesiastés', 'Ec', 'Ecl', 'Ecle'],
    ['El Cantar de los Cantares', 'Can', 'Cantar', 'Cantar de los Cantares'],
    ['Isaías', 'Isaías', 'Isaias', 'Isa', 'Is'],
    ['Jeremías', 'Jeremías', 'Jeremias', 'Jere', 'Jer'],
    ['Lamentaciones', 'Lam', 'Lament'],
    ['Ezequiel', 'Eze', 'Ezeq'],
    ['Daniel', 'Da', 'Dan'],
    ['Oseas', 'Os', 'Ose'],
    ['Joel', 'Joe'],
    ['Amós', 'Am', 'Amos'],
    ['Abdías', 'Abd', 'Abdias'],
    ['Jonás', 'Jon', 'Jonas'],
    ['Miqueas', 'Miq', 'Miquea'],
    ['Nahúm', 'Na', 'Nah'],
    ['Habacuc', 'Hab', 'Haba'],
    ['Sofonías', 'Sof', 'Sofonias'],
    ['Ageo', 'Ag', 'Age'],
    ['Zacarías', 'Zac', 'Zacarias'],
    ['Malaquías', 'Mal', 'Malaquias'],
    ['Mateo', 'Mt', 'Mat'],
    ['Marcos', 'Mr', 'Marc', 'Mar'],
    ['Lucas', 'Lu', 'Luc'],
    ['Juan', 'Jn'],
    ['Hechos', 'Hch', 'Hech'],
    ['Romanos', 'Ro', 'Rom'],
    ['1 Corintios', '1Co', '1 Cor'],
    ['2 Corintios', '2Co', '2 Cor'],
    ['Gálatas', 'Gál', 'Galatas', 'Gal'],
    ['Efesios', 'Ef', 'Efe'],
    ['Filipenses', 'Flp', 'Fili'],
    ['Colosenses', 'Col', 'Colo'],
    ['1 Tesalonicenses', '1Te', '1 Te', '1 Tes'],
    ['2 Tesalonicenses', '2Te', '2 Te', '2 Tes'],
    ['1 Timoteo', '1Ti', '1 Ti', '1 Tim'],
    ['2 Timoteo', '2Ti', '2 Ti', '2 Tim'],
    ['Tito', 'Tit'],
    ['Filemón', 'Flm', 'File', 'Filemon'],
    ['Hebreos', 'Heb', 'Hebr'],
    ['Santiago', 'Snt', 'Sant'],
    ['1 Pedro', '1Pe', '1 Ped', '1 Pe'],
    ['2 Pedro', '2Pe', '2 Ped', '2 Pe'],
    ['1 Juan', '1Jn', '1 Jn'],
    ['2 Juan', '2Jn', '2 Jn'],
    ['3 Juan', '3Jn', '3 Jn'],
    ['Judas', 'Jud'],
    ['Revelación', 'Rev', 'Revelacion', 'Revel', 'Re']
]

def getBook(book):
	for list in bible:
		for bookName in list:
			if bookName.lower().strip() == book.lower().strip():
				return (list[0], list[1])
	return ('', '')
	

def processMatch(m):
	part = ''
	book = ''
	abreviation = ''
	chapter = ''
	verses = '';
	if m.group(2) is not None:
		part = m.group(2).strip()
	if m.group(3) is not None:
		book = m.group(3).strip()
	if m.group(4) is not None:
		chapter = m.group(4).strip()
	if m.group(5) is not None:
		verses = m.group(5).strip()
	(libro, abreviation) = getBook(part + " " + book)
	
	if m.group(1) is not None:
		if m.group(1).strip() == '[':
			return false
		elif m.group(1).strip() == '=':
			return false
		else:
			return '[{0} {1}:{2}](equipdbible://x-callback-url/lookup?x-source=editorial&language=es&scripture={3}{4}:{5}&x-success=editorial://)'.format(libro.strip(), chapter.strip(), verses, abreviation.strip(), chapter.strip(),verses.strip().replace(' ', ''))
	else:
		return '[{0} {1}:{2}](equipdbible://x-callback-url/lookup?x-source=editorial&language=es&scripture={3}{4}:{5}&x-success=editorial://)'.format(libro.strip(), chapter.strip(), verses, abreviation.strip(), chapter.strip(),verses.strip().replace(' ', ''))

#This regular expression matches a bible scripture capturing 
#Group 1 ([ = or Empty) - This char help identify when a scripture has already been extracted and replaced in the text as a markdown link to equipd bible.
#Group 2 (Primero, segundo or tercero) (o vacío)
#Group 3 (Libro de la Biblia)
#Group 4 (Capítulo)
#Group 5 (Versículo/s)

regex = re.compile(r'([\[=])?([1-3])?(?:\s*)([\w+]{2,})[.]?(?:\s*)(\d+)(?:\s*)[:]((?:\s*)(?:\d+)(?:(?:[,;:–-])?(?:\s*)(?:\d+)?)*)', re.UNICODE)

result = regex.sub(processMatch, action_in)

workflow.set_output(result)
Set Variable ?
Variable Name
urlToEquipd
Value
Input
Set Variable ?
Variable Name
Input
Value
initialInput
Find / Replace ?
Find
scriptureBefore
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
urlToEquipd
Set Variable ?
Variable Name
initialInput
Value
Input
Set Variable ?
Variable Name
madeChange
Value
True
…End If
…End Repeat
If… ?
Run the block if
madeChange
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
True
Extend Selection ?
Direction
  • Backward
  • Forward
  • Both
Unit
  • Start/End of Document
  • Start/End of Line
  • Number of Characters...
1
Replace Selected Text ?
Replacement Text
initialInput
…End If
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import editor

editor.set_scroll_position(float(workflow.get_variable('ScrollPosition')))