Function to get a text object (paragraph, tag, ...)

How can I obtain the text of a text object? For example, I’d like to pass ip or it to a function to get the text in the paragraph/ tag.

I don’t think I understand what you mean. Could you provide specific examples? ip refers to an inner paragraph, which is just text.