Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Regex to update markdown headers.
-
Hi ,
I am a novice both with regex and editorial.
I am trying to use regex to shift markdown headers on level down. I have tried find (#+) replace #\1 but this doesn't seem to work with the included find and replace popover workflow. Can anyone suggest how else I can accomplish this?
Thanks,
Chris
-
Not sure of the context, and this workflow is probably overkill, but it throws up a menu allowing you to adjust the number of levels in an outline which have hash headers.
-
Thanks Rob. That is very interesting, especially as I have never tried to use JSON but is more complex than I hoped for! The task seems as if it should be accomplished using the standard macro building blocks but none of the approaches I have tried have been successful!
-
I have confirmed that the regex does what I want in notepad++. I created a 1 action workflow using the find an replace action with the same regex but it seems to cause editorial to crash! Are the regex used in editorial different to those in notepad++? Is there some aspect of the find and replace action I have missed? I am frustrated to be stumped by something that seems so simple!
-
@Chrishphoto I have no idea what flavor of regular expressions notepad++ uses, they tend to differ a little bit with different languages/libraries.
Could you share the workflow that caused the crash? I'd be interested in reproducing the crash, so that I can hopefully fix it. Thanks!
-
I realised that the workflow can't actually do anything as I had not set the input and output. Having said that, it does always cause a crash for me and must represent some error!
http://editorial-app.appspot.com/workflow/4973290271539200/OboTDfy_5Js
-
An updated workflow does the find and replace but doesn't include the found token where I have used \1. How should I include the token in the replace for editorial?
-
@Chrishphoto Thanks!
The crash is probably due to a bug in the current version with find-replace actions that don't have an input (will be fixed in the update I'm working on).
I'd recommend adding a "Document Text" action before the find/replace, then an "Extend Selection" (both directions, start/end of document), and finally a "Replace selected text".
Editorial uses dollar symbols for match groups, so if you replace
\1
with$1
it should work.Here's how it should look:
http://www.editorial-workflows.com/workflow/6377001547988992/pXNc_9M2kSQ
-
Thanks. That's the ticket. I implemented for a selection rather than the whole document as this suits my use case better. http://editorial-app.appspot.com/workflow/5029996724748288/03zOfG0O2RI
Is there documentation for the variant of regex used by editorial?
-
Editorial uses
NSRegularExpression
, which is part of Cocoa and based on ICU regular expressions, so you can either use Apple's documentation or the ICU User Guide (you can ignore the Objective-C/C stuff, but the reference tables are useful). -
Thanks. I now have a pair of macros to promote and demote headers.
http://editorial-app.appspot.com/workflow/4963919726641152/tZs6onJqdYU
http://editorial-app.appspot.com/workflow/5235317636333568/A3-6hNeaPbU