#How to underline links ?

29 messages · Page 1 of 1 (latest)

lean olive
#

I'd like to have all my links automatically underlined (like in HTML). Is this possible without touching the source of the text (i.e. just the template) ?

dry wasp
#

?render

#show link: underline
https://google.com
lean olive
#

Thanks.

#

How no, that's not what I meant.

#

I'm talking about #links, not URLs.

dry wasp
#

As in links to locations in your document?

glacial crescent
#

#link and urls both fall under the #show link: rule, so they both will be affected.
If you only want to underline links within the document, not links to urls you can do

#show link: it => {
  if type(it.dest) == "location" {
    underline(it)
  } else {
    it
  }
}
lean olive
#

OK both solution work actually. Sorry for the confusion and thanks.

misty iron
#

Hi, thanks for this! I'd link to make my links both underlined and navy blue; does anyone know how can I achieve this? Right now I have this:

#

?render

#show link: it => [
    #set text(navy)
    #underline(it.body)]
https://google.com
heady zealotBOT
misty iron
#

But it seems a bit unidiomatic and also note that I can't close the square bracket on a new line because it would add a space after the link, even if there shouldn't be one (e.g. if there were a period after the link).

fast spruce
#

What do you find unidiomatic unidiomatic about it?

#

?render

#show link: it => {
    set text(navy)
    underline(it.body)
}
https://google.com.
misty iron
#

Thanks for the quick response!
I'm a super novice with Typst so everything feels a bit unidiomatic haha
For example, why would you set the color but apply underline directly?
Why not set both or apply both?

#

Also, I don't really get the difference between the square brackets and the curly braces in both our examples. would you mind explaining?

surreal drift
#

Take a look at the intro pages of the doc. It's a pretty central concept and you'll see it described there in more detail.

In short: you can have content (default, or surrounded like this: [content]) and you can have code blocks (like this: {code}. If you have write [text], you get the word text. If you write {text} you refer to a function called text.

You can call functions from content by prepending # (like This is a #strong(example)). But if you want to call several variables/functions, you'll end up with a lot of # symbols cluttering your way, so you're better off with a code block.

tawny halo
misty iron
#

Thanks to you both. @tawny halo I still don't completely get how one would use set underline, would you mind showcasing that by changing the example above?

fast spruce
#

?render

#show link: it => {
    set text(navy)
    set underline(stroke: 2pt) // sets properties of underline function
    show: underline // wraps everything that follows with the underline function 
    it.body
}
https://google.com.
surreal drift
#

Just curious if this works:

#

(Oops... how do I use the bot? Do I have to put ?render at the very top?)

fast spruce
surreal drift
#

?render

#show link: it => {
    set text(navy)
    show: underline.with(stroke: 2pt) // wraps everything that follows with the underline function 
    it.body
}
https://google.com.
surreal drift
#

Perfect, thanks 😄