Skip to content

Instantly share code, notes, and snippets.

@alexras
Created February 16, 2012 02:06
Show Gist options
  • Select an option

  • Save alexras/1840952 to your computer and use it in GitHub Desktop.

Select an option

Save alexras/1840952 to your computer and use it in GitHub Desktop.
Turn a Google Code table into HTML table rows, and convert any backticks in the table to <code> tags
(defun google-code-table-to-html ()
(interactive)
(save-restriction
(narrow-to-region (region-beginning) (region-end))
(goto-char (region-beginning))
(while (re-search-forward "^||" nil t)
(replace-match "<tr><td>"))
(goto-char (region-beginning))
(while (re-search-forward "||$" nil t)
(replace-match "</td></tr>"))
(goto-char (region-beginning))
(while (re-search-forward "||" nil t)
(replace-match "</td><td>"))
(goto-char (region-beginning))
(while (re-search-forward "`\\(.*?\\)`" nil t)
(replace-match (concat "<code>" (match-string 1) "</code>")))
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment