Permalink
Browse files

Merge pull request #61 from codebrainz/markdown

New Plugin: Markdown
  • Loading branch information...
2 parents b30cb65 + ce22ed9 commit ca0c77f32eaa317784e1624900fd3128a72d2ffe @frlan frlan committed Aug 26, 2012
Showing with 9,011 additions and 0 deletions.
  1. +4 −0 Makefile.am
  2. +21 −0 build/markdown.m4
  3. +1 −0 configure.ac
  4. +1 −0 markdown/AUTHORS
  5. +339 −0 markdown/COPYING
  6. 0 markdown/ChangeLog
  7. +4 −0 markdown/Makefile.am
  8. 0 markdown/NEWS
  9. +182 −0 markdown/README
  10. +47 −0 markdown/discount/COPYRIGHT
  11. +35 −0 markdown/discount/CREDITS
  12. +61 −0 markdown/discount/Csio.c
  13. +31 −0 markdown/discount/Makefile.am
  14. +111 −0 markdown/discount/amalloc.c
  15. +29 −0 markdown/discount/amalloc.h
  16. +43 −0 markdown/discount/basename.c
  17. +33 −0 markdown/discount/blocktags
  18. +35 −0 markdown/discount/config.h
  19. +85 −0 markdown/discount/css.c
  20. +77 −0 markdown/discount/cstring.h
  21. +1,006 −0 markdown/discount/discount-changes.patch
  22. +49 −0 markdown/discount/docheader.c
  23. +152 −0 markdown/discount/dumptree.c
  24. +188 −0 markdown/discount/emmatch.c
  25. +84 −0 markdown/discount/flags.c
  26. +1,763 −0 markdown/discount/generate.c
  27. +22 −0 markdown/discount/html5.c
  28. +1,314 −0 markdown/discount/markdown.c
  29. +192 −0 markdown/discount/markdown.h
  30. +357 −0 markdown/discount/mkdio.c
  31. +111 −0 markdown/discount/mkdio.h
  32. +199 −0 markdown/discount/resource.c
  33. +39 −0 markdown/discount/setup.c
  34. +91 −0 markdown/discount/tags.c
  35. +19 −0 markdown/discount/tags.h
  36. +114 −0 markdown/discount/toc.c
  37. +30 −0 markdown/discount/version.c
  38. +82 −0 markdown/discount/xml.c
  39. +48 −0 markdown/discount/xmlpage.c
  40. +14 −0 markdown/docs/Makefile.am
  41. +527 −0 markdown/docs/help.html
  42. BIN markdown/docs/plugin.png
  43. BIN markdown/docs/plugin_mgr.png
  44. BIN markdown/docs/plugin_prefs.png
  45. BIN markdown/docs/plugin_small.png
  46. BIN markdown/docs/set_filetype.png
  47. BIN markdown/docs/settings.png
  48. +28 −0 markdown/src/Makefile.am
  49. +707 −0 markdown/src/conf.c
  50. +74 −0 markdown/src/conf.h
  51. +235 −0 markdown/src/plugin.c
  52. +365 −0 markdown/src/viewer.c
  53. +62 −0 markdown/src/viewer.h
View
@@ -90,6 +90,10 @@ if ENABLE_GPROJECT
SUBDIRS += gproject
endif
+if ENABLE_MARKDOWN
+SUBDIRS += markdown
+endif
+
if ENABLE_MULTITERM
SUBDIRS += multiterm
endif
View
@@ -0,0 +1,21 @@
+AC_DEFUN([GP_CHECK_MARKDOWN],
+[
+ GP_ARG_DISABLE([markdown], [auto])
+
+ GTK_VERSION=2.16
+ WEBKIT_VERSION=1.1.13
+
+ GP_CHECK_PLUGIN_DEPS([markdown], [MARKDOWN],
+ [gtk+-2.0 >= ${GTK_VERSION}
+ webkit-1.0 >= ${WEBKIT_VERSION}
+ gthread-2.0])
+
+ GP_STATUS_PLUGIN_ADD([Markdown], [$enable_markdown])
+
+ AC_CONFIG_FILES([
+ markdown/Makefile
+ markdown/discount/Makefile
+ markdown/src/Makefile
+ markdown/docs/Makefile
+ ])
+])
View
@@ -46,6 +46,7 @@ GP_CHECK_GEANYVC
GP_CHECK_GEANYPG
GP_CHECK_GENIUSPASTE
GP_CHECK_GPROJECT
+GP_CHECK_MARKDOWN
GP_CHECK_MULTITERM
GP_CHECK_PRETTYPRINTER
GP_CHECK_SHIFTCOLUMN
View
@@ -0,0 +1 @@
+Matthew Brush <mbrush@codebrainz.ca>
View
Oops, something went wrong.
View
No changes.
@@ -0,0 +1,4 @@
+include $(top_srcdir)/build/vars.auxfiles.mk
+
+SUBDIRS = discount src docs
+plugin = markdown
View
No changes.
View
@@ -0,0 +1,182 @@
+Markdown
+========
+
+.. image:: plugin_small.png
+ :align: center
+ :alt: The Markdown plugin in action
+ :target: plugin.png
+
+.. contents::
+
+About
+-----
+
+This plugin provides a real-time preview of rendered Markdown, that is,
+`Markdown <http://daringfireball.net/projects/markdown>`_ converted to HTML
+and inserted into an HTML template and loaded into a
+`WebKit <http://www.webkit.org>`_ view.
+
+Features
+--------
+
+ * Allows placing the preview in the sidebar or message window areas
+ * Updates the preview on-the-fly as you type, automatically.
+ * Allows simple customization of fonts and colours and complete control
+ with custom template files.
+
+Usage
+-----
+
+The preview is active by default for all documents with a Markdown filetype
+set. To set a document's filetype, choose from the menus:
+
+.. image:: set_filetype.png
+ :align: center
+ :alt: Choosing Document->Set Filetype->Markup Languages->Markdown source file
+ :target: set_filetype.png
+
+Other than that the operation should be fully automatic. Use the Plugin
+Preferences mechanism to customize some settings as described below.
+
+For more information on Markdown syntax, read the
+`Markdown Syntax Documentation
+<http://daringfireball.net/projects/markdown/syntax>`_.
+
+*Preferences*
+^^^^^^^^^^^^^
+
+.. image:: settings.png
+ :align: center
+ :alt: The Markdown plugin's preferences GUI
+ :target: settings.png
+
+Using Geany's normal Plugin Preferences mechanism, you can customize some
+important settings related to the Markdown preview. The preferences dialog
+allows changing the following settings:
+
+========= ===================================================================
+Name Description
+========= ===================================================================
+Position The area of Geany's UI to put the preview view, currently either
+ in the sidebar or message window (bottom) areas.
+Font The regular body font of the preview.
+Code Font The font to use for the code tags (monospaced) font of the preview.
+BG Color The preview's background color.
+FG Color The preview's foreground (text) color.
+Template The file containing the HTML template for the preview.
+========= ===================================================================
+
+There's two ways to access the Plugin settings, one is through the
+Plugin Manager using the buttons highlighted below:
+
+.. image:: plugin_mgr.png
+ :align: center
+ :alt: The Plugin Manager dialog showing the Help and Preferences buttons.
+ :target: plugin_mgr.png
+
+Clicking the ``Help`` button opens this document in HTML format in your web
+browser. The other way to access the plugin's preferences is through the
+``Edit`` menu as pictured below:
+
+.. image:: plugin_prefs.png
+ :align: center
+ :alt: Accessing plugin preferences from the Edit menu.
+ :target: plugin_prefs.png
+
+*Custom Templates*
+^^^^^^^^^^^^^^^^^^
+
+You can provide a custom HTML template file which contains the substitution
+strings that get replaced at run-time. The following substitution strings
+are available:
+
+============================ ================================================
+Substitution String Description
+============================ ================================================
+``@@markdown@@`` The most important substitution string and
+ gets replaced with the HTML generated from the
+ editor's Markdown buffer. Not having this one
+ in the template makes the plugin completely
+ useless.
+``@@font_name@@`` The normal font family.
+``@@code_font_name@@`` The code/monospace font family.
+``@@font_point_size@@`` The size in points of the normal font.
+``@@code_font_point_size@@`` The size in points of the code/monospace font.
+``@@bg_color@@`` The background color in hex/HTML color notation.
+``@@fg_color@@`` The foreground (text) color in hex/HTML color
+ notation.
+============================ ================================================
+
+The default template file (at the time of writing) contains the following
+HTML code::
+
+ <html>
+ <head>
+ <style type="text/css">
+ body {
+ font-family: @@font_name@@;
+ font-size: @@font_point_size@@pt;
+ background-color: @@bg_color@@;
+ color: @@fg_color@@;
+ }
+ code {
+ font-family: @@code_font_name@@;
+ font-size: @@code_font_point_size@@pt;
+ }
+ </style>
+ </head>
+ <body>
+ @@markdown@@
+ </body>
+ </html>
+
+As you can see it's just normal HTML/CSS and you can tweak it to make the
+preview contents look exactly how you want. The preview view is a WebKit
+browser, the same one used by `Google's Chrome Browser
+<http://google.com/chrome>`_ and `Apple's Safari Browser
+<http://apple.com/safari>`_ as well as numerous others, and it supports many
+modern features such as HTML5 and CSS3 support (at least partially).
+
+If you mess up the default ``template.html`` file, just delete it and the
+default one will be recreated the next time the Markdown plugin is reloaded
+(for example when Geany restarts).
+
+Requirements
+------------
+
+The plugin depends on the following libraries:
+
+ * `GTK+ <http://www.gtk.org>`_ 2.16 or greater
+ * `WebKitGTK+ <http://webkitgtk.org>`_ 1.1.18 or greater
+
+License
+-------
+
+The Markdown plugin is licensed under the GNU General Public License,
+version 2. For the full text of the license, please visit
+http://www.gnu.org/licenses/gpl-2.0.html. The GPL license covers all code
+and files *not* in the ``discount`` directory.
+
+All code inside the ``discount`` directory is under a BSD-style license
+(see the ``discount/COPYRIGHT`` file) and all contributions to this code
+*will* remain under this license. This will make it easier to integrate
+improvements to Discount back upstream if it ever makes sense. So far the
+only changes are superficial to allow it to build with the Geany-Plugins
+build system and to prevent some compiler warnings.
+
+Authors
+-------
+
+The Geany Markdown plugin is written and maintained by::
+
+ Matthew Brush <matt(at)geany(dot)org>
+
+The plugin includes the Discount Markdown library, developed by::
+
+ David Loren Parsons <http://www.pell.portland.or.us/~orc>
+
+Contact
+-------
+
+You can email me at ``matt(at)geany(dot)org``, or find me on the
+``#geany`` IRC channel on FreeNode, with the nickname ``codebrainz``.
@@ -0,0 +1,47 @@
+->Copyright (C) 2007 David Loren Parsons.
+All rights reserved.<-
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation files
+(the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge,
+publish, distribute, sublicence, and/or sell copies of the Software,
+and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution, and in the same place and form as other
+ copyright, license and disclaimer information.
+
+ 3. The end-user documentation included with the redistribution, if
+ any, must include the following acknowledgment:
+
+ This product includes software developed by
+ David Loren Parsons <http://www.pell.portland.or.us/~orc>
+
+ in the same place and form as other third-party acknowledgments.
+ Alternately, this acknowledgment may appear in the software
+ itself, in the same form and location as other such third-party
+ acknowledgments.
+
+ 4. Except as contained in this notice, the name of David Loren
+ Parsons shall not be used in advertising or otherwise to promote
+ the sale, use or other dealings in this Software without prior
+ written authorization from David Loren Parsons.
+
+THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL DAVID LOREN PARSONS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,35 @@
+Discount is primarily my work, but it has only reached the point
+where it is via contributions, critiques, and bug reports from a
+host of other people, some of which are listed before. If your
+name isn't on this list, please remind me
+ -david parsons (orc@pell.chi.il.us)
+
+
+Josh Wood -- Plan9 support.
+Mike Schiraldi -- Reddit style automatic links, MANY MANY MANY
+ bug reports about boundary conditions and
+ places where I didn't get it right.
+Jjgod Jiang -- Table of contents support.
+Petite Abeille -- Many bug reports about places where I didn't
+ get it right.
+Tim Channon -- inspiration for the `mkd_xhtmlpage()` function
+Christian Herenz-- Many bug reports regarding my implementation of
+ `[]()` and `![]()`
+A.S.Bradbury -- Portability bug reports for 64 bit systems.
+Joyent -- Loan of a solaris box so I could get discount
+ working under solaris.
+Ryan Tomayko -- Portability requests (and the rdiscount ruby
+ binding.)
+yidabu -- feedback on the documentation, bug reports
+ against utf-8 support.
+Pierre Joye -- bug reports, php discount binding.
+Masayoshi Sekimura- perl discount binding.
+Jeremy Hinegardner- bug reports about list handling.
+Andrew White -- bug reports about the format of generated urls.
+Steve Huff -- bug reports about Makefile portability (for Fink)
+Ignacio Burgue?o-- bug reports about `>%class%`
+Henrik Nyh -- bug reports about embedded html handling.
+John J. Foerch -- bug reports about incorrect `&ndash;` and `&mdash;`
+ translations.
+
+
@@ -0,0 +1,61 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include "cstring.h"
+#include "markdown.h"
+#include "amalloc.h"
+
+
+/* putc() into a cstring
+ */
+void
+Csputc(int c, Cstring *iot)
+{
+ EXPAND(*iot) = c;
+}
+
+
+/* printf() into a cstring
+ */
+int
+Csprintf(Cstring *iot, char *fmt, ...)
+{
+ va_list ptr;
+ int siz=100;
+
+ do {
+ RESERVE(*iot, siz);
+ va_start(ptr, fmt);
+ siz = vsnprintf(T(*iot)+S(*iot), ALLOCATED(*iot)-S(*iot), fmt, ptr);
+ va_end(ptr);
+ } while ( siz > (ALLOCATED(*iot)-S(*iot)) );
+
+ S(*iot) += siz;
+ return siz;
+}
+
+
+/* write() into a cstring
+ */
+int
+Cswrite(Cstring *iot, char *bfr, int size)
+{
+ RESERVE(*iot, size);
+ memcpy(T(*iot)+S(*iot), bfr, size);
+ S(*iot) += size;
+ return size;
+}
+
+
+/* reparse() into a cstring
+ */
+void
+Csreparse(Cstring *iot, char *buf, int size, int flags)
+{
+ MMIOT f;
+ ___mkd_initmmiot(&f, 0);
+ ___mkd_reparse(buf, size, 0, &f);
+ ___mkd_emblock(&f);
+ SUFFIX(*iot, T(f.out), S(f.out));
+ ___mkd_freemmiot(&f, 0);
+}
Oops, something went wrong.

0 comments on commit ca0c77f

Please sign in to comment.