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?
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 -----------------------------------------------------------------
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-... 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?
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-...
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 -----------------------------------------------------------------
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-...
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 -----------------------------------------------------------------
participants (3)
-
Hans Hagen
-
Hans Hagen
-
seyal.zavira@gmail.com