Typesetting Long URLs with ConTeXt












2















I’m trying to typeset a lengthy URL in ConTeXt MKIV. The URL appears correctly in the resulting PDF when I use hyphenatedurl, but the hyperlink is wrong in two ways. First, only the first line of the URL in the PDF is a hyperlink. Second, the hyperlink target is incorrectly set to be just the first line of the URL.



Here is some example code that produces this problem for me:



% !TEX TS-program = ConTeXt (LuaTeX)

starttext
hyphenatedurl{http://cocatalog.loc.gov/cgi-bin/Pwebrecon.cgi?Search_Arg=TX0008128881&Search_Code=REGS&PID=H2kE07My-dH7holsSiJLceSpl&SEQ=20170626171039&CNT=25&HIST=1}
stoptext


On my system, this generates a PDF containing the URL printed over three lines, with line breaks as follows:



http://cocatalog.loc.gov/cgi-bin/Pwebrecon.cgi?Search_Arg=TX0008128881&Search
_Code=REGS&PID=H2kE07My-dH7holsSiJLceSpl&SEQ=20170626171039&CNT
=25&HIST=1


Of these three lines, only the first line is clickable/interactive, and its target is incorrectly set to http://cocatalog.loc.gov/cgi-bin/Pwebrecon.cgi?Search_Arg=TX0008128881&Search, rather than the full URL.



How can I set the hyperlink correctly? Alternatively, how can I turn off the hyperlink altogether?










share|improve this question



























    2















    I’m trying to typeset a lengthy URL in ConTeXt MKIV. The URL appears correctly in the resulting PDF when I use hyphenatedurl, but the hyperlink is wrong in two ways. First, only the first line of the URL in the PDF is a hyperlink. Second, the hyperlink target is incorrectly set to be just the first line of the URL.



    Here is some example code that produces this problem for me:



    % !TEX TS-program = ConTeXt (LuaTeX)

    starttext
    hyphenatedurl{http://cocatalog.loc.gov/cgi-bin/Pwebrecon.cgi?Search_Arg=TX0008128881&Search_Code=REGS&PID=H2kE07My-dH7holsSiJLceSpl&SEQ=20170626171039&CNT=25&HIST=1}
    stoptext


    On my system, this generates a PDF containing the URL printed over three lines, with line breaks as follows:



    http://cocatalog.loc.gov/cgi-bin/Pwebrecon.cgi?Search_Arg=TX0008128881&Search
    _Code=REGS&PID=H2kE07My-dH7holsSiJLceSpl&SEQ=20170626171039&CNT
    =25&HIST=1


    Of these three lines, only the first line is clickable/interactive, and its target is incorrectly set to http://cocatalog.loc.gov/cgi-bin/Pwebrecon.cgi?Search_Arg=TX0008128881&Search, rather than the full URL.



    How can I set the hyperlink correctly? Alternatively, how can I turn off the hyperlink altogether?










    share|improve this question

























      2












      2








      2








      I’m trying to typeset a lengthy URL in ConTeXt MKIV. The URL appears correctly in the resulting PDF when I use hyphenatedurl, but the hyperlink is wrong in two ways. First, only the first line of the URL in the PDF is a hyperlink. Second, the hyperlink target is incorrectly set to be just the first line of the URL.



      Here is some example code that produces this problem for me:



      % !TEX TS-program = ConTeXt (LuaTeX)

      starttext
      hyphenatedurl{http://cocatalog.loc.gov/cgi-bin/Pwebrecon.cgi?Search_Arg=TX0008128881&Search_Code=REGS&PID=H2kE07My-dH7holsSiJLceSpl&SEQ=20170626171039&CNT=25&HIST=1}
      stoptext


      On my system, this generates a PDF containing the URL printed over three lines, with line breaks as follows:



      http://cocatalog.loc.gov/cgi-bin/Pwebrecon.cgi?Search_Arg=TX0008128881&Search
      _Code=REGS&PID=H2kE07My-dH7holsSiJLceSpl&SEQ=20170626171039&CNT
      =25&HIST=1


      Of these three lines, only the first line is clickable/interactive, and its target is incorrectly set to http://cocatalog.loc.gov/cgi-bin/Pwebrecon.cgi?Search_Arg=TX0008128881&Search, rather than the full URL.



      How can I set the hyperlink correctly? Alternatively, how can I turn off the hyperlink altogether?










      share|improve this question














      I’m trying to typeset a lengthy URL in ConTeXt MKIV. The URL appears correctly in the resulting PDF when I use hyphenatedurl, but the hyperlink is wrong in two ways. First, only the first line of the URL in the PDF is a hyperlink. Second, the hyperlink target is incorrectly set to be just the first line of the URL.



      Here is some example code that produces this problem for me:



      % !TEX TS-program = ConTeXt (LuaTeX)

      starttext
      hyphenatedurl{http://cocatalog.loc.gov/cgi-bin/Pwebrecon.cgi?Search_Arg=TX0008128881&Search_Code=REGS&PID=H2kE07My-dH7holsSiJLceSpl&SEQ=20170626171039&CNT=25&HIST=1}
      stoptext


      On my system, this generates a PDF containing the URL printed over three lines, with line breaks as follows:



      http://cocatalog.loc.gov/cgi-bin/Pwebrecon.cgi?Search_Arg=TX0008128881&Search
      _Code=REGS&PID=H2kE07My-dH7holsSiJLceSpl&SEQ=20170626171039&CNT
      =25&HIST=1


      Of these three lines, only the first line is clickable/interactive, and its target is incorrectly set to http://cocatalog.loc.gov/cgi-bin/Pwebrecon.cgi?Search_Arg=TX0008128881&Search, rather than the full URL.



      How can I set the hyperlink correctly? Alternatively, how can I turn off the hyperlink altogether?







      context






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jun 26 '17 at 21:46









      J. KingJ. King

      375




      375






















          1 Answer
          1






          active

          oldest

          votes


















          4














          Actually, I get no hyperlink at all, which is what I expect because hyphenatedurl only typesets the URL and doesn't make a link. And even if I made a link using goto{<text>}[url(<link>)] it wouldn't work because interaction is not turned on. It seems to me that some heuristic of your PDF viewer is trying to detect the link and transform it into something clickable. This however fails on the line break.



          It is very easy though to set up a clickable link from within ConTeXt. I also put an empty style because I don't like bold links. See the Garden for further configuration.



          setupinteraction[state=start,style=]

          define[1]hyperlink{goto{hyphenatedurl{#1}}[url(#1)]}

          starttext

          hyperlink{http://cocatalog.loc.gov/cgi-bin/Pwebrecon.cgi?Search_Arg=TX0008128881&Search_Code=REGS&PID=H2kE07My-dH7holsSiJLceSpl&SEQ=20170626171039&CNT=25&HIST=1}

          stoptext


          enter image description here






          share|improve this answer


























          • Thank you! I had been using setupinteraction to try to turn OFF the hyperlink, but it never occurred to me that my PDF viewer may have been interpreting the text as a hyperlink on its own. Your explanation makes perfect sense.

            – J. King
            Jun 26 '17 at 22:38











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "85"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f376939%2ftypesetting-long-urls-with-context%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          4














          Actually, I get no hyperlink at all, which is what I expect because hyphenatedurl only typesets the URL and doesn't make a link. And even if I made a link using goto{<text>}[url(<link>)] it wouldn't work because interaction is not turned on. It seems to me that some heuristic of your PDF viewer is trying to detect the link and transform it into something clickable. This however fails on the line break.



          It is very easy though to set up a clickable link from within ConTeXt. I also put an empty style because I don't like bold links. See the Garden for further configuration.



          setupinteraction[state=start,style=]

          define[1]hyperlink{goto{hyphenatedurl{#1}}[url(#1)]}

          starttext

          hyperlink{http://cocatalog.loc.gov/cgi-bin/Pwebrecon.cgi?Search_Arg=TX0008128881&Search_Code=REGS&PID=H2kE07My-dH7holsSiJLceSpl&SEQ=20170626171039&CNT=25&HIST=1}

          stoptext


          enter image description here






          share|improve this answer


























          • Thank you! I had been using setupinteraction to try to turn OFF the hyperlink, but it never occurred to me that my PDF viewer may have been interpreting the text as a hyperlink on its own. Your explanation makes perfect sense.

            – J. King
            Jun 26 '17 at 22:38
















          4














          Actually, I get no hyperlink at all, which is what I expect because hyphenatedurl only typesets the URL and doesn't make a link. And even if I made a link using goto{<text>}[url(<link>)] it wouldn't work because interaction is not turned on. It seems to me that some heuristic of your PDF viewer is trying to detect the link and transform it into something clickable. This however fails on the line break.



          It is very easy though to set up a clickable link from within ConTeXt. I also put an empty style because I don't like bold links. See the Garden for further configuration.



          setupinteraction[state=start,style=]

          define[1]hyperlink{goto{hyphenatedurl{#1}}[url(#1)]}

          starttext

          hyperlink{http://cocatalog.loc.gov/cgi-bin/Pwebrecon.cgi?Search_Arg=TX0008128881&Search_Code=REGS&PID=H2kE07My-dH7holsSiJLceSpl&SEQ=20170626171039&CNT=25&HIST=1}

          stoptext


          enter image description here






          share|improve this answer


























          • Thank you! I had been using setupinteraction to try to turn OFF the hyperlink, but it never occurred to me that my PDF viewer may have been interpreting the text as a hyperlink on its own. Your explanation makes perfect sense.

            – J. King
            Jun 26 '17 at 22:38














          4












          4








          4







          Actually, I get no hyperlink at all, which is what I expect because hyphenatedurl only typesets the URL and doesn't make a link. And even if I made a link using goto{<text>}[url(<link>)] it wouldn't work because interaction is not turned on. It seems to me that some heuristic of your PDF viewer is trying to detect the link and transform it into something clickable. This however fails on the line break.



          It is very easy though to set up a clickable link from within ConTeXt. I also put an empty style because I don't like bold links. See the Garden for further configuration.



          setupinteraction[state=start,style=]

          define[1]hyperlink{goto{hyphenatedurl{#1}}[url(#1)]}

          starttext

          hyperlink{http://cocatalog.loc.gov/cgi-bin/Pwebrecon.cgi?Search_Arg=TX0008128881&Search_Code=REGS&PID=H2kE07My-dH7holsSiJLceSpl&SEQ=20170626171039&CNT=25&HIST=1}

          stoptext


          enter image description here






          share|improve this answer















          Actually, I get no hyperlink at all, which is what I expect because hyphenatedurl only typesets the URL and doesn't make a link. And even if I made a link using goto{<text>}[url(<link>)] it wouldn't work because interaction is not turned on. It seems to me that some heuristic of your PDF viewer is trying to detect the link and transform it into something clickable. This however fails on the line break.



          It is very easy though to set up a clickable link from within ConTeXt. I also put an empty style because I don't like bold links. See the Garden for further configuration.



          setupinteraction[state=start,style=]

          define[1]hyperlink{goto{hyphenatedurl{#1}}[url(#1)]}

          starttext

          hyperlink{http://cocatalog.loc.gov/cgi-bin/Pwebrecon.cgi?Search_Arg=TX0008128881&Search_Code=REGS&PID=H2kE07My-dH7holsSiJLceSpl&SEQ=20170626171039&CNT=25&HIST=1}

          stoptext


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 25 at 22:09

























          answered Jun 26 '17 at 22:19









          Henri MenkeHenri Menke

          72.6k8160270




          72.6k8160270













          • Thank you! I had been using setupinteraction to try to turn OFF the hyperlink, but it never occurred to me that my PDF viewer may have been interpreting the text as a hyperlink on its own. Your explanation makes perfect sense.

            – J. King
            Jun 26 '17 at 22:38



















          • Thank you! I had been using setupinteraction to try to turn OFF the hyperlink, but it never occurred to me that my PDF viewer may have been interpreting the text as a hyperlink on its own. Your explanation makes perfect sense.

            – J. King
            Jun 26 '17 at 22:38

















          Thank you! I had been using setupinteraction to try to turn OFF the hyperlink, but it never occurred to me that my PDF viewer may have been interpreting the text as a hyperlink on its own. Your explanation makes perfect sense.

          – J. King
          Jun 26 '17 at 22:38





          Thank you! I had been using setupinteraction to try to turn OFF the hyperlink, but it never occurred to me that my PDF viewer may have been interpreting the text as a hyperlink on its own. Your explanation makes perfect sense.

          – J. King
          Jun 26 '17 at 22:38


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f376939%2ftypesetting-long-urls-with-context%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to change which sound is reproduced for terminal bell?

          Can I use Tabulator js library in my java Spring + Thymeleaf project?

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents