Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

HN displays code just fine if you put four spaces in front of each line, like this:

    #!/usr/bin/env -S uv run
    # /// script
    # requires-python = ">=3.12"
    # dependencies = [
    #     "google-api-python-client",
    #     "google-auth-httplib2",
    #     "google-auth-oauthlib",
    #     "selenium",
    #     "webdriver_manager",
    #     "pydantic",
    # ]
    # ///
    import argparse
    import datetime
I built a tool to help me do that: https://observablehq.com/@simonw/wrap-text-at-specified-widt...

Edit: Huh, two spaces works too:

  #!/usr/bin/env -S uv run
  # /// script
  # requires-python = ">=3.12"


Two spaces, Reddit is the four spaces one.

  Two spaces
    Four spaces


which is the right choice as :set ts=2 is obviously correct


Here are the official formatting guidelines: https://news.ycombinator.com/formatdoc


Thanks Simon, I guess it was a brain fart, because I'm sure I've used this formatting a lot in the past.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: