How does the Rich Text section generate a link in code?

Content created in the visual theme editor for OS2.0 settings,blocks,sections, template,etc are store in JSON files. ala configurations.

Inspect the file with the settings for that section for the value of the rich text sections content.

i.e if the section is on the frontpage/homepage/index inspect index.json.

URLs in settings are an escaped JSON string, because of the slashes or other characters.

i.e in a text block text-setting of a rich text section

"1234567asdfgh": {
  "type": "text",
  "settings": {
    "text": "

All Collections<\/a><\/p>"
  },
  ...

Loosely as if you were creating a URL in a setting info property. https://shopify.dev/docs/themes/architecture/settings/input-settings#create-links

If you don’t mean a url within actual rich-text value that is in a rich text section you need to elaborate.