On Aug 26, 2012, at 10:36, psilas <[email protected]> wrote:
> I would like to convert Multimarkdown internal links to Pandoc ones
______________________________________________________________________
This is pretty quick and dirty, but it works.
Kendall's Perl is prettier though. :)
-ccs
------------------------------------------------------------------------------------------------
on fndRepl(_find, _repl, _data)
tell application "BBEdit"
set tocItemNew to replace _find using _repl searchingString _data options
{search mode:grep, case sensitive:false, returning results:true}
end tell
end fndRepl
------------------------------------------------------------------------------------------------
try
tell application "BBEdit"
set fRec to {found:true}
tell text of front text window
select insertion point before character 1
repeat while found of fRec = true
set fRec to find "^\\[.+\\]\\[\\]" options {backwards:false, case
sensitive:false, search mode:grep, wrap around:false} with selecting match
if found of fRec = true then
set _found to (found object of fRec) as text
set AppleScript's text item delimiters to {"[", "]"}
set tocItem to text item 2 of _found
set tocItem to fndRepl("(.)", "\\l\\1", tocItem) of me
set tocItemNew to "(#" & fndRepl(" ", "-", tocItem) of me & ")"
set replText to fndRepl("(^\\[.+?\\])(\\[\\])", "\\1" & tocItemNew,
_found) of me
set text of selection to replText
end if
end repeat
end tell
end tell
on error eMsg number eNum
set {c, s} to {return, "------------------------------------------"}
set e to s & c & "Error: " & eMsg & c & s & c & "Error Number: " & eNum & c &
s
beep
set dDlg to display dialog e buttons {"Cancel", "Copy", "OK"} default button
"OK"
if button returned of dDlg = "Copy" then
set the clipboard to e
end if
end try
------------------------------------------------------------------------------------------------
--
--
You received this message because you are subscribed to the
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem,
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>