Moed Katan, Chapter 3, Mishnah 5. The Mishnah deals with the law of a Yom Tov that interrupts the days of mourning: one who buries his dead three days before the festival - that is, he is standing on the third day of the shivah - when Yom Tov arrives, "batlah heimenu gezeiras shivah" - the decree of the seven days is nullified from him. It is worth noting that we do not rule in accordance with this Mishnah: the halachah is that even a very small amount of mourning observed before the festival is enough, and that too interrupts the shivah, whereas our Mishnah holds that three days are required.
Eight days - nullifying the decree of thirty:
The Mishnah continues: once eight days have passed from the burial - and the shivah generally begins from the time of burial - the mourner has already entered the day following the shivah, on which he observes the practices of shloshim, the continuation of the mourning period after the shivah. If Yom Tov arrives at this point, after part of one day of shloshim has passed for him, it interrupts the shloshim as well, and the shloshim comes to an end on account of Yom Tov.
"Shabbos olah v'einah mafsekes":
Chazal established that Shabbos is included in the seven days of mourning. True, on the Shabbos that falls within the shivah actual mourning is observed, but only mourning in private, in matters between a person and himself. Therefore Shabbos is always counted as part of the shivah and does not interrupt it - for if it did interrupt, there would never be a complete shivah, since every shivah contains a Shabbos. The festivals, by contrast, do interrupt the shivah, as explained above.
"Regalim mafsikin v'einan olin":
There are cases in which the days of Yom Tov are not counted toward the shivah:
One who observed no mourning at all before the festival: for example, where the burial took place on Chol HaMoed - he must sit the entire shivah after the festival.
According to the Mishnah's view, one who observed fewer than three days: if he had only two days before Yom Tov, he must complete the remaining five days afterward. For us this has no practical application, since according to our halachic approach any amount of mourning observed before Yom Tov is nullified by it.
The days of Yom Tov do, however, count toward the shloshim.
In summary: in this Mishnah we learned that three days of mourning before the festival nullify the decree of the shivah, and that eight days from the burial nullify even the decree of the shloshim; that Shabbos counts toward the shivah and does not interrupt it, since only private mourning is observed on it; and that the festivals do interrupt, and in certain cases their days do not even count toward the shivah - but they do count toward the shloshim.