Advertisement
rccharles

print file only

May 4th, 2019
1,253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (*
  2.  
  3.   This applescript converts clipboard input into a format suited for pasting into an ASC
  4.   reply.  I observed that my copies into an ASC reply were not formated that well.  
  5.   I observed that copies from a web browser were formated much better.  I went about
  6.    adjusting the clipboard copy to the format expected by a web browser for best results.
  7.  
  8.  This applescript accepts the clipboard in either
  9.  -- plain text upon which the text is converted to HTML.  Conversion is limitted to inserting paragraph tags for blank lines and inserting links where http or https text appears. The page title is substituted for the link.  
  10.  -- HTML source code identified by text containing HTML markup.  
  11.          Caveat emptor.  
  12.  
  13. run with copy from Waterfox. List of main routines.
  14.   --- run ---
  15.   --- common ---
  16.   --- adjustCharacters() ---
  17.   --- adjustBrowserHTML ---
  18.   --- adjustURLs ---
  19.   --- adjustToAscHtml ---
  20.   --- adjustLF() ---
  21.   --- convertToHTML ---
  22.  
  23. run with HTML as text from TextWrangler. List of main routines.
  24.   --- run ---
  25.   --- common ---
  26.   --- adjustCharacters() ---
  27.   --- adjustBrowserHTML ---
  28.   --- adjustURLs ---
  29.   --- adjustToAscHtml ---
  30.   --- adjustLF() ---
  31.   --- chompLeftAndTag ---
  32.   --- chompLeftAndTag ---
  33.   --- adjustLF() ---
  34.   --- chompLeftAndTag ---
  35.   --- chompLeftAndTag ---
  36.   --- adjustLF() ---
  37.   --- convertToHTML
  38.  
  39. run with plain text from TextWrangler. List of main routines
  40.   --- run ---
  41.   --- common ---
  42.   --- adjustCharacters ---
  43.   --- adjustURLs ---
  44.   --- chompLeftAndTag ---
  45.   --- chompLeftAndTag ---
  46.   --- chompLeftAndTag ---
  47.   --- chompLeftAndTag ---
  48.   --- addParagraphs ---
  49.   --- convertToHTML ---
  50.  
  51.  to use:
  52.  1) copy command + c what data you want to convert
  53.  2) run this applascript by double clicking on the app.
  54.  3) paste command + V into an ASC reply
  55.  
  56.  I have tested in Waterfox 56.2.9 in Yosemite.  I assume the process will work with other web browsers and other versions of macOS.
  57.  
  58.  Save as an Application Bundle.  Don't check any of the boxes.
  59.  
  60. Should you experience a problem, run in the Script Editor.
  61.    Shows how to debug via on run path. Shows items added to folder. Shows log statement.
  62.    It is easier to diagnose problems with debug information. I suggest adding log statements to your script to see what is going on.  Here is an example.  
  63.    
  64.   For testing, run in the Script Editor.
  65.          1) Click on the Event Log tab to see the output from the log statement
  66.       2) Click on Run
  67.    
  68. change log
  69. may 1, 2019   -- skip 403 forbidding title
  70. may 2, 2019   -- convert \" to ".  the \" mysteriously appears in HTML source code input.  Probably some TextEdit artifact.
  71.                 copy to TextEdit copy out of TextEdit.
  72. may 7, 2019   -- regressed May 2nd update.  Applescript was inserting \" for display purposes into output.
  73. may 8, 2019   -- special processing for html class on clipboard
  74.                          https://pastebin.com/raw/Yg138YqT
  75. may 16,2019  -- fixed hexDumpFormatOne bugs and improved output
  76. may 16,2019  -- added hexDumpFormatZero
  77. may 19,2019  -- eliminate line breaks outside the <pre>...</pre> tags in HTML. ASC intrepreting line
  78.                          breaks as meaningful <br>
  79.                          instead of white space.simplified line break code.
  80.                        https://pastebin.com/raw/Nq08cFYH
  81. may 23, 2019 -- squash leading blanks in a line.
  82. may 27, 2019 -- Horizontal Ellipsis
  83.                          8230   U+2026  E2 80 A6    … Horizontal Ellipsis
  84.                  https://www.charset.org/utf-8/9
  85. may 28, 2019 -- decide what to do with tabs
  86.          
  87.  
  88. enhancements:
  89.   -- get pdf title
  90.  
  91.  
  92. Author: rccharles
  93.  
  94.  Copyright 2019 rccharles  
  95.      
  96.        Permission is hereby granted, free of charge, to any person obtaining a copy  
  97.        of this software and associated documentation files (the "Software"), to deal  
  98.        in the Software without restriction, including without limitation the rights  
  99.        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell  
  100.        copies of the Software, and to permit persons to whom the Software is  
  101.        furnished to do so, subject to the following conditions:  
  102.        
  103.        The above copyright notice and this permission notice shall be included in all  
  104.        copies or substantial portions of the Software.  
  105.        
  106.        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  
  107.        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  
  108.        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE  
  109.        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER  
  110.        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,  
  111.        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE  
  112.        SOFTWARE.  
  113.  
  114.  
  115.    
  116.  
  117.  *)
  118.  
  119.  
  120. -- Gets invoked here when you run in AppleScript editor or double click on the app icon.
  121. on run
  122.     global debug
  123.    
  124.     -- Write a message into the event log.
  125.     log "  --- Starting on " & ((current date) as string) & " --- "
  126.    
  127.     -- 3 and 6 are good to use
  128.     set debug to 6
  129.     -- 0 no debugging
  130.     -- 1 displays input and output to this routine
  131.     -- 2 moderate
  132.     -- 3 display important "on" blocks
  133.     -- 4 display end of important "on" blocks
  134.     -- 5 display minor "on" blocks
  135.     -- 6 intense
  136.     -- 7 include replaceCharacter and hexDumpFormatOne debuging
  137.     set lf to character id 10
  138.    
  139.     if debug ≥ 3 then log "in --- run ---"
  140.    
  141.     set the clipboard to wrapupClipboardDataSelector()
  142.    
  143.     set theList to clipboard info
  144.     if debug ≥ 2 then printClipboardInfo(theList)
  145.    
  146.     set cbInfo to get (clipboard info) as string
  147.    
  148.     -- Most likely, if we have HTML data in the clipboard it will be from a web browser or Word.
  149.     if cbInfo contains "HTML" then
  150.        
  151.         if debug ≥ 2 then log "Working with HTML Class data from clipboard."
  152.         set theBoard to the clipboard as «class HTML»
  153.        
  154.         set normalHtml to do shell script "osascript -e 'try' -e 'get the clipboard as «class HTML»' -e 'end try' | awk '{sub(/«data HTML/, \"\") sub(/»/, \"\")} {print}' | xxd -r -p "
  155.         if debug ≥ 1 then
  156.             log "...Print out plain text version of inputed HTML data from the clipboard..." & return & normalHtml
  157.             hexDumpFormatOne("after converting to printable, normalHtml", normalHtml)
  158.         end if
  159.        
  160.         set normalHtml to adjustCharacters(normalHtml)
  161.        
  162.         set returnedData to adjustBrowserHTML(normalHtml)
  163.         if debug ≥ 2 then
  164.             log "...Print out plain text version of adjusted HTML data ..." & return & returnedData
  165.             log "...just printed plain text version"
  166.             log "printed in hex"
  167.             hexDumpFormatOne("returnedData", returnedData)
  168.         end if
  169.        
  170.         set returnedData to convertToHTML(returnedData)
  171.         try
  172.             if debug ≥ 2 then log "returnedData is " & returnedData
  173.         on error errStr number errorNumber
  174.             log "===> We didn't find HTML data.   errStr is " & errStr & " errorNumber is " & errorNumber
  175.             return 1
  176.         end try
  177.     else
  178.         -- will work with a plain html or plain text.
  179.         try
  180.             if debug ≥ 2 then log "Working with plain html or plain text"
  181.             set clipboardData to (the clipboard as text)
  182.             if debug ≥ 2 then
  183.                 log "class clipboardData is " & class of clipboardData
  184.                 log "continuing plain html or plain text"
  185.             end if
  186.            
  187.             if debug ≥ 1 then
  188.                 log "inputted clipboardData is " & clipboardData
  189.                 hexDumpFormatOne("inputted clipboardData", clipboardData)
  190.             end if
  191.         on error errStr number errorNumber
  192.             log "===> We didn't find data on the clipboard.   errStr is " & errStr & " errorNumber is " & errorNumber
  193.             display dialog "We didn't find HTML source code nor plain text on the clipboard." & return & "Please copy from a different source." giving up after 15
  194.             return 1
  195.         end try
  196.         if debug ≥ 2 then log "calling common"
  197.         set returnedData to common(clipboardData)
  198.     end if
  199.     if debug ≥ 2 then log "place on the clipboard returnedData is " & returnedData
  200.     postToCLipboard(returnedData)
  201.     -- return code
  202.     return 0
  203.    
  204. end run
  205.  
  206. -- Folder actions.
  207. -- Gets invoked here when something is dropped on the folder that this script is monitoring.
  208. -- Right click on the folder to be monitored. services > Folder Action Settup...
  209. on adding folder items to this_folder after receiving added_items
  210.     -- Write a message into the event log.
  211.     log "  --- Starting on " & ((current date) as string) & " --- "
  212.     display dialog "TBD, some assembly required."
  213. end adding folder items to
  214.  
  215.  
  216.  
  217. -- Gets invoked here when something is dropped on this AppleScript icon
  218. on open dropped_items
  219.     global debug
  220.     set debug to 2
  221.     -- Write a message into the event log.
  222.     log "  --- Starting on " & ((current date) as string) & " --- "
  223.     if debug ≥ 3 then log "in --- open ---"
  224.    
  225.     (*
  226.     -- Debug code.
  227.       set fileName to choose file with prompt "get file"
  228.       set dropped_items to {fileName}
  229.     *)
  230.     if debug ≥ 2 then log "class of dropped_items is " & class of dropped_items
  231.     display dialog "You dropped " & (count of dropped_items) & " item or items." & return & "  Caveat emptor. You have been warned." giving up after 6
  232.    
  233.     set totalFileData to ""
  234.     repeat with droppedItem in dropped_items
  235.         if debug ≥ 2 then
  236.             log "The droppedItem is "
  237.             -- display dialog "processing file " & (droppedItem as string) giving up after 3
  238.             log droppedItem
  239.             log "class = " & class of droppedItem
  240.         end if
  241.         set extIs to findExtension(droppedItem)
  242.         set extIsU to makeCaseUpper(extIs)
  243.         if extIsU is "HTML" or extIsU is "HTM" or extIsU is "TEXT" or extIsU is "TXT" then
  244.             try
  245.                 set theFile to droppedItem as string
  246.                 set theFile to open for access file theFile
  247.                 set allOfFile to read theFile
  248.                 close access theFile
  249.             on error theErrorMessage number theErrorNumber
  250.                 log "==> " & theErrorMessage & "error number " & theErrorNumber
  251.                 close access theFile
  252.             end try
  253.             if debug ≥ 2 then printHeader("read from file ( allOfFile )", allOfFile)
  254.             set totalFileData to totalFileData & common(allOfFile)
  255.         else
  256.             -- we do not support this extension
  257.             display dialog "We only support files with extenstion of html, htm, text or txt in either case. Your file had a " & extIs & " extention. Skipping" giving up after 10
  258.         end if
  259.     end repeat
  260.    
  261.     postToCLipboard(totalFileData)
  262.     -- return code
  263.     return 0
  264.    
  265. end open
  266.  
  267.  
  268. -- ------------------------------------------------------
  269. on common(clipboardData)
  270.     global debug
  271.     if debug ≥ 3 then log "in --- common ---"
  272.     set ht to character id 9
  273.     set lf to character id 10
  274.    
  275.     set cbInfo to get (clipboard info) as string
  276.    
  277.     set clipboardData to adjustCharacters(clipboardData)
  278.     (*
  279.     -- for some crazy reason, I found hex "090a" (HT LF) in a html file.
  280.     set clipboardData to alterString(clipboardData, ht & lf, lf)
  281.     -- don't let Windoze confuse us. convert Return LineFeed to lf
  282.     set clipboardData to alterString(clipboardData, return & lf, lf)
  283.     -- might as will convert classic macOS return to lf. We will have to look for less things.
  284.     set clipboardData to alterString(clipboardData, return, lf)
  285.     if debug ≥ 2 then hexDumpFormatOne("change various line ends to a LF. clipboardData", clipboardData)
  286.     *)
  287.    
  288.     -- figure out what type of data we have: plain text or html source code text.
  289.     set paraCount to count of textToList(clipboardData, "<p")
  290.     set endparaCount to count of textToList(clipboardData, "</p>")
  291.     set titleCount to count of textToList(clipboardData, "<title")
  292.     set endTitleCount to count of textToList(clipboardData, "</title>")
  293.     set aLinkCount to count of textToList(clipboardData, "href=\"http")
  294.     -- mangled href="http
  295.     set mangledLinkCount to count of textToList(clipboardData, "href=\\\"http")
  296.     set brCount to count of textToList(clipboardData, "<br>")
  297.     if debug ≥ 2 then
  298.         log "Values used to distinguis HTML source code from plain text."
  299.         log "paraCount  is " & paraCount
  300.         log "endparaCount is " & endparaCount
  301.         log "titleCount is " & titleCount
  302.         log "endTitleCount is " & endTitleCount
  303.         log "aLinkCount is " & aLinkCount
  304.         log "brCount is " & brCount
  305.         log "mangledLinkCount is " & mangledLinkCount
  306.     end if
  307.    
  308.     -- note, textToList returns a count one greater than the actual because item one is the data before the first found entry.
  309.     if paraCount ≥ 4 and endparaCount ≥ 3 or brCount ≥ 4 or ((titleCount is endTitleCount) and titleCount ≥ 2) or aLinkCount ≥ 3 or mangledLinkCount ≥ 3 then
  310.         -- ASC tends to convert line-ends to either <p></p> or <p><br></p>. Isn't desireable for HTML input
  311.         if debug ≥ 2 then log "... found HTML input ... (in plain text format )."
  312.         set clipboardData to adjustBrowserHTML(clipboardData)
  313.        
  314.     else
  315.         if debug ≥ 2 then log "... found plain Text input ..."
  316.         set clipboardData to typeText(clipboardData)
  317.     end if
  318.     set readyData to convertToHTML(clipboardData)
  319.     if debug ≥ 4 then log "bye from  -.- common -.-"
  320.     return readyData
  321. end common
  322.  
  323. -- ------------------------------------------------------  
  324. (* add paragraphs *)
  325. on addParagraphs(theOutputBuffer)
  326.     global debug
  327.     if debug ≥ 3 then log "in --- addParagraphs ---"
  328.     set lf to character id 10
  329.    
  330.     -- start the theOutputBuffer with a paragraph tag.  We are taking a simple approach at this time.
  331.     set theOutputBuffer to "<p>" & theOutputBuffer
  332.     --  LF
  333.     -- Remember CRLF was changed to LF above and CR was chanaged to LF above.
  334.     -- we don't want no Windoze problems
  335.     set theOutputBuffer to alterString(theOutputBuffer, lf & lf, "</p><p> </p><p>")
  336.    
  337.     -- Does the string end with a dangling paragraph?  
  338.     if debug ≥ 5 then
  339.         log "length of theOutputBuffer is " & length of theOutputBuffer
  340.     end if
  341.     if (length of theOutputBuffer) > (length of "</p>") then
  342.         if text ((length of theOutputBuffer) - 2) thru (length of theOutputBuffer) of theOutputBuffer is "<p>" then
  343.             set theOutputBuffer to text 1 thru ((length of theOutputBuffer) - 3) of theOutputBuffer
  344.         else if text ((length of theOutputBuffer) - 2) thru (length of theOutputBuffer) of theOutputBuffer is not "</p>" then
  345.             set theOutputBuffer to theOutputBuffer & "</p>"
  346.         end if
  347.     end if
  348.     if debug ≥ 4 then log "bye from  -.- addParagraphs -.-"
  349.     return theOutputBuffer
  350. end addParagraphs
  351.  
  352. -- ------------------------------------------------------
  353. (*
  354.   We received HTML class data on the clipboard.  This is the manager.
  355.   At this point, we expect only LFs in the text.
  356.  *)
  357. on adjustBrowserHTML(normalHtml)
  358.     global debug
  359.     if debug ≥ 3 then log "in --- adjustBrowserHTML ---"
  360.     set lf to character id 10
  361.    
  362.     set alteredHTML to adjustURLs(normalHtml)
  363.     set alteredHTML to adjustToAscHTML(alteredHTML)
  364.     if debug ≥ 4 then log "bye from  -.- adjustBrowserHTML -.-"
  365.     return alteredHTML
  366. end adjustBrowserHTML
  367.  
  368. -- ------------------------------------------------------
  369. (*
  370.     Symbol  Meaning                 Hex     Used
  371.         CR      Carriage Return         0d      classic Macintosh
  372.         LF      Line Feed                       0a      UNIX
  373.         CR/LF   Carriage Return/Line Feed   0d0a    MS-DOS, Windows, OS/2
  374.        
  375.     8230    U+2026  E2 80 A6    … Horizontal Ellipsis
  376.         https://www.charset.org/utf-8/9
  377.        &hellip;
  378.         https://www.toptal.com/designers/htmlarrows/punctuation/horizontal-ellipsis/
  379.  
  380.     *)
  381. on adjustCharacters(normalHtml)
  382.     global debug
  383.     set ht to character id 9 -- horizontal tab
  384.     set lf to character id 10
  385.     set ellipsis1 to character id 226
  386.     set ellipsis2 to character id 128
  387.     set ellipsis3 to character id 166
  388.    
  389.     if debug ≥ 3 then log "in --- adjustCharacters() ---"
  390.    
  391.     -- for some reason web broswers are having difficulty with utf-8 E2 80 A6
  392.     -- so convert to a HTML entity.  does work in <pre>
  393.     set normalHtml to alterString(normalHtml, ellipsis1 & ellipsis2 & ellipsis3, "&hellip;")
  394.    
  395.     -- don't let Windoze confuse us. convert Return LineFeed to lf
  396.     set normalHtml to alterString(normalHtml, return & lf, lf)
  397.     -- might as will convert classic macOS return to lf. We will have to look for less things.
  398.     set normalHtml to alterString(normalHtml, return, lf)
  399.     if debug ≥ 3 then hexDumpFormatOne("after altering characters normalHtml", normalHtml)
  400.     return normalHtml
  401. end adjustCharacters
  402.  
  403. -- ------------------------------------------------------
  404. -- called for HTML processing
  405. on adjustLF(theBuffer)
  406.     global debug
  407.     set ht to character id 9
  408.     set lf to character id 10
  409.     if debug ≥ 3 then log "in --- adjustLF() ---"
  410.     if debug ≥ 2 then hexDumpFormatOne("  adjustLF: input from theBuffer", theBuffer)
  411.     set numberOfLf to 1 -- for debuggin so we can display loop count
  412.    
  413.     set inputLfBuffer to theBuffer -- now, input data
  414.     set outputBuildLf to "" -- output data
  415.     -- copy & change
  416.     -- ditch leading LFs
  417.     repeat while length of inputLfBuffer ≥ 2 and text 1 thru 1 of inputLfBuffer is lf
  418.         if debug ≥ 2 then log "  adjustLF: found leading lf. current length of inputLfBuffer is " & getIntegerAndHex(length of inputLfBuffer)
  419.         -- just lob off LF
  420.         set inputLfBuffer to text 2 thru -1 of inputLfBuffer
  421.        
  422.         log "  adjustLF: next text character is " & text 1 thru 1 of inputLfBuffer
  423.     end repeat
  424.     -- for some crazy reason, I found hex "090a" (HT LF) in a html file.
  425.     set inputLfBuffer to alterString(inputLfBuffer, ht & lf, lf)
  426.     repeat until inputLfBuffer is ""
  427.        
  428.         set whereLfOffset to offset of lf in inputLfBuffer
  429.         if debug ≥ 2 then log "  adjustLF: whereLfOffset is " & whereLfOffset & " in hex " & integerToHex(whereLfOffset)
  430.        
  431.         -- get before and after characters if present.
  432.         if whereLfOffset ≥ 2 then
  433.             set priorCharacter to (text (whereLfOffset - 1) thru (whereLfOffset - 1) in inputLfBuffer)
  434.         else
  435.             set priorCharacter to ""
  436.         end if
  437.         if whereLfOffset ≥ (length of inputLfBuffer) then
  438.             -- no following character
  439.             set followingCharacter to ""
  440.         else
  441.             set followingCharacter to (text (whereLfOffset + 1) thru (whereLfOffset + 1) in inputLfBuffer)
  442.         end if
  443.         if debug ≥ 2 then log "  adjustLF: priorCharacter is >" & priorCharacter & "< followingCharacter is >" & followingCharacter & "<"
  444.        
  445.         -- process the LF. 
  446.         if (whereLfOffset is 1) and ((length of inputLfBuffer)2) then
  447.             set inputLfBuffer to text 2 thru -1 of inputLfBuffer
  448.             if debug ≥ 2 then log "  adjustLF: leading lf.  Got rid of it."
  449.             -- nothing to move to outputBuildLf            
  450.         else if (whereLfOffset is 1) and ((length of inputLfBuffer) is 1) then
  451.             -- we have found all theLFs to find.
  452.             set inputLfBuffer to ""
  453.             if debug ≥ 2 then log "  adjustLF: only one character left.  Got rid of it."
  454.         else if followingCharacter is "" then
  455.             if debug ≥ 2 then log "null"
  456.             -- didn't we just check this? Yes, but we need to iterate somehow.
  457.             set {inputLfBuffer, outputBuildLf} to trimOneChar(inputLfBuffer, outputBuildLf, whereLfOffset, " ")
  458.             -- just skip it, so we don't have to put anything on outputBuildLf
  459.         else if priorCharacter is not ">" and priorCharacter is not " " and followingCharacter is lf then
  460.             -- reduce a series of LFs to one blank
  461.             -- the next time around the next LF will be comparing to the prior character
  462.             -- as a blank
  463.             if debug ≥ 2 then log "  adjustLF: series of LFs"
  464.             set {inputLfBuffer, outputBuildLf} to trimOneChar(inputLfBuffer, outputBuildLf, whereLfOffset, " ")
  465.         else if priorCharacter is " " and followingCharacter is tab then
  466.             -- reduce a series of LFs to one blank
  467.             -- the next time around the next LF will be comparing to the prior character
  468.             -- as a blank
  469.             if debug ≥ 2 then log "  adjustLF: series of LFs"
  470.             set {inputLfBuffer, outputBuildLf} to trimOneChar(inputLfBuffer, outputBuildLf, whereLfOffset, "")
  471.             set {inputLfBuffer, outputBuildLf} to trimCharacters(inputLfBuffer, outputBuildLf, tab)
  472.         else if priorCharacter is ">" and followingCharacter is not " " then
  473.             --  LF after HTML tag. no real need for lf here.  asc tends to make these into <p></p>
  474.             if debug ≥ 2 then log "  adjustLF: found a tag"
  475.             -- copy prior stuff
  476.             set {inputLfBuffer, outputBuildLf} to trimOneChar(inputLfBuffer, outputBuildLf, whereLfOffset, "")
  477.         else if followingCharacter is lf then
  478.             -- prevent double LFs.
  479.             if debug ≥ 2 then log "  adjustLF: prevent double LFs at" & getIntegerAndHex(whereLfOffset)
  480.             set {inputLfBuffer, outputBuildLf} to trimOneChar(inputLfBuffer, outputBuildLf, whereLfOffset, "")
  481.             -- middle of text
  482.         else if (whereLfOffset < (length of inputLfBuffer)) and followingCharacter is " " then
  483.             -- we need to avoid double blanks
  484.             -- purge
  485.             if debug ≥ 2 then log "  adjustLF: getting rid of lf at " & getIntegerAndHex(whereLfOffset)
  486.             -- skip lf.
  487.             set {inputLfBuffer, outputBuildLf} to trimOneChar(inputLfBuffer, outputBuildLf, whereLfOffset, " ")
  488.             -- get read of leading spaces.  That is the spaces after the lf
  489.             set {inputLfBuffer, outputBuildLf} to trimCharacters(inputLfBuffer, outputBuildLf, " ")
  490.         else
  491.             -- assume there are character before and after the LF.
  492.             if debug ≥ 2 then log "  adjustLF: punt."
  493.             -- replace with blank
  494.             set {inputLfBuffer, outputBuildLf} to trimOneChar(inputLfBuffer, outputBuildLf, whereLfOffset, " ")
  495.         end if
  496.        
  497.         if debug ≥ 2 then
  498.             hexDumpFormatOne("  adjustLF: outputBuildLf of " & numberOfLf, outputBuildLf)
  499.             hexDumpFormatOne("  adjustLF: inputLfBuffer of " & numberOfLf, inputLfBuffer)
  500.         end if
  501.         -- next pass will be
  502.         set numberOfLf to numberOfLf + 1
  503.     end repeat
  504.     if debug ≥ 4 then log "bye from  -.- adjustLF() -.-"
  505.     return outputBuildLf
  506. end adjustLF
  507.  
  508. -- ------------------------------------------------------
  509. (* ASC likes to insert lots of white space into a page.
  510.   This routine attempt to fix up the html to avoid
  511.   all the extra white-space.
  512.  
  513.    Minimize the amount of white space inserted.
  514.  *)
  515.  
  516. on adjustToAscHTML(ascHtml)
  517.     global debug
  518.     if debug ≥ 3 then log "in --- adjustToAscHtml ---"
  519.     set lf to character id 10
  520.     set numberOfPres to 1
  521.     -- In the context of HTML, LF should mostly be insignificant.
  522.     -- Would be bad to change a LF inside the <pre>  tag.
  523.     --skip changing lf in "<pre>.  
  524.     set buildHtml to "" -- will contain the output
  525.     if debug ≥ 2 then log "find <pre>s"
  526.     -- copy & change
  527.     if (offset of "</pre>" in ascHtml) is not 0 then
  528.         repeat while (offset of "</pre>" in ascHtml) is not 0
  529.             -- get text before "<pre" tag
  530.             set splitString to item 1 of splitTextToList(ascHtml, "<pre")
  531.             if debug ≥ 2 then
  532.                 log "splitString is " & splitString
  533.                 hexDumpFormatOne("buildHtml *before* adjustLF()", buildHtml)
  534.             end if
  535.             set buildHtml to buildHtml & adjustLF(splitString)
  536.             hexDumpFormatOne("buildHtml after adjustLF()", buildHtml)
  537.            
  538.             -- lob off header text we processed
  539.             -- while we found the text before "<pre", we still need to get it out
  540.             -- of ascHtml
  541.             --  & gets rid of the token ("<pre"), so fix
  542.             set ascHtml to "<pre" & chompLeftAndTag(ascHtml, "<pre")
  543.            
  544.             -- any more <pre> tags?
  545.             if ascHtml is "" then
  546.                 display dialog "HTML missing </pre> tag. possible logic error." giving up after 10
  547.                 -- none. We have already adjusted buildHtml
  548.                 exit repeat -- ------ done processing ascHtml ------>
  549.             end if
  550.             if debug ≥ 2 then hexDumpFormatOne("remaining ascHtml is ", ascHtml)
  551.            
  552.             -- tack on the unaltered <pre>..</pre> stuff
  553.             set buildHtml to buildHtml & (item 1 of splitTextToList(ascHtml, "</pre>")) & "</pre>"
  554.             if debug ≥ 2 then hexDumpFormatOne("buildHtml after finding </pre>", buildHtml)
  555.            
  556.             set ascHtml to chompLeftAndTag(ascHtml, "</pre>")
  557.             if debug ≥ 2 then hexDumpFormatOne("ascHtml end of " & numberOfPres & " pass", ascHtml)
  558.             set numberOfPres to numberOfPres + 1
  559.            
  560.         end repeat
  561.         -- remainder
  562.         set buildHtml to buildHtml & adjustLF(ascHtml)
  563.         set ascHtml to ""
  564.     else
  565.         -- lf's are only signigicant in <pre>...</pre>
  566.         if debug ≥ 2 then log "didn't find a <pre>"
  567.         -- all others are white space.
  568.         set buildHtml to adjustLF(ascHtml)
  569.         set ascHtml to "" -- input text processed
  570.     end if
  571.    
  572.    
  573.     (*
  574.     Hack about to fix ASC interpretation of HTML.
  575.    
  576.     ASC alters the definition of a paragraph to have not space before or after the paragraph.
  577.     A paragraph like <p></p> works like a <br>.
  578.    
  579.     Consequently, ASC converts <p> </p> to <p><br></p>, that is a
  580.     space only paragraph to a paragraph with a <br> in it.
  581.    
  582.     the code converts one tag on a line to a line of tags.
  583.     </ol>
  584.     </p>
  585.     <p>
  586.     converted form
  587.     </ol></p><p>
  588.    
  589.     so that means a change on </ol></p><p> converts both the multi-lines form and the single line form.
  590.    
  591.     *)
  592.     set buildHtml to alterString(buildHtml, "<br> ", "<br>")
  593.     -------------------- failure???
  594.     --set buildHtml to alterString(buildHtml, "<p> ", "<p>")
  595.    
  596.     -- asc paragraphs don't generate space before and after the paragraph.
  597.     set buildHtml to alterString(buildHtml, "</p><p></p><p></p>", "</p><p> </p><p></p>")
  598.    
  599.     set buildHtml to alterString(buildHtml, "</p><p></p><p></p>", "</p><p> </p><p></p>")
  600.    
  601.     set buildHtml to alterString(buildHtml, "</ol></p><p>", "</ol><p> </p></p><p>")
  602.     (*
  603.     surprisingly ASC converts <p> </p> to <p><br></p>, that is a
  604.     space only paragraph to a paragraph with a <br> in it.
  605.    
  606.     the code converts one tag on a line to a line of tags.
  607.     </ol>
  608.     </p>
  609.     <p>
  610.     converted form
  611.     </ol></p><p>
  612.    
  613.     so that means a change on </ol></p><p> converts both the multi-lines form and the single line form.
  614.    
  615.     *)
  616.     --set buildHtml to alterString(buildHtml, "<p> </p>", "<p></p>")
  617.     if debug ≥ 2 then hexDumpFormatOne("complete buildHtml ", buildHtml)
  618.     if debug ≥ 4 then log "bye from  -.- adjustToAscHTML -.-"
  619.     return buildHtml
  620. end adjustToAscHTML
  621.  
  622. -- ------------------------------------------------------
  623. (*
  624. example:
  625.   Free version of Parallels for individual use:</p><p><br></p>
  626.   <p>https://itunes.apple.com/us/app/parallels-desktop-lite/id1085114709?mt=12</p>
  627.   <p><br></p>
  628.   <p>Full version</p><p><a href="http://www.parallels.com/en/products/desktop/" target="_blank">
  629.      http://www.parallels.com/en/products/desktop/</a>
  630.      
  631. If asc find a URL outside of an a tag, it will place blank lines around the URL. No, it will not go the
  632. full nine yards and place an a tag around the url.
  633.  
  634. *)
  635. on adjustURLs(theOriginalInputBuffer)
  636.     global debug
  637.     if debug ≥ 3 then log "in --- adjustURLs ---"
  638.     set alteredBuffer to false
  639.     set lf to character id 10
  640.     set theInputBuffer to theOriginalInputBuffer
  641.     if debug ≥ 2 then hexDumpFormatOne("  adjustURLs: theInputBuffer", theInputBuffer)
  642.    
  643.     -- we end up in a lot of grief when the buffer ends without
  644.     -- a line-end
  645.     if text (length of theInputBuffer) thru (length of theInputBuffer) of theInputBuffer is not lf then
  646.         -- tack LF at the end
  647.         set alteredBuffer to true
  648.         set theInputBuffer to theInputBuffer & lf
  649.         if debug ≥ 2 then hexDumpFormatOne("  adjustURLs: theInputBuffer", theInputBuffer)
  650.     end if
  651.    
  652.     set buildHtml to ""
  653.     if debug ≥ 5 then log "  adjustURLs: buildHTML [ should be empty string ] is " & buildHtml
  654.     set countI to 1 -- variable is used for debuging.
  655.     -- do until we have processed theInputBuffer
  656.     repeat until theInputBuffer is ""
  657.         if debug ≥ 2 then log "  adjustURLs: at the top of theInputBuffer ........."
  658.        
  659.         set foundWhere to {}
  660.         repeat with lookCharacters in {"https://", "http://", "<a "}
  661.             copy (offset of lookCharacters in theInputBuffer) to the end of the foundWhere
  662.             try
  663.                 set tempLoc to (offset of lookCharacters in theInputBuffer)
  664.                 if debug ≥ 2 then log "  adjustURLs: searching for " & lookCharacters & " found at offset  " & tempLoc & " contains " & text tempLoc thru (tempLoc + ((length of lookCharacters) - 1)) of theInputBuffer
  665.             end try
  666.         end repeat
  667.         if debug ≥ 2 then log foundWhere
  668.         set foundMarkerOffset to (minimumPositiveNumber from foundWhere)
  669.         -- figure out what type of marker we got?
  670.        
  671.         -- None.  Reached the end of the data without finding one.
  672.         if foundMarkerOffset ≤ 0 then
  673.             -- we are done
  674.             if debug ≥ 2 then log "  adjustURLs: Found all links."
  675.             set buildHtml to buildHtml & theInputBuffer
  676.             if debug ≥ 2 then printHeader("  adjustURLs: buildHTML", buildHtml)
  677.             set theInputBuffer to ""
  678.             exit repeat -- ------ done processing theInputBuffer ------>
  679.         end if
  680.        
  681.         -- find which of three markers we found.
  682.         if (text foundMarkerOffset thru (foundMarkerOffset + 2) of theInputBuffer) is "<a " then
  683.             set actualMarker to "<a "
  684.         else if text foundMarkerOffset thru (foundMarkerOffset + 6) of theInputBuffer is "http://" then
  685.             set actualMarker to "http://"
  686.         else
  687.             -- just assume it's the remaining "https://" since we looked for just three.
  688.             set actualMarker to "https://"
  689.         end if
  690.         set actualMarkerOffsetLength to ((length of actualMarker) - 1)
  691.         if debug ≥ 2 then
  692.             log "  adjustURLs: actualMarker is " & actualMarker & " actualMarkerOffsetLength is " & actualMarkerOffsetLength
  693.             log "  adjustURLs: foundMarkerOffset is " & getIntegerAndHex(foundMarkerOffset) & "  verify marker text is " & text foundMarkerOffset thru (foundMarkerOffset + actualMarkerOffsetLength) of theInputBuffer
  694.         end if
  695.        
  696.        
  697.         if foundMarkerOffset ≥ 2 then
  698.             -- collect and strip off characters that are before the marker.
  699.             if debug ≥ 2 then
  700.                 log "  adjustURLs: buildHTML is " & buildHtml & " length is " & getIntegerAndHex(length of buildHtml)
  701.                 hexDumpFormatOne("  adjustURLs: theInputBuffer", theInputBuffer)
  702.                 log "  adjustURLs:  (foundMarkerOffset - 1) is " & getIntegerAndHex((foundMarkerOffset - 1))
  703.             end if
  704.             -- get the proceding text
  705.             set buildHtml to buildHtml & text 1 thru (foundMarkerOffset - 1) of theInputBuffer
  706.             if debug ≥ 2 then
  707.                 log "  adjustURLs: buildHTML is " & buildHtml
  708.                 hexDumpFormatOne("  adjustURLs: buildHTML", buildHtml)
  709.             end if
  710.            
  711.             -- https://apple.stackexchange.com/a/20135/44531
  712.            
  713.             set theInputBuffer to text foundMarkerOffset thru -1 of theInputBuffer --trim off character before what we found
  714.             if debug ≥ 2 then
  715.                 printHeader("  adjustURLs: theInputBuffer", theInputBuffer)
  716.                 hexDumpFormatOne("  adjustURLs: theInputBuffer", theInputBuffer)
  717.             end if
  718.         else
  719.             log "  adjustURLs: ==> no proceeding data."
  720.         end if
  721.        
  722.         repeat 1 times -- interate loop
  723.            
  724.             -- example" the url is also the display text
  725.             -- <a href="https://discussions.apple.com/docs/DOC-8841" target="_blank">https://discussions.apple.com/docs/DOC-8841</a>
  726.             if debug ≥ 2 then hexDumpFormatOne("  adjustURLs: theInputBuffer", theInputBuffer)
  727.            
  728.             -- check for the <a> tag
  729.             if text 1 thru (length of "<a ") of theInputBuffer is "<a " then
  730.                 -- found <a> tag
  731.                 if debug ≥ 2 then log "  adjustURLs: processing <a> tag"
  732.                 -- ASC consider a line-end as a <br> when when firefox considers it a blank
  733.                 -- change a possible line-end before an <a> tag to a " "
  734.                 if debug ≥ 2 then hexDumpFormatOne("  adjustURLs: before lf check buildHTML", buildHtml)
  735.                 if text (length of buildHtml) thru (length of buildHtml) of buildHtml is lf then
  736.                     if debug ≥ 2 then log "  adjustURLs: we need to delete a line-end before the <a> tag"
  737.                     set buildHtml to text 1 thru ((length of buildHtml) - 1) of buildHtml
  738.                     set buildHtml to buildHtml & " "
  739.                     if debug ≥ 2 then hexDumpFormatOne("  adjustURLs: after lf deletion buildHTML", buildHtml)
  740.                 end if
  741.                 -- find ending </a> tag
  742.                 set whereEnds to offset of "</a>" in theInputBuffer
  743.                 if whereEnds ≤ 0 then
  744.                     if debug ≥ 2 then log "  adjustURLs: ==> found an error in the HTML.  no ending </a>"
  745.                     set buildHtml to buildHtml & theInputBuffer
  746.                     printHeader("  adjustURLs: buildHTML", buildHtml)
  747.                     set theInputBuffer to ""
  748.                     display dialog "  adjustURLs: Found an error in the HTML.  No ending </a>.  Will skip." giving up after 10
  749.                     exit repeat -- ------ next ------>
  750.                 end if
  751.                 set lastOffsetLength to ((length of "</a>") - 1)
  752.                 if debug ≥ 2 then log "  adjustURLs: lastOffsetLength is " & lastOffsetLength
  753.                 set lastCharacterOffset to whereEnds + lastOffsetLength
  754.                 if debug ≥ 2 then log "  adjustURLs: lastCharacterOffset is " & lastCharacterOffset
  755.                 -- needs to copy the ending ">"
  756.                 set anchorString to text 1 thru lastCharacterOffset of theInputBuffer
  757.                 -- don't let Windoze confuse us. convert Return LineFeed to lf
  758.                 -- Correct absure ASC bug where there is a line-end in the <a> text.
  759.                 if debug ≥ 2 then hexDumpFormatOne("  adjustURLs: before adjusting anchorString", anchorString)
  760.                 set anchorString to alterString(anchorString, lf, " ")
  761.                 if debug ≥ 2 then hexDumpFormatOne("  adjustURLs: anchorString", anchorString)
  762.                 --
  763.                 -- fix up mangled url
  764.                 -- be a nice guy for RW -???-
  765.                 -- Waterfox fixes up!
  766.                 --  
  767.                 set buildHtml to buildHtml & anchorString
  768.                 if debug ≥ 2 then hexDumpFormatOne("  adjustURLs: buildHTML", buildHtml)
  769.                 -- https://apple.stackexchange.com/a/20135/44531
  770.                 -- We want first character of the "next" portion of theInputBuffer so add one
  771.                 set theInputBuffer to text (lastCharacterOffset + 1) thru -1 of theInputBuffer --trim out <a>
  772.                 if debug ≥ 2 then hexDumpFormatOne("  adjustURLs: theInputBuffer", theInputBuffer)
  773.                 -- Web Browsers like Firefox convert a line-end in text to a space.
  774.                 if text 1 thru 1 of theInputBuffer is lf then
  775.                     if (length of theInputBuffer) is 1 then
  776.                         set theInputBuffer to " "
  777.                     else
  778.                         set theInputBuffer to " " & (text 2 thru (length of theInputBuffer) of theInputBuffer)
  779.                         if debug ≥ 2 then hexDumpFormatOne("  adjustURLs: after lf deletion; theInputBuffer", theInputBuffer)
  780.                     end if
  781.                 end if
  782.                 exit repeat -- ------ next ------>
  783.             end if
  784.            
  785.             -- find the end of the HTML URL by splitting on blank or return
  786.             -- unsafe characters  <blank> " < > # % { } | \ ^ ~ [ ] `
  787.             -- and line-end
  788.             -- while # is listed as unsafe, it does appear in a url as a marker of some sort.
  789.             -- leave it out as an ending character.
  790.             -- https://perishablepress.com/stop-using-unsafe-characters-in-urls/
  791.             -- the end of the clipboard string my end after the url, hence no " ", LF or CR
  792.             -- Rember, CRLF was converted to LF above
  793.             set endsWhere to {}
  794.             -- the end of the url ends with one of the not allowed characters + line-end
  795.             repeat with unsafeCharacter in {" ", "\"", lf, "<", ">", "%", "{", "}", "|", "\\", "^", "~", "[", "]"}
  796.                 copy (offset of unsafeCharacter in theInputBuffer) to the end of the endsWhere
  797.             end repeat
  798.             if debug ≥ 2 then log endsWhere
  799.             set endOfURL to (minimumPositiveNumber from endsWhere) - 1
  800.            
  801.             if debug ≥ 2 then log "  adjustURLs: endOfURL is " & endOfURL
  802.            
  803.             if endOfURL ≤ 0 then
  804.                 -- We have reached the end of the input
  805.                 set theURL to theInputBuffer
  806.                 set theInputBuffer to ""
  807.             else
  808.                 set theURL to text 1 thru endOfURL of theInputBuffer
  809.                 if debug ≥ 2 then log "  adjustURLs: from middle theURL is " & theURL
  810.                
  811.                 set theInputBuffer to text (endOfURL + 1) thru -1 of theInputBuffer -- trim off url in front.
  812.             end if
  813.             if debug ≥ 2 then printHeader("  adjustURLs: printHeader", theInputBuffer)
  814.             if debug ≥ 1 then log "  adjustURLs: ----------------------- " & theURL & " -----------------------"
  815.             (*
  816.             retrieve the file pointed to by the URL so we can
  817.             get the title. Note: <title> can have attributes.  Example:
  818.                
  819.             <title data-test-page-title="Parallels Desktop Lite on the Mac App Store"
  820.             >‎Parallels Desktop Lite on the Mac App Store</title>
  821.            
  822.             *)
  823.            
  824.             -- Example:
  825.             -- curl --silent --location --max-time 10 <URL>
  826.             set toUnix to "curl --silent --location --max-time 10 " & quoted form of theURL
  827.             if debug ≥ 2 then log "  adjustURLs: what we will use to retrieve the Url. toUnix  is " & return & "  " & toUnix
  828.             try
  829.                 if debug ≥ 2 then log "  adjustURLs: reading link file to get title"
  830.                 set fromUnix to do shell script toUnix
  831.                 --log "fromUnix:"
  832.                 if debug ≥ 2 then
  833.                     printHeader("  adjustURLs: fromUnix", fromUnix)
  834.                     -- may not be working with an HTLM document, so thefound title may be too long or confused.
  835.                     log "  adjustURLs: how far?..."
  836.                 end if
  837.                 -- there could be some bagage with the <title
  838.                 set actualTagData to tagContent(fromUnix, "<title", "</title>")
  839.                 -- Find what we will actually display in the title.
  840.                 -- Fix up gotchas.             
  841.                 if debug ≥ 2 then log "  adjustURLs: actualTagData  is " & printHeader("actualTagData", actualTagData)
  842.                 if actualTagData is "" then
  843.                     set actualTagData to theURL
  844.                 else if length of actualTagData > 140 then
  845.                     if debug ≥ 2 then log "  adjustURLs: length of actualTagData is " & length of actualTagData & "which is too long.  Truncated."
  846.                     set actualTagData to theURL
  847.                     -- curl https://appleid.apple.com returns <title>403 Forbidden</title>
  848.                     -- which is misleading.
  849.                 else if actualTagData contains "403" and actualTagData contains "Forbidden" then
  850.                     log "  adjustURLs:  found 403 web page."
  851.                     set actualTagData to theURL
  852.                 else
  853.                     -- there could be some attributes within the <title> tag.
  854.                     -- or there could not be
  855.                     -- an attribute could have a > in it. ignoring that for now.
  856.                     try
  857.                         -- find where <title ends
  858.                         set whereToEnd to (offset of ">" in actualTagData)
  859.                         if debug ≥ 2 then log "  adjustURLs: whereToEnd is " & whereToEnd
  860.                         set whereToBegin to whereToEnd + (length of ">")
  861.                         if debug ≥ 2 then log "  adjustURLs: whereToBegin is " & whereToBegin
  862.                         hexDumpFormatOne("  adjustURLs: actualTagData", actualTagData)
  863.                         set actualTagData to text whereToBegin thru (length of actualTagData) of actualTagData
  864.                         if debug ≥ 2 then log "  adjustURLs: actualTagData is " & actualTagData
  865.                     on error theErrorMessage number theErrorNumber
  866.                         log "  adjustURLs: ==>No ending greater than (>) for title. Badly contructed html." & return & "message is " & theErrorMessage & "error number " & theErrorNumber
  867.                         set actualTagData to actualTagData
  868.                         -- no need to repair.  It's not our page.
  869.                     end try
  870.                    
  871.                     -- found line-end in title.  caused confustion.
  872.                     -- note: this is new data and the multiple line-ends have not been
  873.                     -- filtered out.
  874.                     -- some joker had a line-end in the title!
  875.                     if debug ≥ 3 then
  876.                         log "  adjustURLs: actualTagData (title) has been chanaged which is  " & actualTagData
  877.                         hexDumpFormatOne("  adjustURLs: actualTagData (title)", actualTagData)
  878.                     end if
  879.                     set actualTagData to alterString(actualTagData, return & lf, lf)
  880.                     set actualTagData to alterString(actualTagData, return, lf)
  881.                     set actualTagData to adjustLF(actualTagData)
  882.                     if debug ≥ 2 then
  883.                         log "  adjustURLs: actualTagData (title) has been chanaged which is  " & actualTagData
  884.                         hexDumpFormatOne("  adjustURLs: actualTagData (title)", actualTagData)
  885.                     end if
  886.                    
  887.                 end if
  888.             on error errMsg number n
  889.                 display dialog "  adjustURLs: ==> Error occured when looking for title. " & errMsg & " with number " & n giving up after 10
  890.                 log "  adjustURLs: ==> Error occured when looking for title. " & errMsg & " with number " & n
  891.                 set actualTagData to theURL
  892.             end try
  893.             -- why the _blank in the <a>?
  894.             set assembled to "<a href=\"" & theURL & "\" target=\"_blank\">" & actualTagData & "</a>"
  895.             if debug ≥ 2 then log "  adjustURLs: assembled  is " & assembled
  896.            
  897.             if (length of theInputBuffer)0 then
  898.                 -- We have reached the end of the input
  899.                 if debug ≥ 2 then log "  adjustURLs: we have reached the end of the input."
  900.                 set buildHtml to buildHtml & assembled
  901.             else
  902.                 if debug ≥ 2 then log "  adjustURLs: more input to process"
  903.                 set buildHtml to buildHtml & assembled
  904.             end if
  905.            
  906.             -- wrap up
  907.             --log "transformed text from buildHTML is  " & return & buildHTML
  908.             if debug ≥ 2 then log "  adjustURLs: #" & countI & " transformed text from buildHTML is  " & return & buildHtml
  909.             -- number of links found
  910.             set countI to countI + 1
  911.            
  912.         end repeat -- used to interate
  913.     end repeat -- processing links in the input text
  914.     if alteredBuffer is true then
  915.         -- chop off the lf we added above.
  916.         set buildHtml to text 1 thru ((length of buildHtml) - 1) of buildHtml
  917.         set alteredBuffer to false -- somewhat redundant
  918.     end if
  919.     if debug ≥ 4 then log "bye from  -.- adjustURLs -.-"
  920.     return the buildHtml
  921.    
  922. end adjustURLs
  923.  
  924. -- ------------------------------------------------------
  925. (*
  926. alterString
  927.   thisText is the input string to change
  928.   delim is what string to change.  It doesn't have to be a single character.
  929.   replacement is the new string
  930.  
  931.   returns the changed string.
  932. *)
  933.  
  934. on alterString(thisText, delim, replacement)
  935.     global debug
  936.     if debug ≥ 5 then log "in ~~~ alterString ~~~"
  937.     set resultList to {}
  938.     set {tid, my text item delimiters} to {my text item delimiters, delim}
  939.     try
  940.         set resultList to every text item of thisText
  941.         set text item delimiters to replacement
  942.         set resultString to resultList as string
  943.         set my text item delimiters to tid
  944.     on error
  945.         set my text item delimiters to tid
  946.     end try
  947.     return resultString
  948. end alterString
  949.  
  950. -- ------------------------------------------------------
  951. (*
  952.   Return the text to the right of theToken.
  953. *)
  954. on answerAndChomp(theString, theToken)
  955.     global debug
  956.     if debug ≥ 5 then log "in ~~~ answerAndChomp ~~~"
  957.     set debugging to false
  958.     set theOffset to offset of theToken in theString
  959.     if debug ≥ 6 then log "theOffset is " & theOffset
  960.     set theLength to length of theString
  961.     if theOffset > 0 then
  962.         set beginningPart to text 1 thru (theOffset - 1) of theString
  963.         if debug ≥ 6 then log "beginningPart is " & beginningPart
  964.        
  965.         set chompped to text theOffset thru theLength of theString
  966.         if debug ≥ 6 then log "chompped is " & chompped
  967.         return {chompped, beginningPart}
  968.     else
  969.         set beginningPart to ""
  970.         return {theString, beginningPart}
  971.     end if
  972.    
  973. end answerAndChomp
  974.  
  975. -- ------------------------------------------------------
  976. (*
  977.   Delete the leading part of the string until and including theToken.
  978. *)
  979. on chompLeftAndTag(theString, theToken)
  980.     global debug
  981.     if debug ≥ 6 then log "in --- chompLeftAndTag ---"
  982.     if debug ≥ 5 then
  983.         log "theToken is " & theToken
  984.         hexDumpFormatOne("theString", theString)
  985.     end if
  986.     set theOffset to offset of theToken in theString
  987.     if debug ≥ 5 then log "theOffset is " & theOffset & " in hex is " & integerToHex(theOffset)
  988.     set theLength to length of theString
  989.     if debug ≥ 5 then log "theLength is " & theLength & " in hex is " & integerToHex(theLength)
  990.    
  991.     if theOffset > 0 then
  992.         -- Do we have any more of the string to return?
  993.         if (theOffset + (length of theToken)) ≤ length of theString then
  994.             set chompped to text (theOffset + (length of theToken)) thru theLength of theString
  995.         else
  996.             set chompped to ""
  997.         end if
  998.         if debug ≥ 5 then log "length of chompped is " & length of chompped & "chompped is " & chompped
  999.         return chompped
  1000.     else
  1001.         return ""
  1002.     end if
  1003. end chompLeftAndTag
  1004.  
  1005. -- ------------------------------------------------------
  1006. on convertToHTML(theData)
  1007.     global debug
  1008.     if debug ≥ 3 then log "in --- convertToHTML ---" & return & "  Try to send back HTML. the processed data in variable theData is " & theData
  1009.     try
  1010.         set clipboardDataQuoted to quoted form of theData
  1011.        
  1012.         if debug ≥ 1 then
  1013.             log "  convertToHTMLz: .... data soon to be returned ...." & return & "clipboardDataQuoted is " & return & clipboardDataQuoted
  1014.             hexDumpFormatOne("clipboardDataQuoted", clipboardDataQuoted)
  1015.         end if
  1016.         -- make hex string as required for HTML data on the clipboard
  1017.         set toUnix to "/bin/echo -n " & clipboardDataQuoted & " | hexdump -ve '1/1 \"%.2x\"'"
  1018.         if debug ≥ 5 then printHeader("  convertToHTMLz: toUnix to convert to hex", toUnix)
  1019.         set fromUnix to do shell script toUnix
  1020.        
  1021.         if debug ≥ 5 then printHeader("  convertToHTMLz: fromUnix", fromUnix)
  1022.        
  1023.         if debug ≥ 5 then
  1024.             log "  convertToHTMLz: displaying original string -- so we can tell if it converted successfully. "
  1025.             --hexDumpFormatOne("fromUnix", fromUnix)
  1026.         end if
  1027.     on error errMsg number n
  1028.         log "  convertToHTMLz: ==> convert to hex string failed. " & errMsg & " with number " & n
  1029.         set fromUnix to ""
  1030.     end try
  1031.     if debug ≥ 4 then log "bye from  -.- convertToHTML -.-"
  1032.     return fromUnix
  1033. end convertToHTML
  1034.  
  1035. -- ------------------------------------------------------  
  1036. (*
  1037. Yvan Koenig
  1038. https://macscripter.net/viewtopic.php?id=43133
  1039. *)
  1040. on findExtension(inputFileName)
  1041.     global debug
  1042.     if debug ≥ 5 then log "in ~~~ indExtension ~~~"
  1043.     set fileName to inputFileName as string
  1044.     set saveTID to AppleScript's text item delimiters
  1045.     set AppleScript's text item delimiters to {"."}
  1046.     set theExt to last text item of fileName
  1047.     set AppleScript's text item delimiters to saveTID
  1048.     --log "theExt is " & theExt
  1049.     if theExt ends with ":" then set theExt to text 1 thru -2 of theExt
  1050.     if debug ≥ 5 then log "theExt is " & theExt
  1051.     return theExt
  1052. end findExtension
  1053.  
  1054. -- ------------------------------------------------------
  1055. (*
  1056. length of inputLfBuffer & " in hex " & integerToHex(length of inputLfBuffer)
  1057. *)
  1058. on getIntegerAndHex(aNumber)
  1059.     global debug
  1060.     if debug ≥ 5 then log "in ~~~ getIntegerAndHex ~~~"
  1061.    
  1062.     return aNumber & " in Hex " & integerToHex(aNumber)
  1063. end getIntegerAndHex
  1064.  
  1065. -- ------------------------------------------------------
  1066. (*
  1067.   http://krypted.com/mac-os-x/to-hex-and-back/
  1068.                0    2    4    6    8    a    c    e     0 2 4 6 8 a c e
  1069. 0000000:   3c 703e 5369 6d70 6c65 2070 7574 2c20   <p>Simple put,
  1070.             *)
  1071. on hexDumpFormatOne(textMessage, hex)
  1072.     global debug
  1073.    
  1074.     set aNul to character id 1
  1075.    
  1076.     if debug ≥ 5 then log "in ~~~ hexDumpFormatOne ~~~"
  1077.     if debug ≥ 7 then log "    hexDumpFormatOne: input string is " & return & hex
  1078.    
  1079.     -- -r -p
  1080.     set displayValue to aNul & hex
  1081.     set toUnix to "/bin/echo -n " & (quoted form of displayValue) & " | xxd  "
  1082.     if debug ≥ 7 then log "    hexDumpFormatOne: toUnix is " & toUnix
  1083.    
  1084.     try
  1085.         set fromUnix to do shell script toUnix
  1086.        
  1087.         -- two hex digits
  1088.         set displayText to replaceCharacter(fromUnix, 10, "  ")
  1089.         if debug ≥ 7 then
  1090.             log "    hexDumpFormatOne: " & return & displayText
  1091.             log "    hexDumpFormatOne: length of displayText is " & length of displayText
  1092.         end if
  1093.         -- one character
  1094.         set displayText to replaceCharacter(displayText, 51, " ")
  1095.         if debug ≥ 7 then
  1096.             log "    hexDumpFormatOne: " & return & displayText
  1097.             log "    hexDumpFormatOne: almost there ..... length of displayText is " & length of displayText
  1098.         end if
  1099.         log "variable " & textMessage & " in hex is " & return & "         0    2    4    6    8    a    c    e     0 2 4 6 8 a c e" & return & displayText
  1100.     on error errMsg number n
  1101.         log "    hexDumpFormatOne: ==> convert hex string to string failed. " & errMsg & " with number " & n
  1102.     end try
  1103.     if debug ≥ 7 then
  1104.         log "leaving ~.~ hexDumpFormatOne ~.~"
  1105.     end if
  1106. end hexDumpFormatOne
  1107.  
  1108. -- ------------------------------------------------------
  1109. on hexDumpFormatZero(textMessage, hex)
  1110.     global debug
  1111.     if debug ≥ 5 then log "in ~~~ hexDumpFormatZero ~~~"
  1112.     if debug ≥ 5 then log "input string is " & hex
  1113.     -- -r -p
  1114.     set toUnix to "/bin/echo -n " & (quoted form of hex) & " | xxd  "
  1115.     if debug ≥ 5 then log "toUnix is " & toUnix
  1116.     try
  1117.         set displayText to do shell script toUnix
  1118.        
  1119.         log "variable " & textMessage & " in hex is " & return & "         0    2    4    6    8    a    c    e     0 2 4 6 8 a c e" & return & displayText
  1120.     on error errMsg number n
  1121.         log "==> convert hex string to string failed. " & errMsg & " with number " & n
  1122.     end try
  1123. end hexDumpFormatZero
  1124.  
  1125. -- ------------------------------------------------------
  1126. (*
  1127. https://macscripter.net/viewtopic.php?id=43713
  1128.   *)
  1129. on integerToHex(nDec)
  1130.     global debug
  1131.     if debug ≥ 5 then log "in ~~~ integerToHex ~~~"
  1132.     try
  1133.         set nHex to do shell script "perl -e 'printf(\"%X\", " & nDec & ")'" --> "F0"
  1134.     on error errMsg number n
  1135.         log "==> convert integer to hex. " & errMsg & " with number " & n
  1136.         set nHex to ""
  1137.     end try
  1138.     return nHex
  1139. end integerToHex
  1140.  
  1141. -- ------------------------------------------------------
  1142. (*
  1143.  
  1144. https://stackoverflow.com/questions/55838252/minimum-value-that-not-zero
  1145.        set m to get minimumPositiveNumber from {10, 2, 0, 2, 4}
  1146.     log "m is " & m
  1147.     set m to minimumPositiveNumber from {0, 0, 0}
  1148.     log "m is " & m
  1149. *)
  1150. on minimumPositiveNumber from L
  1151.     global debug
  1152.     if debug ≥ 5 then log "in ~~~ minimumPositiveNumber ~~~"
  1153.     local L
  1154.    
  1155.     if L = {} then return null
  1156.    
  1157.     set |ξ| to 0
  1158.    
  1159.     repeat with x in L
  1160.         set x to x's contents
  1161.         if (x < |ξ| and x ≠ 0) ¬
  1162.             or |ξ| = 0 then ¬
  1163.             set |ξ| to x
  1164.     end repeat
  1165.    
  1166.     |ξ|
  1167. end minimumPositiveNumber
  1168.  
  1169. -- ------------------------------------------------------
  1170. (*
  1171.   makeCaseUpper("Now is the time, perhaps, for all good men")
  1172. *)
  1173. on makeCaseUpper(theString)
  1174.     global debug
  1175.     if debug ≥ 5 then log "in ~~~ makeCaseUpper ~~~"
  1176.     set UC to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  1177.     set LC to "abcdefghijklmnopqrstuvwxyz"
  1178.     set C to characters of theString
  1179.     repeat with ch in C
  1180.         if ch is in LC then set contents of ch to item (offset of ch in LC) of UC
  1181.     end repeat
  1182.     return C as string
  1183. end makeCaseUpper
  1184.  
  1185. -- ------------------------------------------------------
  1186. on postToCLipboard(pleasePost)
  1187.     global debug
  1188.     if debug ≥ 5 then log "in ~~~ postToCLipboard ~~~"
  1189.     try
  1190.         -- osascript -e "set the clipboard to «data HTML${hex}»"     
  1191.         set toUnixSet to "osascript -e \"set the clipboard to «data HTML" & pleasePost & \""
  1192.         if debug ≥ 5 then log "  postToCLipboard: toUnixSet is " & printHeader("toUnixSet", toUnixSet)
  1193.        
  1194.         set fromUnixSet to do shell script toUnixSet
  1195.         if debug ≥ 5 then log "  postToCLipboard: fromUnixSet is " & fromUnixSet
  1196.        
  1197.     on error errMsg number n
  1198.         log "  postToCLipboard: ==> We tried to send back HTML data, but failed. " & errMsg & " with number " & n
  1199.     end try
  1200.     -- see what ended up on the clipboard
  1201.     set theList2 to clipboard info
  1202.     if debug ≥ 2 then printClipboardInfo(theList2)
  1203. end postToCLipboard
  1204.  
  1205. -- ------------------------------------------------------
  1206. on printClipboardInfo(theList)
  1207.     global debug
  1208.     if debug ≥ 5 then log "in ~~~ printClipboardInfo ~~~"
  1209.     log (clipboard info)
  1210.     log class of theList
  1211.     log "Data types on the clipboard ... "
  1212.     printList("", theList)
  1213.     log "... "
  1214. end printClipboardInfo
  1215.  
  1216. -- ------------------------------------------------------
  1217. (* Pump out the beginning of theString *)
  1218. on printHeader(theName, theString)
  1219.     global debug
  1220.     if debug ≥ 5 then
  1221.         log "in ~~~ printHeader ~~~"
  1222.         log "theName is " & theName
  1223.         log theString
  1224.         log "length of theString is " & length of theString
  1225.     end if
  1226.     if length of theString ≤ 0 then
  1227.         log "==> no string to print"
  1228.     else
  1229.         log theName & " is " & return & text 1 thru (minimumPositiveNumber from {400, length of theString}) of theString & "<+++++++++"
  1230.     end if
  1231. end printHeader
  1232.  
  1233. -- ------------------------------------------------------
  1234. (*
  1235. print out the items in a list
  1236.  
  1237. *)
  1238.  
  1239. on printList(theName, splits)
  1240.     global debug
  1241.     if debug ≥ 5 then log "in ~~~ printList ~~~"
  1242.     try
  1243.         set theCount to 1
  1244.         repeat with theEntry in splits
  1245.             --log "class of theEntry is " & class of theEntry
  1246.             set classDisplay to class of theEntry as text
  1247.             --log "classDisplay is " & classDisplay as text
  1248.             --log "class of classDisplay is " & class of classDisplay
  1249.             if classDisplay is "list" then
  1250.                 log "    " & theName & theCount & " is " & item 1 of theEntry & "; " & item 2 of theEntry
  1251.             else
  1252.                 log "    " & theName & theCount & " is " & theEntry
  1253.             end if
  1254.             set theCount to theCount + 1
  1255.         end repeat
  1256.     on error errMsg number n
  1257.         log "==> No go in printList. " & errMsg & " with number " & n
  1258.     end try
  1259. end printList
  1260.  
  1261. -- ------------------------------------------------------
  1262. (*
  1263. StefanK in https://macscripter.net/viewtopic.php?id=43852
  1264. Replaces one or more characters based on the length of theCharacter.
  1265.  
  1266.   Big Warning!!!
  1267.   ==============
  1268.     This on block is called by hexDumpFormatOne().  
  1269.     Therefor, you may not call hexDumpFormatOne() from this on block.
  1270.     If you so so, you get yourself into an endless loop.
  1271.     Use hexDumpFormatZero() instead.
  1272.    
  1273.     script -k <output file name>
  1274.     osascript /Applications/applescriptFiles/workwithclipboardV13-HTML.app
  1275.     use Activity Monito to stop osascript
  1276.    
  1277. *)
  1278.  
  1279. on replaceCharacter(theText, theOffset, theCharacter)
  1280.     global debug
  1281.     if debug ≥ 7 then log "in ~~~ replaceCharacter ~~~"
  1282.     if debug ≥ 7 then
  1283.         log "  theOffset is " & getIntegerAndHex(theOffset) & " with theCharacter >" & theCharacter & "<  length of theText is " & getIntegerAndHex(length of theText)
  1284.         log "theText is " & theText
  1285.     end if
  1286.    
  1287.     set theOutput to theText -- ready to return if need be.
  1288.     repeat 1 times
  1289.         -- sanity checks
  1290.         if theOffset ≤ 0 then
  1291.             display dialog "No character to replace at " & theOffset & " with character " & theCharacter & " in " & theText giving up after 10
  1292.             log "==> Adjust theOffset to be wihin the string."
  1293.             exit repeat -------------- return ---------->                  
  1294.         end if
  1295.         if (theOffset - (length of theCharacter))0 then
  1296.             display dialog "Too near the front of the buffer.  " & theOffset & " with character " & theCharacter & " in " & theText giving up after 10
  1297.             log "==> Too near the front of the buffer. "
  1298.             exit repeat -------------- return ---------->
  1299.         end if
  1300.         if (theOffset + (length of theCharacter) - 1) > (length of theText) then
  1301.             display dialog "To near the end of the buffer. " & theOffset & " with character " & theCharacter & " in " & theText giving up after 10
  1302.             log "==> Too near the end of the buffer. "
  1303.             log "  " & "theOffset is " & theOffset & " with theCharacter >" & theCharacter & "<  in " & theText
  1304.             log "length of buffer is " & getIntegerAndHex(length of theText)
  1305.             exit repeat -------------- return ---------->                  
  1306.         end if
  1307.        
  1308.         if debug ≥ 7 then
  1309.             log "theOffset is " & getIntegerAndHex(theOffset)
  1310.             log "theCharacter is " & theCharacter
  1311.         end if
  1312.        
  1313.         try
  1314.             -- what if we are at the end of the buffer.  We cannot get any remainder text.
  1315.             if theOffset ≥ (length of theText) then
  1316.                 set theOutput to (text 1 thru (theOffset - 1) of theText) & theCharacter
  1317.             else
  1318.                 set theOutput to (text 1 thru (theOffset - 1) of theText) & theCharacter & (text (theOffset + (length of theCharacter)) thru -1 of theText)
  1319.             end if
  1320.         on error errMsg number n
  1321.             log "==> No go. " & errMsg & " with number " & n
  1322.             exit repeat -------------- return ---------->
  1323.         end try
  1324.     end repeat
  1325.     return theOutput
  1326. end replaceCharacter
  1327.  
  1328. -- ------------------------------------------------------
  1329. (*
  1330. splitTextToList seems to be what you are trying to do
  1331.   thisText is the input string
  1332.   delim is what to split on
  1333.  
  1334.   results returned in a list
  1335.  
  1336.   Total hack. We know splitTextToList strips of delim so add it back.
  1337. *)
  1338.  
  1339. on splitTextToList(thisText, delim)
  1340.     global debug
  1341.     if debug ≥ 5 then log "in ~~~ splitTextToList ~~~"
  1342.    
  1343.     set returnedList to textToList(thisText, delim)
  1344.     set resultArray to {}
  1345.     copy item 1 of returnedList to the end of the resultArray
  1346.    
  1347.     repeat with i from 2 to (count of returnedList) in returnedList
  1348.         set newElement to delim & item i of returnedList
  1349.         copy newElement to the end of the resultArray
  1350.     end repeat
  1351.    
  1352.     return resultArray
  1353. end splitTextToList
  1354.  
  1355. -- ------------------------------------------------------
  1356. (*
  1357.   Retrieved data between "begin" and "end" tag. Whatever is between the strings.
  1358. *)
  1359. on tagContent(theString, startTag, endTag)
  1360.     global debug
  1361.     if debug ≥ 5 then log "in ~~~ tagContent ~~~"
  1362.     try
  1363.         if debug ≥ 5 then log "in tabContent. " & return & "    startTag is " & startTag & " endTag is " & endTag
  1364.         set beginningOfTag to chompLeftAndTag(theString, startTag)
  1365.         if length of beginningOfTag ≤ 0 then
  1366.             set middleText to ""
  1367.         else
  1368.             printHeader("beginningOfTag", beginningOfTag)
  1369.             set endingOffset to (offset of endTag in beginningOfTag)
  1370.            
  1371.             if endingOffset ≤ (length of endTag) then
  1372.                 set middleText to ""
  1373.             else
  1374.                 set middleText to text 1 thru (endingOffset - 1) of beginningOfTag
  1375.                 printHeader("middleText is ", middleText)
  1376.             end if
  1377.         end if
  1378.     on error errMsg number n
  1379.         log "==> finding contained text failed. " & errMsg & " with number " & n
  1380.         set middleText to ""
  1381.     end try
  1382.     if debug ≥ 5 then log "returning with middleText is " & middleText
  1383.     return middleText
  1384. end tagContent
  1385. -- ------------------------------------------------------
  1386. (*
  1387. textToList seems to be what you are trying to do
  1388.   thisText is the input string
  1389.   delim is what to split on
  1390.  
  1391.   returns a list of strings.  
  1392.  
  1393. - textToList was found here:
  1394. - http://macscripter.net/viewtopic.php?id=15423
  1395.  
  1396. *)
  1397.  
  1398. on textToList(thisText, delim)
  1399.     global debug
  1400.     if debug ≥ 5 then log "in ~~~ textToList ~~~"
  1401.     set resultList to {}
  1402.     set {tid, my text item delimiters} to {my text item delimiters, delim}
  1403.    
  1404.     try
  1405.         set resultList to every text item of thisText
  1406.         set my text item delimiters to tid
  1407.     on error
  1408.         set my text item delimiters to tid
  1409.     end try
  1410.     return resultList
  1411. end textToList
  1412.  
  1413. -- ------------------------------------------------------
  1414. on trimCharacters(inputTrim, outputTrim, reduce)
  1415.     global debug
  1416.     if debug ≥ 3 then
  1417.         log "in ~~~ trimCharacters ~~~"
  1418.         log "  trimCharacters: length of inputTrim is" & getIntegerAndHex(length of inputTrim)
  1419.         hexDumpFormatOne("  trimCharacters: inputTrim", inputTrim)
  1420.         log "  trimCharacters: length of outputTrim is " & getIntegerAndHex(length of outputTrim)
  1421.         hexDumpFormatOne("  trimCharacters: outputTrim", outputTrim)
  1422.         log "  trimCharacters: with reduce >" & reduce & "<  "
  1423.     end if
  1424.     set repCount to 1
  1425.    
  1426.     repeat while length of inputTrim ≥ 1 and text 1 thru 1 of inputTrim is " "
  1427.         set {inputTrim, outputTrim} to trimOneChar(inputTrim, outputTrim, 1, "")
  1428.         if debug ≥ 6 then
  1429.             log "  trimCharacters: repCount is " & repCount
  1430.             set repCount to repCount + 1
  1431.             log "  trimCharacters: length of inputTrim is" & getIntegerAndHex(length of inputTrim)
  1432.             hexDumpFormatOne("  trimCharacters: cycling inputTrim", inputTrim)
  1433.             log "  trimCharacters: length of outputTrim is " & getIntegerAndHex(length of outputTrim)
  1434.             hexDumpFormatOne("  trimCharacters: cycling outputTrim", outputTrim)
  1435.            
  1436.         end if
  1437.     end repeat
  1438.    
  1439.     if debug ≥ 3 then
  1440.         log "  trimCharacters: length of inputTrim is" & getIntegerAndHex(length of inputTrim)
  1441.         hexDumpFormatOne("  trimCharacters: completed inputTrim", inputTrim)
  1442.         log "  trimCharacters: length of outputTrim is " & getIntegerAndHex(length of outputTrim)
  1443.         hexDumpFormatOne("  trimCharacters: completed outputTrim", outputTrim)
  1444.         log "bye from  ~.~ trimCharacters ~.~"
  1445.     end if
  1446.     return {inputTrim, outputTrim}
  1447. end trimCharacters
  1448.  
  1449. -- ------------------------------------------------------
  1450. on trimOneChar(inputLf, outputTrimmed, theLfOffset, substitueCharacter)
  1451.     global debug
  1452.    
  1453.     if debug ≥ 3 then
  1454.         log "in ~~~ trimOneChar ~~~"
  1455.         hexDumpFormatOne("inputLf", inputLf)
  1456.         hexDumpFormatOne("outputTrimmed", outputTrimmed)
  1457.         log "theLfOffset, is " & getIntegerAndHex(theLfOffset)
  1458.         log "with substitueCharacter >" & substitueCharacter & "<  "
  1459.     end if
  1460.    
  1461.     -- check boundaries
  1462.     if theLfOffset ≤ 0 or (theLfOffset > (length of inputLf)) then
  1463.         -- We are almost done.
  1464.         log "no LF found."
  1465.         -- tack on any trialing stuff
  1466.         set outputTrimmed to outputTrimmed & inputLf
  1467.         set inputLf to ""
  1468.         if debug ≥ 3 then
  1469.             hexDumpFormatOne("inputLf", inputLf)
  1470.             hexDumpFormatOne("outputTrimmed", outputTrimmed)
  1471.         end if
  1472.         return {inputLf, outputTrimmed} ------------ return ------------>
  1473.     end if
  1474.    
  1475.     -- We need to deal with output first, so we haven't trimmed the input we need.
  1476.     if theLfOffset ≥ 2 then
  1477.         if debug ≥ 6 then log "  theLfOffset ≥ 2"
  1478.         set outputTrimmed to outputTrimmed & (text 1 thru (theLfOffset - 1) of inputLf) & substitueCharacter
  1479.     else if theLfOffset = 1 then
  1480.         if debug ≥ 6 then log "  theLfOffset = 1"
  1481.         -- no stuff before the lf
  1482.         set outputTrimmed to outputTrimmed & substitueCharacter
  1483.     end if
  1484.    
  1485.     -- deal with inputLf.
  1486.     if theLfOffset < (length of inputLf) then
  1487.         if debug ≥ 6 then log "  theLfOffset < (length of inputLf) "
  1488.         -- trailing stuff
  1489.         set inputLf to text (theLfOffset + 1) thru -1 of inputLf
  1490.     else if theLfOffset is (length of inputLf) then
  1491.         if debug ≥ 6 then log "  theLfOffset is (length of inputLf) "
  1492.         set inputLf to ""
  1493.     end if
  1494.    
  1495.     if debug ≥ 3 then
  1496.         hexDumpFormatOne("inputLf", inputLf)
  1497.         hexDumpFormatOne("outputTrimmed", outputTrimmed)
  1498.     end if
  1499.     if debug ≥ 4 then log "bye from  ~.~ trimOneChar ~.~"
  1500.     return {inputLf, outputTrimmed}
  1501.    
  1502. end trimOneChar
  1503.  
  1504. -- ------------------------------------------------------
  1505. (*
  1506.          Unix-like systems      LF      0A      \n
  1507.             (Linux, macOS)
  1508.                Microsoft Windows    CRLF    0D 0A   \r\n
  1509.                classic Mac OS       CR      0D          \r   Applescript return
  1510.   *)
  1511. on typeText(theData)
  1512.    
  1513.     global debug
  1514.     if debug ≥ 5 then log "in ~~~ typeText ~~~"
  1515.     set lf to character id 1
  1516.    
  1517.     if debug ≥ 2 then printHeader("the input  ( theData )", theData)
  1518.     -- Example: -- https://discussions.apple.com/docs/DOC-8841
  1519.     -- locate links
  1520.    
  1521.     set theOutputBuffer to adjustURLs(theData)
  1522.    
  1523.     -- add paragraphs
  1524.     set theOutputBuffer to addParagraphs(theOutputBuffer)
  1525.    
  1526.     if debug ≥ 2 then log "theOutputBuffer is " & return & theOutputBuffer
  1527.     if debug ≥ 4 then log "bye from  -.- typeText -.-"
  1528.     return theOutputBuffer
  1529. end typeText
  1530.  
  1531. -- ------------------------------------------------------
  1532. (* 
  1533.  place debuging data on cipboard
  1534.  has a big side effect.  
  1535. *)
  1536. on wrapupClipboardDataSelector()
  1537.     return "Global Lyme Alliance Reveals Several Drugs and Drug Combinations That Show Success in Treating Lyme Disease
  1538. https://globallymealliance.org/press-releases/global-lyme-alliance-reveals-several-drugs-drug-combinations-show-success-treating-lyme-disease/?utm_source=Newsletter&utm_campaign=220eebaf84-EMAIL_CAMPAIGN_2019_04_18_03_43&utm_medium=email&utm_term=0_2eb359dd6a-220eebaf84-37014111
  1539.  
  1540. https://www.omf.ngo/community-symposium-2/
  1541. Saturday, September 7, 2019
  1542. Live streamed
  1543. https://www.omf.ngo/community-symposium-2/
  1544.  
  1545.  
  1546. New OMF-funded Research Publication: A Nanoelectronics-blood-based diagnostic biomarker for ME/CFS
  1547.  
  1548. Dr. Ron Davis, OMF Scientific Advisory Board Director, explains the PNAS publication on the nanoneedle (April 29, 2019)
  1549.  
  1550. A paper describing the nanoneedle was published in the Proceedings of the National Academy of Sciences. Ronald W. Davis, PhD, is the senior author. Rahim Esfandyarpour, PhD, is the lead author. The nanoneedle is a test that measures changes in immune cells with their blood plasma as a result of salt stress. Inside the nanoneedle, the immune cells interfere with a small electric current. The change in electrical activity is directly correlated with the health of the sample. The test, which is still in a pilot phase, is based on how a person’s immune cells respond to stress. With blood samples from 40 people — 20 with ME/CFS and 20 without — the test yielded precise results, accurately flagging all patients and none of the healthy individuals.
  1551.  
  1552.  
  1553. https://www.youtube.com/watch?v=6Qn0fIV8SbE&feature=youtu.be"
  1554.    
  1555. end wrapupClipboardDataSelector
  1556. (*
  1557.     return "<p> </p><p> </p><p>If you are unable to set up \"two-factor authentication,\" you should set up \"2-step.\"
  1558.    
  1559.    
  1560.  
  1561.  
  1562. Run etrecheck.  The
  1563. first five runs are free.</p> "
  1564. *)
  1565.  
  1566. (* 
  1567. set the clipboard to "<html><p>As you are using a non-Apple app to access your email or other  facilities, you are now required to use an 'app-specific' password in place of your normal iCloud password. In order to do this you need to set up two-factor authentication for your Apple ID, and for this you need to have either a Mac running El Capitan or above, or an iOS device running iOS9 or above.</p><p> </p><p><a href=\"https://support.apple.com/HT204915\" target=\"_blank\">Two-factor authentication for Apple ID - Apple Support</a></p><p> </p><p><a href=\"https://support.apple.com/HT204397\" target=\"_blank\">Using app-specific passwords - Apple Support</a></p><p> </p><p>If you are unable to set up \"two-factor authentication,\" you should set up \"2-step.\"
  1568.    
  1569.    
  1570.  
  1571.  
  1572. Run etrecheck.  The
  1573. first five runs are free. Provided a report on your
  1574. machines hardware and software.  Great for diagnosing your system.  Click on the download
  1575. link at the bottom of the screen.
  1576. <a href=\"http://etrecheck.com/\" target=\"_blank\">EtreCheck</a></p><p></p>
  1577. <p></p><p>
  1578. <ol>
  1579. <li>point 1</li>
  1580. <li>point 2</li>
  1581. <li>point 3</li>
  1582. </ol>
  1583. </p>
  1584. <p>the end</p>
  1585.  
  1586. </ol></p><p>
  1587. "
  1588. *)
  1589. (*
  1590. https://www.oreilly.com/library/view/applescript-the-definitive/0596102119/re89.html
  1591.  
  1592. https://stackoverflow.com/questions/11085654/apple-script-how-can-i-copy-html-content-to-the-clipboard
  1593.  
  1594. -- user has copied a file's icon in the Finder
  1595. clipboard info
  1596. -- {{string, 20}, {«class ut16», 44}, {«class hfs », 80}, {«class
  1597.  utf8», 20}, {Unicode text, 42}, {picture, 2616}, {«class icns», 43336},
  1598. {«class furl», 62}}
  1599.  
  1600. textutil -convert html foo.rtf
  1601.  
  1602. if ((clipboard info) as string) contains "«class furl»" then
  1603.         log "the clipboard contains a file named " & (the clipboard as string)
  1604.     else
  1605.         log "the clipboard does not contain a file"
  1606.     end if
  1607.    
  1608. the clipboard       required
  1609. as  class   optional
  1610.  
  1611. tell application "Script Editor"
  1612.         activate
  1613.     end tell
  1614.    
  1615. textutil has a simplistic text to html conversion
  1616.     set clipboardDataQuoted to quoted form of theData
  1617.     log "quoted form is " & clipboardDataQuoted
  1618.    
  1619.     set toUnix to "/bin/echo -n " & clipboardDataQuoted
  1620.     set toUnix to toUnix & " | textutil -convert html -noload -nostore -stdin -stdout "
  1621.     log "toUnix is " & toUnix
  1622.     set fromUnix to do shell script toUnix
  1623.     log "fromUnix  is " & fromUnix
  1624.    
  1625.    
  1626. set s to "Today is my birthday"
  1627. log text 1 thru ((offset of "my" in s) - 1) of s
  1628. --> "Today is "
  1629.             -- text 1 thru ((offset of "my" in s) - 1) of s
  1630.             -- -1 since offset return the first character "m" position count
  1631.            
  1632. log "beginningOfTag is " & text 1 thru (minimumPositiveNumber from {200, length of beginningOfTag}) of beginningOfTag & "<+++++++++++++++++++++++"
  1633.  
  1634. https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_cmds.html
  1635.  
  1636. *)
  1637.  
  1638. --mac $ hex=`echo -n "<p>your html code here</>" | hexdump -ve '1/1 "%.2x"'`
  1639. --mac $ echo $hex
  1640. --3c703e796f75722068746d6c20636f646520686572653c2f3e
  1641. --mac $ osascript -e "set the clipboard to «data HTML${hex}»"
  1642. --mac $
  1643. (*  
  1644. A sub-routine for encoding ASCII characters.  
  1645.  
  1646. encode_char("$")  
  1647. --> returns: "%24"  
  1648.  
  1649. based on:  
  1650. https://www.macosxautomation.com/applescript/sbrt/sbrt-08.html  
  1651.  
  1652. *)
  1653. (*
  1654. Lowest Numeric Value in a List
  1655.  
  1656. This sub-routine will return the lowest numeric value in a list of items. The passed list can contain non-numeric data as well as lists within lists. For example:
  1657.  
  1658. lowest_number({-3.25, 23, 2345, "sid", 3, 67})
  1659. --> returns: -3.25
  1660. lowest_number({-3.25, 23, {-22, 78695, "bob"}, 2345, true, "sid", 3, 67})
  1661. --> returns: -22
  1662.  
  1663. If there is no numeric data in the passed list, the sub-routine will return a null string ("")
  1664.  
  1665. lowest_number({"this", "list", "contains", "only", "text"})
  1666. --> returns: ""
  1667.  
  1668. https://macosxautomation.com/applescript/sbrt/sbrt-03.html
  1669.  
  1670. Here's the sub-routine:
  1671.  
  1672. *)
  1673. (*
  1674. on lowestNumber(values_list)
  1675.     set the low_amount to ""
  1676.     repeat with i from 1 to the count of the values_list
  1677.         set this_item to item i of the values_list
  1678.         set the item_class to the class of this_item
  1679.         if the item_class is in {integer, real} then
  1680.             if the low_amount is "" then
  1681.                 set the low_amount to this_item
  1682.             else if this_item is less than the low_amount then
  1683.                 set the low_amount to item i of the values_list
  1684.             end if
  1685.         else if the item_class is list then
  1686.             set the low_value to lowest_number(this_item)
  1687.             if the the low_value is less than the low_amount then ¬
  1688.                 set the low_amount to the low_value
  1689.         end if
  1690.     end repeat
  1691.     return the low_amount
  1692. end lowestNumber
  1693.  
  1694. https://lists.apple.com/archives/applescript-users/2010/Sep/msg00139.html
  1695. set list_of_values to {10, 20, 30, 40, 50, 60, 2000, 9, 3000, 4}
  1696.  
  1697. set minimum to 9.9999999999E+12
  1698. set maximum to 0
  1699. repeat with ref_to_value in list_of_values
  1700.     set the_value to contents of ref_to_value
  1701.     if the_value > maximum then set maximum to the_value
  1702.     if the_value < minimum then set minimum to the_value
  1703. end repeat
  1704.  
  1705. {minimum, maximum}
  1706.  
  1707. may do the trick.
  1708.  
  1709. Yvan KOENIG (VALLAURIS, France) lundi 13 septembre 2010 22:32:41
  1710. *)
  1711. (* https://lists.apple.com/archives/applescript-users/2010/Sep/msg00139.html
  1712. set list_of_values to {10, 20, 30, 40, 50, 60, 2000, 9, 3000, 4}
  1713.  
  1714. set minimum to 9.9999999999E+12
  1715.  
  1716. assume it's limited to positive values
  1717.  
  1718.  
  1719. on maxValue(list_of_values)
  1720.     global debug
  1721.     if debug ≥ 5 then log "in maxValue " & return & list_of_values
  1722.     set maximum to 0
  1723.     repeat with ref_to_value in list_of_values
  1724.         set the_value to contents of ref_to_value
  1725.         if the_value > maximum then set maximum to the_value
  1726.     end repeat
  1727.     if debug ≥ 5 then log maximum
  1728.     return maximum
  1729. end maxValue
  1730. *)
  1731. -- ------------------------------------------------------
  1732. (*
  1733. http://harvey.nu/applescript_url_encode_routine.html
  1734.  
  1735. on urlencode(theText)
  1736.     set theTextEnc to ""
  1737.     repeat with eachChar in characters of theText
  1738.         set useChar to eachChar
  1739.         set eachCharNum to ASCII number of eachChar
  1740.         if eachCharNum = 32 then
  1741.             set useChar to "+"
  1742.         else if (eachCharNum ≠ 42) and (eachCharNum ≠ 95) and (eachCharNum < 45 or eachCharNum > 46) and (eachCharNum < 48 or eachCharNum > 57) and (eachCharNum < 65 or eachCharNum > 90) and (eachCharNum < 97 or eachCharNum > 122) then
  1743.             set firstDig to round (eachCharNum / 16) rounding down
  1744.             set secondDig to eachCharNum mod 16
  1745.             if firstDig > 9 then
  1746.                 set aNum to firstDig + 55
  1747.                 set firstDig to ASCII character aNum
  1748.             end if
  1749.             if secondDig > 9 then
  1750.                 set aNum to secondDig + 55
  1751.                 set secondDig to ASCII character aNum
  1752.             end if
  1753.             set numHex to ("%" & (firstDig as string) & (secondDig as string)) as string
  1754.             set useChar to numHex
  1755.         end if
  1756.         set theTextEnc to theTextEnc & useChar as string
  1757.     end repeat
  1758.     return theTextEnc
  1759. end urlencode
  1760.  
  1761. Clipboard classes after a copy from the application.
  1762. from waterfox
  1763. (*«class HTML», 13876, «class utf8», 505, «class ut16», 1012, string, 505, Unicode text, 1010*)
  1764.  
  1765. from chrome
  1766. (*«class HTML», 748, «class utf8», 204, «class ut16», 410, string, 204, Unicode text, 408*)
  1767.  
  1768. from safari
  1769. (*«class weba», 120785, «class RTF », 70255, «class HTML», 122811, «class utf8», 3370, «class ut16», 6772, uniform styles, 47132, string, 3385, scrap styles, 8122, Unicode text, 6732, uniform styles, 47132, scrap styles, 8122*)
  1770.  
  1771. iCab
  1772. (*«class weba», 1665, «class RTF », 763, «class utf8», 121, «class ut16», 244, uniform styles, 376, string, 121, scrap styles, 62, Unicode text, 242, uniform styles, 376, scrap styles, 62*)
  1773.  
  1774. Opera
  1775. (*«class HTML», 5767, «class utf8», 150, «class ut16», 302, string, 150, Unicode text, 300*)
  1776.  
  1777. Textedit
  1778. (*«class RTF », 1136, «class utf8», 138, «class ut16», 278, uniform styles, 148, string, 138, scrap styles, 22, Unicode text, 276, uniform styles, 148, scrap styles, 22*)
  1779.  
  1780. Word
  1781. (*«class DSIG», 4, «class DOBJ», 56, «class OBJD», 244, «class RTF », 30573, «class HTML», 21160, scrap styles, 22, uniform styles, 136, string, 210, Unicode text, 420, «class PDF », 13197, picture, 154058, «class EMBS», 33280, «class LNKS», 909, «class LKSD», 244, «class OJLK», 93, «class HLNK», 1387, «class OFSC», 232, «class ut16», 422, «class DSIG», 4, «class DOBJ», 56, «class OBJD», 244, scrap styles, 22, uniform styles, 136, «class EMBS», 33280, «class LNKS», 909, «class LKSD», 244, «class OJLK», 93, «class HLNK», 1387, «class OFSC», 232*)
  1782.  
  1783. TextWrangler
  1784. (*«class utf8», 185, «class BBLM», 4, «class ut16», 372, string, 185, Unicode text, 370, «class BBLM», 4*)
  1785.  
  1786. *)
  1787.  
  1788.  
  1789.  
  1790. (*
  1791.     set the clipboard to "<html><p>As you are using a non-Apple app to access your email or other  facilities, you are now required to use an 'app-specific' password in place of your normal iCloud password. In order to do this you need to set up two-factor authentication for your Apple ID, and for this you need to have either a Mac running El Capitan or above, or an iOS device running iOS9 or above.</p><p> </p><p><a href=\"https://support.apple.com/HT204915\" target=\"_blank\">Two-factor authentication for Apple ID - Apple Support</a></p><p> </p><p><a href=\"https://support.apple.com/HT204397\" target=\"_blank\">Using app-specific passwords - Apple Support</a></p><p> </p><p>If you are unable to set up two-factor authentication you should set up 2-step \"
  1792.    
  1793.    
  1794.  
  1795.  
  1796. Run etrecheck.  The
  1797. first five runs are free. Provided a report on your
  1798. machines hardware and software.  Great for diagnosing your system.  Click on the download
  1799. link at the bottom of the screen.
  1800. <a href=\"http://etrecheck.com/\" target=\"_blank\">EtreCheck</a></p><p></p>
  1801. <p></p><p>
  1802. <ol>
  1803. <li>point 1</li>
  1804. <li>point 2</li>
  1805. <li>point 3</li>
  1806. </ol>
  1807.  </p>
  1808. <p>the end</p>
  1809. "
  1810.     *)
  1811. (*  set the clipboard to "<p>Simple put, Apple attempts
  1812. to provide all the
  1813. malware detection and removal you need in Mac OS X.</p>
  1814. <p></p><p></p><p></p>
  1815. <p>\"Effective defenses against malware and other threats\" by John Galt
  1816. <a href=\"https://discussions.apple.com/docs/DOC-8841\" target=\"_blank\">Effective
  1817. defenses against malware and ot… - Apple Community</a>
  1818. </p><pre>
  1819. code line #a
  1820. code line #b
  1821. code line #c
  1822. </pre><p> </p><p>\"Avoid phishing emails, fake 'virus' alerts, phony support calls, and other scams\"
  1823. <a href=\"https://support.apple.com/en-ca/HT204759\">Avoid phishing emails, fake
  1824. 'virus' alerts, phony support calls, and other scams - Apple Support</a>
  1825. <pre>
  1826. code line #1
  1827. code line #2
  1828. code line #3
  1829. </pre>"
  1830. *)
  1831. (*
  1832.     set the clipboard to "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
  1833. <html>
  1834.   <head>
  1835.  
  1836.     <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">
  1837.     <title>asc roger's help text</title>
  1838.   </head>
  1839.   <body>
  1840.     <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">
  1841.     <span style=\"font-weight: bold; font-family: Lucida Grande;\">App-Specific
  1842.       passwords</span> (copy direct,
  1843.     clean up returns)<br>
  1844.     <br>
  1845.     There are apps in the Play Store to sync calendars and contacts -
  1846.     search on
  1847.     Smoothsync for two of the best. <br>
  1848.     <br>
  1849.     iCloud mail is standard IMAP and you
  1850.     can access it in the mail application using the settings here:<br>
  1851.     <br>
  1852.     <a href=\"https://support.apple.com/HT202304\">https://support.apple.com/HT202304</a><br>
  1853.     <br>
  1854.     As you are using a non-Apple app to access your email or other&nbsp;
  1855.     facilities, you are now required to use an 'app-specific' password
  1856.     in
  1857.     place of your normal iCloud password. In order to do this you need
  1858.     to
  1859.     set up two-factor authentication for your Apple ID, and for this you
  1860.     need to have either a Mac running El Capitan or above, or an iOS
  1861.     device
  1862.     running iOS9 or above.<br>
  1863.     <br>
  1864.     <a href=\"https://support.apple.com/HT204915\">https://support.apple.com/HT204915</a><br>
  1865.     <br>
  1866.     <a href=\"https://support.apple.com/HT204397\">https://support.apple.com/HT204397</a><br>
  1867.     <br>
  1868.     If you are unable to set up two-factor authentication you should set
  1869.     up
  1870.     2-step verification and use that to create an app-specific password
  1871.     (see link below) . Then go
  1872.     to https://appleid.apple.com , select 'Password and Security'; click
  1873.     'Generate an App-Specific
  1874.     Password' and follow the instructions. Once you have the password,
  1875.     copy
  1876.     it and paste it into the password field in the application instead
  1877.     of
  1878.     your usual iCloud password. You should also keep a note of it
  1879.     (though
  1880.     you can generate a new one if required).<br>
  1881.     <br>
  1882.     <a href=\"https://support.apple.com/kb/HT204152\">https://support.apple.com/kb/HT204152</a><br>
  1883.     <br>
  1884.     You will need to nominate a 'trusted device' - any phone capable of
  1885.     receiving SMS messages. There will be a 2-day wait before you can
  1886.     complete the process.<br>
  1887.     (A particular caveat (about 2-step only) - you will be issued with a
  1888.     'Recovery Key' in case you lose your 'trusted device'. Make sure to
  1889.     write this down and keep it in a safe place; if you lose both it and
  1890.     your trusted device you will be permanently locked out of your ID.
  1891.     You'd be surprised at the number of people who've posted here that
  1892.     they've got themselves into just that position.)<br>
  1893.     <br>
  1894.     Incidentally, Mail on Snow Leopard and earlier is not recognized as
  1895.     an
  1896.     Apple application because it's pre-iCloud and doesn't have the
  1897.     necessary facilities, so it will be necessary to obtain an
  1898.     app-specific
  1899.     password for that.
  1900.   </body>
  1901. </html>
  1902.  
  1903. <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
  1904. <html>
  1905.   <head>
  1906.  
  1907.     <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">
  1908.     <title>asc roger's help text</title>
  1909.   </head>
  1910.   <body>
  1911.     <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">
  1912.     <span style=\"font-weight: bold; font-family: Lucida Grande;\">App-Specific
  1913.       passwords</span> (copy direct,
  1914.     clean up returns)<br>
  1915.     <br>
  1916.     There are apps in the Play Store to sync calendars and contacts -
  1917.     search on
  1918.     Smoothsync for two of the best. <br>
  1919.     <br>
  1920.     iCloud mail is standard IMAP and you
  1921.     can access it in the mail application using the settings here:<br>
  1922.     <br>
  1923.     <a href=\"https://support.apple.com/HT202304\">https://support.apple.com/HT202304</a><br>
  1924.     <br>
  1925.     As you are using a non-Apple app to access your email or other&nbsp;
  1926.     facilities, you are now required to use an 'app-specific' password
  1927.     in
  1928.     place of your normal iCloud password. In order to do this you need
  1929.     to
  1930.     set up two-factor authentication for your Apple ID, and for this you
  1931.     need to have either a Mac running El Capitan or above, or an iOS
  1932.     device
  1933.     running iOS9 or above.<br>
  1934.     <br>
  1935.     <a href=\"https://support.apple.com/HT204915\">https://support.apple.com/HT204915</a><br>
  1936.     <br>
  1937.     <a href=\"https://support.apple.com/HT204397\">https://support.apple.com/HT204397</a><br>
  1938.     <br>
  1939.     If you are unable to set up two-factor authentication you should set
  1940.     up
  1941.     2-step verification and use that to create an app-specific password
  1942.     (see link below) . Then go
  1943.     to https://appleid.apple.com , select 'Password and Security'; click
  1944.     'Generate an App-Specific
  1945.     Password' and follow the instructions. Once you have the password,
  1946.     copy
  1947.     it and paste it into the password field in the application instead
  1948.     of
  1949.     your usual iCloud password. You should also keep a note of it
  1950.     (though
  1951.     you can generate a new one if required).<br>
  1952.     <br>
  1953.     <a href=\"https://support.apple.com/kb/HT204152\">https://support.apple.com/kb/HT204152</a><br>
  1954.     <br>
  1955.     You will need to nominate a 'trusted device' - any phone capable of
  1956.     receiving SMS messages. There will be a 2-day wait before you can
  1957.     complete the process.<br>
  1958.     (A particular caveat (about 2-step only) - you will be issued with a
  1959.     'Recovery Key' in case you lose your 'trusted device'. Make sure to
  1960.     write this down and keep it in a safe place; if you lose both it and
  1961.     your trusted device you will be permanently locked out of your ID.
  1962.     You'd be surprised at the number of people who've posted here that
  1963.     they've got themselves into just that position.)<br>
  1964.     <br>
  1965.     Incidentally, Mail on Snow Leopard and earlier is not recognized as
  1966.     an
  1967.     Apple application because it's pre-iCloud and doesn't have the
  1968.     necessary facilities, so it will be necessary to obtain an
  1969.     app-specific
  1970.     password for that.
  1971.   </body>
  1972. </html>
  1973. "
  1974. *)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement