Code Monkey home page Code Monkey logo

peg-markdown-highlight's Introduction

PEG Markdown Highlight

Description

This project contains:

  • A Markdown parser for syntax highlighting, written in C. The parser itself should compile as is on OS X, Linux and Windows (at least).
  • Helper classes for syntax highlighting NSTextViews in Cocoa applications.
  • A simple example on how to highlight a GtkTextView in a GTK+ application.
  • A simple example on how to highlight a QTextEdit in a Qt application.
  • A parser for stylesheets that define syntax highlighting styles

Copyright 2011 Ali Rantakari -- http://hasseg.org

This program uses the PEG grammar from John MacFarlane's peg-markdown project, and the greg parser generator by Why The Lucky Stiff and Amos Wenger (greg is heavily based on peg/leg by Ian Piumarta). It also contains an implementation of the merge sort algorithm for linked lists by Simon Tatham.

Thanks to these gentlemen (and everyone who contributed to their projects) for making this one possible.

See the LICENSE file for licensing information.

API Documentation

The public APIs are documented using Doxygen. If you have it installed, just run make docs and they should be available under the docs/ directory.

Using the Parser in Your Application

The parser has been written in ANSI/ISO C89 with GNU extensions, which means that you need a GCC-compatible compiler (see section on MSVC below, though). You also need Bourne Shell and some common Unix utilities due to a utility shell script that is used to combine some files in a make step.

Files You Need

You need to add the following files into your project:

  • pmh_definitions.h
  • pmh_parser.h
  • pmh_parser.c

pmh_parser.c implements the parser and must be generated with make. pmh_parser.h contains the parser's public interface and pmh_definitions.h some public definitions you might want to use in files where you don't wish to import the parser interface itself.

Compiling in Microsoft Visual C++

First you need to generate pmh_parser.c somehow. There are two main ways to do this:

  • Use a Linux or OS X machine to generate it
  • Generate it on Windows using MinGW (you'd run make in the MinGW shell)

Whichever way you go, the command you run is make pmh_parser.c.

MSVC does not support some of the GNU extensions the code uses, but it should compile it nicely as C++ (just change the extensions to .cpp or set some magic switch in the project settings to get the same effect). You may need to insert the following to the beginning of pmh_parser.c:

#include "stdafx.h"

Stylesheet Parser

The pmh_styleparser.h file contains the style parser's public interface and the pmh_styleparser.c file implements the parser. The style parser depends on the main parser.

The stylesheet syntax is documented in /styleparser/stylesheet_syntax.md. This file is compiled into an HTML format upon running make docs.

peg-markdown-highlight's People

Contributors

ali-rantakari avatar vojto avatar

Stargazers

Craig Hagerman avatar Alexander North avatar 魏涛 avatar 平江 avatar ZhangShine avatar Atsuo Fukaya avatar Marco Cabazal avatar Mauro Asprea avatar  avatar

Watchers

Bogdan Farca avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.