Posts with <code> or <pre> tags


Please login or register to vote for this query.

(click on this box to dismiss)

finds posts that currently contain <code> or <pre> in raw markdown ideally indenting or backticks should be used instead

Ask Ubuntu

Q&A for Ubuntu users and developers

-- we have to use the PostHistory table to search markdown because
-- the Body schema in the Posts table contains rendered html

WITH LatestBodyRevision (PostId, PostHistoryId) AS (
     SELECT p.Id, ph.Id AS PostHistoryId
     FROM Posts p
     INNER JOIN PostHistory ph ON ph.PostId = p.Id
     WHERE ph.PostHistoryTypeId IN (2,5,8) 
           SELECT * FROM PostHistory phtwo
           WHERE phtwo.PostHistoryTypeId IN (2,5,8) AND 
                 phtwo.PostId = p.Id AND 
                 phtwo.CreationDate > ph.CreationDate

SELECT lbr.PostId AS [Post Link], 
       Score AS [Score], 
       ViewCount AS [Views], 
       LastActivityDate AS [Last Active]
FROM LatestBodyRevision lbr 
INNER JOIN PostHistory ph ON lbr.PostHistoryId = ph.Id
INNER JOIN Posts p ON lbr.PostId = p.Id
WHERE ph.Text LIKE '%<code>%' OR
      ph.Text LIKE '%<pre>%'
ORDER BY p.CreationDate ASC

Enter Parameters

Switch sites:
loading Hold tight while we fetch your results