ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] defining hashtag simulator
@ 2024-05-19  3:40 seyal.zavira
  2024-05-19  9:08 ` [NTG-context] " Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: seyal.zavira @ 2024-05-19  3:40 UTC (permalink / raw)
  To: ntg-context

Hi all,

I want to define a command that simulate hashtag behavior in social networks,

In other words, this command should put the hashtag sign at the beginning of it, replace spaces with dashes and also it should be a clickable link and unbreakable world.
I mean like this, for example:
\myhashtag{hello world}
It should be displayed as #hello_world in the final PDF and when clicked it will search for #hello_world throughout the pdf
How is this possible?
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [NTG-context] Re: defining hashtag simulator
  2024-05-19  3:40 [NTG-context] defining hashtag simulator seyal.zavira
@ 2024-05-19  9:08 ` Hans Hagen
  2024-05-20  6:01   ` seyal.zavira
  0 siblings, 1 reply; 5+ messages in thread
From: Hans Hagen @ 2024-05-19  9:08 UTC (permalink / raw)
  To: ntg-context

On 5/19/2024 5:40 AM, seyal.zavira@gmail.com wrote:
> Hi all,
> 
> I want to define a command that simulate hashtag behavior in social networks,
> 
> In other words, this command should put the hashtag sign at the beginning of it, replace spaces with dashes and also it should be a clickable link and unbreakable world.
> I mean like this, for example:
> \myhashtag{hello world}
> It should be displayed as #hello_world in the final PDF and when clicked it will search for #hello_world throughout the pdf
> How is this possible?
One of the disppointments of pdf (some things indeed got worse over 
time) ...

"Table 215 — Named actions" lists several named actions (PDF 1.2) that 
interactive PDF processors
shall support; further names may be added in the future.
Table 215 — Named ac

Only a few were ever formal ok. Acrobat supports some more (at least 
did) but even on the

\goto{test}[action(search)]

one could not set a string. Adding a decent subset of commands is way 
easier than whatever came later to the standard. It's especially ironic 
in the perspective of accessibility.

However, if one could agree on a subset (as the standard is open) and 
open source viewers would support it ... but getting all on board is 
probably not possible).

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [NTG-context] Re: defining hashtag simulator
  2024-05-19  9:08 ` [NTG-context] " Hans Hagen
@ 2024-05-20  6:01   ` seyal.zavira
  2024-05-20  8:02     ` Hans Hagen via ntg-context
  2024-05-20 14:57     ` Hans Hagen
  0 siblings, 2 replies; 5+ messages in thread
From: seyal.zavira @ 2024-05-20  6:01 UTC (permalink / raw)
  To: ntg-context

Thanks.

What if we want the text to be copied when it is clicked?
I found these link on the stack site for this
https://tex.stackexchange.com/questions/174637/copy-to-clipboard-feature-in-pdf-output/545107#545107

also i defined this:
\def\Hashtag#1{
    \hbox{\tfa\ctxlua{
        str = "#1"
        replacespace = string.gsub(str," ","_")

        context.letterhash()
        context(replacespace)    
        }
    }
}
\starttext
\Hashtag{hello}
\stoptext

i used hbox for making phrase unbreakable.

How can you put all the code in the one Lua function and not need to put hbox or goto function outside of Lua?
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [NTG-context] Re: defining hashtag simulator
  2024-05-20  6:01   ` seyal.zavira
@ 2024-05-20  8:02     ` Hans Hagen via ntg-context
  2024-05-20 14:57     ` Hans Hagen
  1 sibling, 0 replies; 5+ messages in thread
From: Hans Hagen via ntg-context @ 2024-05-20  8:02 UTC (permalink / raw)
  To: ntg-context; +Cc: Hans Hagen

On 5/20/2024 8:01 AM, seyal.zavira@gmail.com wrote:
> Thanks.
> 
> What if we want the text to be copied when it is clicked?
> I found these link on the stack site for this
> https://tex.stackexchange.com/questions/174637/copy-to-clipboard-feature-in-pdf-output/545107#545107
> 
> also i defined this:
> \def\Hashtag#1{
>      \hbox{\tfa\ctxlua{
>          str = "#1"
>          replacespace = string.gsub(str," ","_")
> 
>          context.letterhash()
>          context(replacespace)
>          }
>      }
> }
> \starttext
> \Hashtag{hello}
> \stoptext
> 
> i used hbox for making phrase unbreakable.
> 
> How can you put all the code in the one Lua function and not need to put hbox or goto function outside of Lua?

\startluacode
interfaces.implement {
     name      = "Hashtag",
     public    = true,
     protected = true,
     arguments = "string",
     actions   = function(str)
         context("{\\nohyphens\\letterhash %s}",string.gsub(str," ","_"))
      -- str = string.gsub(str," ","_")
      -- context.bgroup()
      -- context.nohyphens()
      -- context.letterhash()
      -- context(str)
      -- context.egroup()
     end
}
\stopluacode


-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [NTG-context] Re: defining hashtag simulator
  2024-05-20  6:01   ` seyal.zavira
  2024-05-20  8:02     ` Hans Hagen via ntg-context
@ 2024-05-20 14:57     ` Hans Hagen
  1 sibling, 0 replies; 5+ messages in thread
From: Hans Hagen @ 2024-05-20 14:57 UTC (permalink / raw)
  To: ntg-context

On 5/20/2024 8:01 AM, seyal.zavira@gmail.com wrote:
> Thanks.
> 
> What if we want the text to be copied when it is clicked?
> I found these link on the stack site for this
> https://tex.stackexchange.com/questions/174637/copy-to-clipboard-feature-in-pdf-output/545107#545107
> 
> also i defined this:
> \def\Hashtag#1{
>      \hbox{\tfa\ctxlua{
>          str = "#1"
>          replacespace = string.gsub(str," ","_")
> 
>          context.letterhash()
>          context(replacespace)
>          }
>      }
> }
> \starttext
> \Hashtag{hello}
> \stoptext
> 
> i used hbox for making phrase unbreakable.
> 
> How can you put all the code in the one Lua function and not need to put hbox or goto function outside of Lua?
In the next upload you can do this:

\protected\def\Hashtag#1%
   {\begingroup
    \nohyphens
    \spacechar\underscoreasciicode
    \nospaces\plusthree
    \letterhash#1%
    \endgroup}

(was an easy extension given what we already have)

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-05-20 14:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-19  3:40 [NTG-context] defining hashtag simulator seyal.zavira
2024-05-19  9:08 ` [NTG-context] " Hans Hagen
2024-05-20  6:01   ` seyal.zavira
2024-05-20  8:02     ` Hans Hagen via ntg-context
2024-05-20 14:57     ` Hans Hagen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).