What is the formal definition of a continuous function? Thomas' Calculus 14th Edition gives the following definition of a continuous function:

We define a continuous function to be one that is continuous at every
point in its domain.

As an example, it declares the function f(x)=1/x a continuous function:

The function ƒ(x) = 1/x (Figure 2.41) is a continuous function because
it is continuous at every point of its domain. The point x = 0 is
not in the domain of the function ƒ, so ƒ is not continuous on any
interval containing x = 0. Moreover, there is no way to extend ƒ to a
new function that is defined and continuous at x = 0. The function ƒ
does not have a removable discontinuity at x = 0.

On the other hand, this document I found on the MIT Math portal, has this to say about that same function 1/x:

The function 1/x is continuous on (0, ∞) and on (−∞, 0), i.e., for x >
0 and for x < 0, in other words, at every point in its domain.
However, it is not a continuous function since its domain is not an
interval. It has a single point of discontinuity, namely x = 0, and it
has an infinite discontinuity there.

Unless I'm misreading something here, these two sources are in direct contradiction with each other. So my questions are: is f(x)=1/x a continuous or discontinuous function, and what is the generally accepted formal definition of an overall continuous function?
 A: The MIT supplementary course notes you linked to give — and use — the following (non-standard) definition:

We say a function is continuous if its domain is an interval, and it is continuous at every point of that interval.

(Continuity of a function at a point and on an interval have been defined previously in the notes.)
This is actually a useful and intuitive concept, but unfortunately it does not agree with the standard definition a continuous function as used in modern mathematics, which simply requires the function to be continuous at every point in its domain, whatever that may be.
The reason why this concept is useful is that even continuous functions can behave in weird ways if their domain is not connected.  Notably, a continuous function with a connected domain always has a connected range: for real-valued functions, this implies that the intermediate value theorem holds for such functions on their whole domain, and in particular that the function cannot go from positive to negative without a zero in between, like e.g. $x \mapsto 1/x$ does.
It's just unfortunate that, presumably in an attempt at brevity, these course notes end up using the term "continuous" in a nonstandard sense, thus creating confusion.  If their author had just bothered using e.g. "continuous with a connected domain" or defining their own term or even just adding a footnote about the nonstandard terminology, this confusion could've been avoided.
A: The MIT source is treating $1/x$ as a function $\Bbb R\to\Bbb R\cup\{\pm\infty\}$ (at least, I hope so: otherwise they really are wrong!). It is still not quite right, since they haven’t specified a value for $1/0$ - perhaps their point is that no value for $1/0$ can be chosen which makes the function continuous. I think this is a poor example of a “discontinuous” function, since in general, the overwhelming majority of continuous functions (and their theory) that appear throughout mathematics are not even over $\Bbb R$, thus it is very... strange, to say: “the domain is not an interval, therefore the function is discontinuous”. That point of view limits one’s perspective to functions of the real line (which is maybe sufficient for that particular course). You shouldn’t worry too much about their example.
However, Thomas is quite correct: if you view $x\mapsto1/x$ as a function $\Bbb R\setminus\{0\}\to\Bbb R$, then it is certainly continuous. It is possible MIT were trying to simplify things (too much?) by avoiding talk about the (co)domain. But in general consideration, the continuity of the function entirely depends on the domain that you consider.
As for the question in your title: the formal, most general definition of continuity of a function $f:X\to Y$ between topological spaces $X,Y$, is that any open (closed) set in $Y$ has open (closed), respectively, preimage in $X$ when pulled back under $f$. It is equivalent to say $f$ is continuous at every point, meaning that, for any $x\in X$ and any $Y$-neighbourhood $U$ of $f(x)$, there is an $X$-neighbourhood $V$ of $x$ which $f$ maps into $U$. Even if you don’t know much topology, you can make intuitive sense of the last definition by replacing “neighbourhood” with notions of proximity ($\varepsilon-\delta$!).
