This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; preview-rst.el --- description -*- lexical-binding: t; -*- | |
;; | |
;; This file is not part of GNU Emacs. | |
;; | |
;;; Commentary: | |
;; | |
;; Based on the "Intro To Emacs Lisp: Adding Live Preview when Editing Markdown" | |
;; guide at the link below. This has been followed along, but re-written to use | |
;; docutils and rst-mode as I do not have pandoc, nor do I feel I want to deal | |
;; with installing it and it's many Haskell dependencies. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def degrees_to_cardinal(degrees): | |
''' | |
Return the cardinal direction representing a given 'degrees' | |
''' | |
cardinal = ['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', | |
'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW'] | |
cardinal_len = len(cardinal) | |
ix = round(degrees / (360.0 / cardinal_len)) | |
return cardinal[ix % cardinal_len] |