23

Sometimes (old) comments break the parser, so it would be nice to view their code to check what was (actually) supposed to be there. Is there any way to view a comment's source just like the source link in a post's revision?

edit Another application for this would be the ability to better quote comments in an answer without having to re-markdown them.

  • 2
    Got an example? – Bart Oct 29 '13 at 8:50
  • 1
    I guess you could view the page source and look at the raw HTML? – ben is uǝq backwards Oct 29 '13 at 8:53
  • 4
    @benisuǝqbackwards - It will show the output in the page source too not the actual source we are looking for. – hims056 Oct 29 '13 at 8:58
  • @Bart: Just try anything with more than one consecutive backtick, backslash or asterisk; examples should be fairly easy to make. – Kerrek SB Oct 29 '13 at 8:59
  • For what I understand of the system, either this is a feature-request or we need a custom script to "de-parse" the HTML. – brasofilo Oct 29 '13 at 9:04
  • 1
    @Bart It's not necessarily restricted to broken display, another reason might be a comment containing some formatting, links or code which one wants to quote in an answer/question without having to reformat everything again... – Tobias Kienzler Oct 29 '13 at 9:04
  • 1
    @brasofilo Well, if this is currently not possible, I'd indeed re-tag this into a request – Tobias Kienzler Oct 29 '13 at 9:05
  • 1
    @KerrekSB Ah, I misread. I thought we were talking about old comments no longer displaying right. – Bart Oct 29 '13 at 9:06
  • 3
    data.stackexchange.com ? It's not as easy as it could be, but I don't think enough people need to see this often enough that it has to be easy. – Dukeling Oct 29 '13 at 9:16
  • @Dukeling Come on, I implicitly meant "intuitive"... – Tobias Kienzler Oct 29 '13 at 9:17
  • 2
    @TobiasKienzler that's very intuitive - just put the desired post ID and you have all comments listed with their raw source. – Shadow Wizard Oct 29 '13 at 9:25
  • 1
    @TobiasKienzler the data explorer updates once a week. – Shadow Wizard Oct 29 '13 at 13:21
  • 1
    An example of use - accessing the tex on such an enabled site to easily pull it into a question or answer post. – user213963 Nov 1 '13 at 5:09
  • 1
    @MichaelT Indeed, especially if interspersed with text such that otherwise many show-source-right-clicks were necessary – Tobias Kienzler Nov 1 '13 at 7:36
  • 1
    I will add link to this answer which mentions a bookmarklet which copies the comments on a question with MathJax and MarkDown. The link in the answer is dead, but the bookmarklet is currently available here: normalhuman.github.io/stackmarklets – Martin Mar 14 '17 at 10:31
11

Based on Tim's answer, I have constructed this SEDE query.

You can put either the comment ID, or the raw comment URL and get its full details, including the raw source as requested.

To get the comment URL, middle click or right click and choose "Copy link address" over the comment timestamp:

For example, the above will result in such a link: https://meta.stackexchange.com/questions/203390/is-there-a-way-to-view-a-comments-source#comment648179_203390

Now you can either type 648179 in the CommentId text field, or the full link in the RawLink textbox.

For easy copying you might want to run run the Query with the option Text-only results enabled so it becomes easier to copy the raw results.

Note, the SEDE data is updated on a weekly basis, every Sunday or Monday so comments posted in the last week after Sunday or Monday won't show up.

  • I'm not sure this works anymore? I tried with a comment from ELL meta and it didn't output anything. – Revetahw Sep 19 '16 at 10:12
  • @Fiksdal yes is still works. Example from ELL meta. What comment exactly did you try? – Shadow Wizard Sep 20 '16 at 16:05
  • This comment. – Revetahw Sep 20 '16 at 16:14
  • @Fiksdal you missed the last paragraph in my answer: "the SEDE data is updated on a weekly basis". – Shadow Wizard Sep 20 '16 at 16:15
  • Ah, thanks :D Got it. – Revetahw Sep 20 '16 at 16:16
  • 1
    In case someone is wondering how to get the complete text without downloading the CSV file, you can resize the text column: i.stack.imgur.com/1OTLs.png – Donald Duck Oct 16 '17 at 16:24
10

You can either use Data Explorer or the API's /comments/{ids} route with the body_markdown filter to get the source of a given comment. Going with one of these options would make more sense than having native site functionality, since this isn't really a common use case.

It's also not too difficult to reverse-engineer the appropriate Markdown based on the resulting HTML source (I have something similar for chat messages from back when I did the Town Hall Digests), but obviously that takes a bit more work than the above-mentioned methods. Plus, when considering edge-cases related to bug reports, the reverse-engineered Markdown may not be identical to the source.

3

There is a User Script in this answer Converting a comment to an answer (again) which adds a "Source" link to comments:

enter image description here

When you click the link it displays the source in a popup:

enter image description here

This text can be copied and pasted elsewhere ...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .