11/19/2023 0 Comments Textmate python 3![]() Step 5: Fill the Command(s) text area with the following code: Step 4: Ensure that each option for Save, Input, Output and Activation are the same as shown below (click to enlarge): ![]() Step 3: Click on the +- button in the lower left corner of the window and select New Command, then name the command Pygmentize Ruby (assuming that you want a command for Ruby). ![]() Step 2: Within TextMate click on the menu entry: Bundles -> Bundle Editor -> Show Bundle Editor and click on the triangle to open up Text in the left pane. Step 1: If you haven’t done so already, install Pygments. ![]() In other words, I’m eating my own dog food. The HTML required to present the code nicely in this section was generated from within TextMate. The following are a series of steps that you can take to reproduce the same results as mine. Ruby and Python deserve their own command because they are the languages whose code I publish the most, but pressing ⌃⌥3 (or 4) prompts a long list of languages to choose from as shown below (the image is cut to reduce its length): I placed these commands under the Text menu, since they are globally available for textual formats, whether I’m composing HTML, Textile, Markdown or ReST but this is entirely arbitrary and I suspect that many would consider the HTML menu instead or place a “Convert to HTML” entry in the menu of the specific language. Should I ever forget these 4 shortcuts, I can take a quick look at the Text bundle menu shown below. I could, if so inclined, associate all 4 commands to the same shortcut and be prompted by a menu every time this combination is pressed, obtaining something along the lines of the image shown below: Note that this is not necessarily the best arrangement, but it works well for me. In practice, this means that I use 1 and 2 most of the time and these shortcuts are easy enough to remember. ⌃⌥2 is for Python snippets, ⌃⌥3 for any other language, and ⌃⌥4 for any language as well but with the option of adding line numbers. When I select a snippet of Ruby code in TextMate and press ⌃⌥1 a snippet of code is transformed into the proper HTML. The result of that brief session is a hack that delivers the integration of TextMate and Pygments, so that code can be easily converted to HTML in order to beautifully present it.įirst, let’s see how I use it. So on the weekend I pulled out my big sharp razor and started yak shaving. However, switching between TextMate and the command line is not as convenient as I’d like. Pygments is a Python library but ships as a command line tool as well. But when it comes to highlighting code, for me Pygments is simply unbeatable. A few solutions exist, including embedding gist snippets, using “Create HTML from Document” in TextMate, or adopting JavaScript libraries or WP plugins. One of the problems that I had, and that others probably face too, is the less than smooth process of publishing properly highlighted code in posts and HTML pages. All of my posts are first drafted in my trusty editor before being published. Like many, I don’t use TextMate just for coding.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |