[url] Url Wrapper Δ
(*******************************************************************************CREATE BBCODE URL WRAPPER FOR SELECTED TEXT
CREATED BY JONATHAN BEEBE - www.beebeography.com
--------------------------------------------------------------------------------
Version: 01 Created: 18 December, 2006 @ 10:11 AM
The following code will:
get the selection from Journaler
add the [url= ???] and [/url] tags to the selection
the text is broken apart at each space
the first text item is the URL
all remaning text items are the visible text
replace the selection with the new text
Example Journaler usage:
Write the URL in the entry as follows:
http://www.my_url.com This is the Visible Text
Output is:
[url=http://www.my_url.com]This is the Visible Text[/url]
To use this script select the text that should be wrapped
and then run the script.
*******************************************************************************)
tell application "Journler"
set theEntry to selected entry
set theContents to plain text of theEntry
set theSelection to selected text
set theNumber to (offset of theSelection in theContents)
set theLength to count of characters of theSelection
set AppleScript's text item delimiters to " "
set theURL to text item 1 of theSelection
set theVisibleText to (text items 2 thru -1 of theSelection) as string
set AppleScript's text item delimiters to ""
set theCount to count of theContents
if (theCount ≤ (theNumber + theLength)) then
set theNewText to (((text items 1 thru (theNumber - 1)) of theContents) & "[url=" & theURL & "]" & theVisibleText & "[/url]") as string
else
set theNewText to (((text items 1 thru (theNumber - 1)) of theContents) & "[url=" & theURL & "]" & theVisibleText & "[/url]" & ((text items (theNumber + theLength) thru -1) of theContents)) as string
end if
set plain text of theEntry to theNewText
return
end tell
Open this Script in Script Editor by clicking
here. This only works with OS 10.3 or later.
[code] Code Wrapper Δ
(*******************************************************************************CREATE BBCODE CODE WRAPPER FOR SELECTED TEXT
CREATED BY JONATHAN BEEBE - www.beebeography.com
--------------------------------------------------------------------------------
Version: 01 Created: 18 December, 2006 @ 10:11 AM
The following code will:
get the selection from Journaler
add the [code] and [/code] tags to the selection
replace the selection with the new text
Example Journaler usage:
Write the Code in the entry as follows:
Output is:
[code]The code you seleted[/code]
To use this script select the text that should be wrapped
and then run the script.
*******************************************************************************)
tell application "Journler"
set theEntry to selected entry
set theContents to plain text of theEntry
set theHTML to html text of theEntry
set theSelection to selected text
set theNumber to (offset of theSelection in theContents)
set theLength to count of characters of theSelection
set AppleScript's text item delimiters to ""
set theCount to count of theContents
if (theCount ≤ (theNumber + theLength)) then
set theNewText to (((text items 1 thru (theNumber - 1)) of theContents) & "[code]" & theSelection & "[/code]") as string
else
set theNewText to (((text items 1 thru (theNumber - 1)) of theContents) & "[code]" & theSelection & "[/code]" & ((text items (theNumber + theLength) thru -1) of theContents)) as string
end if
set plain text of theEntry to theNewText
return
end tell
Open this Script in Script Editor by clicking
here. This only works with OS 10.3 or later.
[b] Bold, [i] Italic, [u] Underline text Δ
(*******************************************************************************FORMAT TEXT OF CURRENT NOTE WITH BBCODE MARKUP
CREATED BY JONATHAN BEEBE - www.beebeography.com
--------------------------------------------------------------------------------
Version: 01 Created: 18 December, 2006 @ 10:11 AM
The following code will:
replace any text styled with Bold, Italic, and Underline styles
with the correct BBCode style markup
Example Journaler usage:
Output is:
Here is some sample text Can I get [b]better[/b] [i]style [/i][u]info[/u] about it?
*******************************************************************************)
tell application "Journler"
set theEntry to selected entry
set theContents to plain text of theEntry
set theHTML to html text of theEntry
set theText to my formatBold(theHTML)
set theText to my formatItalic(theText)
set theText to my formatUnderline(theText)
set html text of theEntry to theText
end tell
on formatBold(theText)
set theText to (my stripCharacterAndReplaceWith(theText, "</strong>", "[/b]"))
return (my stripCharacterAndReplaceWith(theText, "<strong>", "[b]"))
end formatBold
on formatItalic(theText)
set theText to (my stripCharacterAndReplaceWith(theText, "</em>", "[/i]"))
return (my stripCharacterAndReplaceWith(theText, "<em>", "[i]"))
end formatItalic
on formatUnderline(theText)
set theText to (my stripCharacterAndReplaceWith(theText, "</u>", "[/u]"))
return (my stripCharacterAndReplaceWith(theText, "<u>", "[u]"))
end formatUnderline
on stripCharacterAndReplaceWith(theText, theCharacter, theReplacement)
local theResult, theStrings
set theResult to ""
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to theCharacter
set theStrings to every text item of theText
set AppleScript's text item delimiters to theReplacement
set theResult to theStrings as string
set AppleScript's text item delimiters to oldDelimiters
return theResult
end stripCharacterAndReplaceWith
Open this Script in Script Editor by clicking
here. This only works with OS 10.3 or later.