26

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.

18
  • 2
    Got an example?
    – Bart
    Commented Oct 29, 2013 at 8:50
  • 1
    I guess you could view the page source and look at the raw HTML? Commented Oct 29, 2013 at 8:53
  • 4
    @benisuǝqbackwards - It will show the output in the page source too not the actual source we are looking for.
    – Himanshu
    Commented Oct 29, 2013 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
    Commented Oct 29, 2013 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
    Commented Oct 29, 2013 at 9:04
  • 2
    @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... Commented Oct 29, 2013 at 9:04
  • 1
    @brasofilo Well, if this is currently not possible, I'd indeed re-tag this into a request Commented Oct 29, 2013 at 9:05
  • 1
    @KerrekSB Ah, I misread. I thought we were talking about old comments no longer displaying right.
    – Bart
    Commented Oct 29, 2013 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. Commented Oct 29, 2013 at 9:16
  • @Dukeling Come on, I implicitly meant "intuitive"... Commented Oct 29, 2013 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. Commented Oct 29, 2013 at 9:25
  • 1
    @TobiasKienzler the data explorer updates once a week. Commented Oct 29, 2013 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
    Commented Nov 1, 2013 at 5:09
  • 1
    @MichaelT Indeed, especially if interspersed with text such that otherwise many show-source-right-clicks were necessary Commented Nov 1, 2013 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
    Commented Mar 14, 2017 at 10:31

3 Answers 3

18

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.

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

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.

6

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 ...

0

You must log in to answer this question.

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