Loading ...
Sorry, an error occurred while loading the content.

Re: [Clip] Footnotes

Expand Messages
  • Bob McAllister
    ... Axel I think you will find that this collection of clips will do the job. The main clip (Process footnotes) will collect any text placed within
    Message 1 of 3 , Sep 7 9:55 PM
    • 0 Attachment
      On 9/5/06, Axel Berger <Axel-Berger@...> wrote:
      > If I write <ref>Some commentary or remark</ref> > it will create a
      > footnote mark with automatic (re-)numbering there and
      > put the remark at the bottom of the current document.
      >
      > Has anyone manged to emulate that using clips?

      Axel

      I think you will find that this collection of clips will do the job.

      The main clip (Process footnotes) will collect any text placed within
      <ref></ref> tags, replace it with a sequential hyperlinked number and
      then write a single numbered list of all the references at the
      selected location (marked by <Create footnotes here>) within the body
      of the HTML file.

      I have followed my personal preference to have footnotes hyperlinked
      in both directions (from the reference to the note, and from the note
      back to where the reader was in the main text flow).

      The supporting clips (Mark refs and Footnote position) are intended to
      simplify the task of preparing the file to run the main clip but you
      may find it just as convenient to enter this information by hand.

      A limitation is that any <ref></ref> pair that contains an HTML tag
      (such as <i>) will be skipped. If you need to add any HTML (such as
      hyperlinks) to references, do it after they are collected in one place
      in the file.

      The processing of footnotes will work correctly once only, so a second
      attempt to run the clip on the same file is blocked (to avoid damage).
      If you need to add another reference; reload the unprocessed copy of
      the file (saved automatically by the clip on its first run), include
      the new information, resave and run the clip again.

      The variable %dlt% (defined in the first line of the main clip) holds
      a string of characters used (internally) to mark the end of each
      reference. It can be any string (up to 10 characters) but needs to be
      something that cannot occur in any reference (or else that reference
      will be cut where the string occurs into two footnotes instead of one,
      which will not match your original). I used ~`~ but you can change
      this as you wish (and the clip will adjust automatically).

      The main clip uses two class names (ftrf and ftnt) in the HTML to
      enable references and footnotes to be styled visually to suit the rest
      of your document. The final clip contains a few lines from my css file
      indicating one way this can be done.

      I have marked any long lines that are likely to be broken in the email
      by placing ";long line follows" above and a comment mark ";" below
      each one.

      I hope this is useful.

      Bob

      H=";HTML footnotes"

      H="Mark refs"
      ^!InsertHTML <ref>^&</ref>

      H="Footnote position"
      ^!InsertText <Create footnotes here>

      H="Process footnotes"
      ^!Set %refstring%=""; %dlt%="~`~"
      :check_if_safe
      ^!Find "<Create footnotes here>" WS
      ^!IfError NEXT ELSE Skip_2
      ;long line follows
      ^!Info [L]This file is not ready to be processed.^%NL%It does not have
      a location marked to place the footnotes.
      ;
      ^!GoTo END
      :force_save
      ^!Set %suffix%=_unprocessed; %origname%=^$GetDocName$
      ;long line follows
      ^!Set %ext%=^$StrCopy(^$GetDocName$;^$StrPosRight(".";^$GetDocName$;0)$;^$Calc(^$StrSize(^$GetDocName$)$+1-^$StrPosRight(".";^$GetDocName$;0)$;0)$)$
      ;
      ;long line follows
      ;^!Set %newname%=^$StrCopyLeft(^$GetDocName$;^$Calc(^$StrPosRight(".";^$GetDocName$;0)$-1;0)$)$
      ;
      ^!Append %newname% ^%suffix%^%ext%
      ^!Save AS ^%newname%
      ^!Jump Doc_Start
      :collect_refs
      ^!Find <ref>+[^<]+</ref> RS
      ^!IfError make_array
      ;long line follows
      ^!Set %grab%=^$StrCopy(^$GetSelection$;6;^$Calc(^$StrSize(^$GetSelection$)$-11;0)$)$
      ;
      ^!Append %refstring% ^%grab%^%dlt%
      ^!Goto collect_refs
      :make_array
      ^!If ^$StrSize(^%refstring%)$>0 Skip_2
      ^!Info There were no references found for conversion.
      ^!GoTo END
      ^!SetListDelimiter ^%dlt%
      ;long line follows
      ^!SetArray %refs%=^$StrCopyLeft(^%refstring%;^$Calc(^$StrSize(^%refstring%)$-^$StrSize(^%dlt%)$;0)$)$
      ;
      :replace_refs
      ^!Jump Doc_Start
      ^!Set %idx%=1
      :ftrf_loop
      ;long line follows
      ^!Replace "<ref>^%refs^%idx%%</ref>" >> "<a href="#ftnt^%idx%"
      class="ftrf">^%idx%</a><a name="ftrf^%idx%" />" S
      ;
      ^!Inc %idx%
      ^!If ^%idx% <= ^%refs0% ftrf_loop
      :write_footnotes
      ^!Find "<Create footnotes here>"
      ^!Set %idx%=1
      ^!InsertHTML <div class="ftnt">^%NL%<h4>Footnotes</h4>^%NL%
      :ftnt_loop
      ;long line follows
      ^!InsertHTML <span><a name="ftnt^%idx%" /><a href="#ftrf^%idx%"
      >^%idx%</a>^%SPACE%^%refs^%idx%%</span>^%NL%
      ;
      ^!Inc %idx%
      ^!If ^%idx% <= ^%refs0% ftnt_loop
      ^!InsertHTML </div>
      :save_with_original_name
      ^!Save AS ^%origname%

      H="Insert styles"
      ;Caution - Works in FF but something here breaks IE
      ;long line follows
      ^!InsertText .ftrf{font-size: x-small;vertical-align:
      text-top;padding:0 0.5ex;}^%NL%.ftnt {border-top: thin solid
      black;}^%NL%.ftnt h4 {padding:0;margin:0;}^%NL%.ftnt span
      {display:block;font-size: small;}
      ;
    • Axel Berger
      ... Very much so, thanks. Not only will it solve the problem at hand but also teach me a lot about the finer points of clip programming. Danke Axel
      Message 2 of 3 , Sep 8 2:38 AM
      • 0 Attachment
        Bob McAllister wrote:
        > I hope this is useful.

        Very much so, thanks. Not only will it solve the problem at hand but
        also teach me a lot about the finer points of clip programming.

        Danke
        Axel
      Your message has been successfully submitted and would be delivered to recipients shortly.