should help you out Consider moving your table tags from the html envelope and conditionally rendering them inside your transformation like this:
// If this is the first item in the repeater, open the table tag
<%# DataItemIndex == 0 ? "<table>" : "" %>
// your trasformation code
// if this is the last item in the repeater, close the table tag
<%# DataItemIndex + 1 == DataItemCount ? "</table>" : "" %>
I think the issue was by ths following , I am guessing you want when you are on Alert 1 page to use the detail transformation? You should use a repeater, and use transformation 1 (the one with the read more URL) as the Transformation, and use your Detail transformation as the Selected Item Transformation.
This might help you You are seeing the HTML printed on the web page because you are using the HTMLEncode() method - you don't need to use this method for what you are trying to achieve. Just reference the page type field directly in the macro and the HTML generated in the rich text editor will be rendered. Assuming the name of the page type field is "HTMLContent", enter this into your transformation: