Editorial Workflows

Insert Footnote...

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: Inserts a Markdown footnote (including its definition) without changing the current cursor position. Footnotes are numbered sequentially, based on existing footnotes in the document.

Shared by: evolve75

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

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

def get_next_footnote():
	text = editor.get_text(True)
	footnotes = set(re.findall('\[\^(.*?)\]', text))
	max_footnote = 0
	for fn in footnotes:
		try:
			fn_num = int(fn)
			max_footnote = max(max_footnote, fn_num)
		except ValueError:
			pass
	return str(max_footnote+1)

workflow.set_output(get_next_footnote())
Set Variable ?
Variable Name
Footnote Name
Value
Input
Request Text Input ?
Title
Insert Footnote...
Initial Text
Text for footnote Footnote Name
  • Single Line
  • Multiple Lines
Keyboard Options:
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import editor

text = editor.get_text()
cursor = editor.get_selection()[0]
fn_name = workflow.get_variable('Footnote Name')
fn_text = workflow.get_input()

footnote_def = '[^%s]: %s' % (fn_name, fn_text)
footnote_marker = '[^%s]' % (fn_name,)
end = len(text)
editor.replace_text(end, end, '\n\n' + footnote_def, False)
editor.replace_text(cursor, cursor, footnote_marker, False)