In preparing my reviews of iOS 9 and the iPad Pro, I noticed that my writing process was being slowed down by the lack of multitasking support in my text editor of choice, Editorial. For the past couple of weeks, I've been trying to move some of my Editorial scripts and workflows to 1Writer, with interesting results and potential for the future.
I have written about Editorial at length on MacStories, and I still find Ole Zorn's text editor to provide the most powerful combination of Markdown and plain text automation that's ever been created on iOS. Over the years, I've put together hundreds of workflows thanks to Editorial's visual actions and Python scripting; while some of them were made for fun and intellectual curiosity, the majority of them helped me save time when doing actual work for this website, Relay FM, and Club MacStories. There is no other app with the same feature set and rich Markdown support of Editorial.
Since iOS 9, however, I've been wondering whether part of Editorial's automation could be taken somewhere else, possibly in another app that offered full integration with iOS 9 multitasking. I may have several workflows in Editorial, but I only use a tiny fraction of them on a daily basis for regular work on this website. I'd rather use a text editor that excels at a subset of Markdown workflows and integrates with iOS 9 than a single text editor with every imaginable workflow without proper iOS 9 integration.
It was this realization that pushed me to give 1Writer another look. I first bought the app years ago, but because I had no excuse to explore the world outside of Editorial, I didn't try to recreate any workflows in it. This time around, I was motivated to rebuild the core of my setup in 1Writer, so I took a deep dive into the app's automation engine.
Things will likely change again once Editorial supports iOS 9, but in the meantime I've developed an appreciation for 1Writer's design and features that helped me understand the app better.
editor– Interact with the text editor. This lets you get and set a document's text, get ranges and selections, replace selections, and perform file operations.
app– This objects includes methods to interact with the app itself. There isn't a lot of choice here compared to Editorial or Pythonista, but you can launch URLs, get and set the clipboard, and see if a script is being activated from the app's extension.
ui– Automated user interaction. Again, not as full-featured as the crazy custom interfaces of Editorial, but you can show alerts programmatically, display success and error messages, bring up input fields to enter text, and even display lists of multiple items with associated functions.
http– Perform HTTP requests, including GET and POST requests.
webBrowser– This object allows you to interact with the app's built-in web browser, which doesn't have tabs like Editorial's browser and isn't based on the new Safari View Controller web views of iOS 9. You can also show HTML code in the browser.
RegExp objects with, say, text passed by the app's
editor object, which communicates directly with the text editing interface. For more details, you can check out 1Writer's online documentation.
For my more advanced Markdown and web automation, I believe I'll always end up using Editorial; not even Workflow gets close to the possibilities opened by Python and text manipulation of Editorial.
Adding and Reopening Markdown Links
In every post I publish on MacStories, there's at least one link that points readers somewhere else. I prefer inline Markdown links over reference-style ones as I like to see the URL I'm linking to while I'm reading a paragraph, and I find the hyperlink to be one of the greatest inventions of the open web. I link profusely whenever possible.
For two years, I've relied on an Editorial workflow that makes text selected in the editor an inline link based on the webpage that is active in the in-app browser. I have used that workflow thousands of times and it has saved me hours I would have spent manually typing the link syntax in a document each time. You can download it here if you want.
After years of writing in Editorial and swiping back and forth between the text editor and the built-in browser, adjusting to a shared browser-editor setup required some change in habits on my end. I'm still learning to remember that I have this ability thanks to iOS 9; the iPad Pro is facilitating this change with its superior multitasking experience. 1Writer and Safari running simultaneously on my iPad haven't only allowed me to more easily reference web material when writing – they also offer an easier way to add inline links.
On iOS 9, 1Writer features a series of buttons in the iPad's Shortcut Bar that let you perform actions in the text editor. One of these is a Link button that can add a link at the insertion point in a document or transform selected text in a Markdown link.
By default, tapping the Link button offers two choices: you can type a link's text and URL manually, or you can link to another document in 1Writer. If you've already copied a link, though, 1Writer will display a third option to add a link from your clipboard, which is ideal for text selections.
When I'm editing a piece in 1Writer2, I can invoke Safari, put the two apps in Split View, and, as I go through my edits, copy a link in Safari, select some text in 1Writer, tap the link icon, and have a link ready in the document. This takes a second, and it benefits from the new shortcut to copy URLs in iOS 9: just tap & hold the address bar in Safari to show a Copy button.
The ability to view a browser next to a Markdown document is useful for obvious reasons, and 1Writer's 'From Clipboard' link option works well with Safari. I can see future MacStories reviews and articles benefitting from a way to pin Safari next to the text editor.
The action works by grabbing the entire text of the line where the cursor is, scanning it for matches to the regex I created, and displaying results in a list. An error message is displayed if no links are found. The regular expression is designed to match Markdown image links and inline links, with and without alt attributes or link titles. Different parts of a link are captured with groups, but this action only uses the second group to collect URLs and list them. Feel free to modify everything and do something else with capturing groups.
This action solves an annoying problem for me: I don't like selecting URLs with the native iOS selection controls, and 1Writer doesn't have built-in methods to extract URLs from the current line. It took a bit of work, but I'm happy with the results. When I'm editing a post, I can bring up the action sheet, tap Reopen, and I'm presented with a list of links so I can choose one and send it back to Safari on the other side of the screen.
A note on launching actions in 1Writer: the app doesn't have a bookmarks bar on top of the editor, and the only way to view actions is through a modal popup that lists custom actions below default ones such as Copy and Open In.
It's not the fastest way to launch actions that are supposed to save you time, and I think they should be more prominent in the UI. Thankfully, you can trigger the Actions popup from the Shortcut Bar3 (share icon) or from the copy & paste menu of iOS. I'd like to see 1Writer get the ability to pin individual actions to the Shortcut Bar, assign keyboard shortcuts to them, or maybe even pin actions to the sides of a document (there's plenty of space on the iPad Pro).
Images and Lists
In Editorial, I had to create my own workflows to insert a Markdown image link and turn selected lines into an unordered list. In 1Writer, both features are available by default with buttons in the Shortcut Bar (or the extended keyboard row if you prefer to use that one). The list button does what you expect – if I had to nitpick, I'd like the app to use asterisks instead of dashes for unordered lists, but I'm not here to argue about our favorite flavors of Markdown.
For images, 1Writer lets you either take or add photos from your library, or enter a link. If you pick an image, it gets uploaded to one of the app's supported services (Dropbox, CloudApp, Evernote, and Droplr) and its public link is inserted in the document. If you already have an image URL, the syntax for a Markdown image link is entered in the document so you can type any possible alt text and paste your link.
It would be nice if 1Writer supported more blogging-focused upload services for media such as Rackspace Cloud Files (what I use) and Amazon S3. External integrations (not just for publishing, but to generate image URLs) would definitely make for an IAP I'd buy in a heartbeat.
Linked Posts with Blockquotes
This workflow isn't strictly related to 1Writer, and it's been customized for my specific needs, but I thought it could still be useful for some people.
When I create linked posts for the site, I want to be able to select some text in the browser and generate a text file with a quoted selection and the original webpage's title as the file name. Because 1Writer doesn't let me access the contents of a webpage programmatically, I created a workflow that uses Pythonista and Workflow in Safari4 to create the template file I want when I need to prepare a linked post.
Making progress on new iPad blogging workflow based on Split View for linked posts (1Writer, Workflow, Pythonista) pic.twitter.com/Hme8LHHncB
— Federico Viticci (@viticci) November 14, 2015
You can find the workflow here, and the Pythonista script on GitHub. As I showed on Twitter a few days ago, the workflow is meant to be used in Split View with Safari next to 1Writer. Here's what it does:
- Gets selected text from Safari;
- The Workflow extension passes the HTML version of selected text to Pythonista;
- Pythonista converts HTML to Markdown using html2text;
- The Split View layout is restored with Safari and 1Writer;
- A new file is automatically created in 1Writer, using the title of the webpage as file name and a blockquote of Safari's selection in the body text.
Note: If the original webpage is a relay.fm URL, Workflow reformats the content to the style I prefer. This is just for me and it's designed for how I like to link to podcast episodes on MacStories. You can delete the conditional block because you likely won't need it.
You may be wondering why involving Pythonista at all when the Workflow extension can return HTML for selections in Safari or pass plain text to 1Writer via a URL scheme. The reason is that I like to keep formatting of an original article intact when I link to it on MacStories (that includes text styles and hyperlinks), and I try to avoid HTML mixed with Markdown as much as possible. I want the file behind each linked post to be completely in Markdown and I don't want to lose any formatting the original author included in their post. The only way to do this automatically is to use both Pythonista and Workflow. If Workflow added support for
html2text in an action, I could avoid using a Python script.
With this setup, I can work with Safari and 1Writer simultaneously, creating dynamic templates for linked posts in two seconds when I want to link to a webpage on MacStories. However, there's also another way to capture webpage information and convert it to Markdown with 1Writer.
1Writer has a powerful share extension that, if used in Safari, can create a new file prefilled with a Markdown version of text selected in the browser. The share extension's template is customizable: by combining placeholders for the webpage title, URL, and selected text with any arbitrary plain text (Settings > Share Extension > Template), you can set up the extension to create files for content captured in Safari.
To demonstrate this, I created a New Linked action that reformats content captured from the 1Writer extension. The original selection from Safari is automatically converted to Markdown by the extension, and I chose to set the extension's template to include a Markdown blockquote and an inline link for the current webpage at the top of the document.
The inline link is a trick to work around the extension template's inability to set a custom name for a file created by the extension. I would like the 1Writer extension to use a webpage's title as the file name whenever I capture content from Safari, but there's no such option in the Settings – the app uses a timestamp instead.
To circumvent this limitation, I insert an inline link as the first line of the file, manually copy and paste the title in the title bar or rename the new file, then use the same regular expression I created to reopen links (see how capturing groups did come in handy?) to remove the first line from the file and set the iOS clipboard to the URL of the webpage. This way, I can save a linked post template from Safari to 1Writer, open the app, and add the link somewhere in the document with the Link button of the Shortcut Bar.
You can download my New Linked action here.
Jump to Section
One of my favorite details of Editorial is a menu to quickly navigate to Markdown sections inside a document. By tapping on a file's name in the title bar, Editorial opens a list of all Markdown headers found in the current file. Sadly, this isn't possible in 1Writer, which slows me down when I have to jump across sections in long documents.
Fortunately, Phillip Gruneich has come up with an action that scans the document for headers, shows them in a list, and lets you tap one to jump to it. It's not as fast to activate as Editorial's title bar popup, but it gets the job done.
You can download Phillip's action here.
Adding App Store Links
When I have to link to an app from the Store, I can run this action to look up an app on the iTunes API and get a Markdown link with the affiliate URL into the document. Everything happens behind the scenes and all you have to do is select the type of app you need to find (iPhone, iPad, or Mac) and pick it from a list of results. 1Writer developer Ngoc Luu himself did all the work on the iTunes API code, which works very well.
The only parameters you have to change in the action are the affiliate token and the campaign tracking code, which I put right at the top as two variables.
I modified the action to work if some text is selected in the editor. If I select the name of an app I want to link to in my document, I don't want to type the app's name again when searching for its link; in my action, 1Writer displays a text field prefilled with the selected app name. If everything looks good, you can just tap Continue7 and the action will look up the app's name for you. If you're adding a link for selected text that isn't an app's name, you can delete the prefilled text with one tap and type it manually. If nothing is selected, the action creates an inline link with no anchor text. It works either way.
You can download the action here.
MacStories readers know that I have a particular affection for footnotes, as I'm proud of the way we designed the footnote popover to behave with the redesign of our website last year.
When I have to add a footnote to an article, I use an Editorial workflow that asks me for a footnote label and some text, and which then takes care of scrolling to the bottom of the document, inserting the footnote, and scrolling back to where I was, pasting the footnote anchor. All this is done automatically, and I couldn't work with my text editor in any other way at this point. Manual insertion is not an option.
I also created an action that shows the footnote's text if you don't remember what it is about anymore and you're too lazy to scroll. Unfortunately, 1Writer's
editor object doesn't provide a way to select the closest word to the cursor like in Editorial, so you'll have to manually select a footnote label before running the action. I'll have to update this action to include a proper error message if results aren't found.
You can download my Find Footnote action here.
1Writer is far from the power and customization of Editorial. Ole Zorn's app is the undisputed king of Markdown automation on iOS, and nothing gets close to it. But, I found 1Writer to be a capable replacement for most of my daily Markdown needs, and the app has been updated to work on iOS 9 and the iPad Pro.
1Writer has potential, and it surprised me because I didn't expect to be able to recreate most of my Markdown automation in it. I don't know if I'll switch back to Editorial once it gets updated with iOS 9 integration and even more workflows, but I'll keep using 1Writer for now. It's a solid text editor with nice little touches that I haven't mentioned in this article, and it's on the right track to offer a versatile alternative to Editorial for Markdown power users.
1Writer is available on the App Store.
- I've been using a beta Workflow action to post Markdown to WordPress. Hopefully, it'll be released soon. ↩︎
- By the way, I deactivated the app's extra keyboard row and automatic full-screen mode. With the Shortcut Bar (and also with the large keyboard of the iPad Pro), I have essential shortcuts and keys right at my fingertips; I find full-screen mode mostly annoying as it hides the title bar, preventing me from quickly opening the sidebar to see all my documents. Both options can be turned off in the Settings. ↩︎
- And in iOS 9.2, Safari View Controller too, which has been updated to provide webpage content to action extensions. ↩︎
- There is a condition to test whether the editor has been activated from the extension and not from the full app. ↩︎
- You'll have to close and reopen the app for the file to show up (or exit Split View). ↩︎
- Unfortunately, pressing Return in the text fields of custom UIs in 1Writer doesn't map to 'Continue' in the popup, but it adds a new line in the editor. This should be fixed. ↩︎